lang: ast: replace var keyword with global
local variables are now created automatically when they are first assigned to. the global keyword can be used to declare that a name refers to a global variable instead, at which point, assigning to the name results in the assignment referencing the global variable instead of allocating a new global variable.
This commit is contained in:
@@ -19,10 +19,10 @@ static struct token_parse_result parse_use_keyword(
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
static struct token_parse_result parse_var_keyword(
|
||||
static struct token_parse_result parse_global_keyword(
|
||||
struct ivy_parser *ctx, struct ivy_token *tok)
|
||||
{
|
||||
parser_push_state(ctx, IVY_AST_VAR, 0);
|
||||
parser_push_state(ctx, IVY_AST_GLOBAL, 0);
|
||||
return PARSE_RESULT(IVY_OK, 0);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ struct ast_node_type unit_node_ops = {
|
||||
KW_PARSER(PACKAGE, parse_package_keyword),
|
||||
KW_PARSER(CLASS, parse_class_keyword),
|
||||
KW_PARSER(USE, parse_use_keyword),
|
||||
KW_PARSER(VAR, parse_var_keyword),
|
||||
KW_PARSER(GLOBAL, parse_global_keyword),
|
||||
},
|
||||
.n_symbol_parsers = {
|
||||
SYM_PARSER(DOT, parse_dot),
|
||||
|
||||
Reference in New Issue
Block a user