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:
2025-04-15 11:02:47 +01:00
parent abebdb595a
commit e430b7b2f1
9 changed files with 190 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ extern struct ast_node_type expr_node_ops;
extern struct ast_node_type block_node_ops;
extern struct ast_node_type msg_node_ops;
extern struct ast_node_type op_node_ops;
extern struct ast_node_type var_node_ops;
extern struct ast_node_type ident_node_ops;
extern struct ast_node_type int_node_ops;
extern struct ast_node_type double_node_ops;
@@ -51,6 +52,7 @@ static const struct ast_node_type *node_ops[] = {
[IVY_AST_BLOCK] = &block_node_ops,
[IVY_AST_MSG] = &msg_node_ops,
[IVY_AST_OP] = &op_node_ops,
[IVY_AST_VAR] = &var_node_ops,
[IVY_AST_IDENT] = &ident_node_ops,
[IVY_AST_INT] = &int_node_ops,
[IVY_AST_DOUBLE] = &double_node_ops,
@@ -268,6 +270,7 @@ const char *ivy_ast_node_type_to_string(enum ivy_ast_node_type v)
ENUM_STR(IVY_AST_UNIT_IMPORT);
ENUM_STR(IVY_AST_DISCARD);
ENUM_STR(IVY_AST_INT);
ENUM_STR(IVY_AST_VAR);
ENUM_STR(IVY_AST_DOUBLE);
ENUM_STR(IVY_AST_STRING);
ENUM_STR(IVY_AST_FSTRING);