lang: add var keyword for variable declarations
the var keyword allows greater control over what scope a particular variable exists in. it clarifies whether a new variable is being defined or an existing variable is being assigned to. it will also facilitate the implementation of global variables.
This commit is contained in:
@@ -46,6 +46,7 @@ static struct lex_token_def keywords[] = {
|
||||
LEX_TOKEN_DEF(IVY_KW_GET, "get"),
|
||||
LEX_TOKEN_DEF(IVY_KW_SET, "set"),
|
||||
LEX_TOKEN_DEF(IVY_KW_END, "end"),
|
||||
LEX_TOKEN_DEF(IVY_KW_VAR, "var"),
|
||||
};
|
||||
static const size_t nr_keywords = sizeof keywords / sizeof keywords[0];
|
||||
|
||||
@@ -1154,6 +1155,7 @@ const char *ivy_keyword_to_string(enum ivy_keyword keyword)
|
||||
ENUM_STR(IVY_KW_GET);
|
||||
ENUM_STR(IVY_KW_SET);
|
||||
ENUM_STR(IVY_KW_END);
|
||||
ENUM_STR(IVY_KW_VAR);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user