summaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-05-01 01:57:22 +0200
committerCarlos Maniero <carlos@maniero.me>2023-05-01 18:24:42 -0300
commite3d8e031c6f20c68f2227028ee8b3e73cd9b8161 (patch)
tree52068df5df3fea73eea9e5af311b03771a0f614a /src/ast.h
parent8c56ddf0b640b8880eb5b97e5ca1b787585c29c0 (diff)
parser: Implement variable assignment
This commit introduces variable assignment making it possible to change a variable value. Example: myvar: i32 = 1; myvar = 2; Signed-off-by: Johnny Richard <johnny@johnnyrichard.com> Co-authored-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ast.h b/src/ast.h
index 2bd700e..5095852 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -87,6 +87,12 @@ typedef struct ast_variable_declaration_t
ast_node_t *value;
} ast_variable_declaration_t;
+typedef struct ast_variable_assignment_t
+{
+ ast_identifier_t *identifier;
+ ast_node_t *expression;
+} ast_variable_assignment_t;
+
typedef enum
{
AST_BINARY_OPERATION,
@@ -96,6 +102,7 @@ typedef enum
AST_RETURN_STMT,
AST_UNKOWN_NODE,
AST_VARIABLE_DECLARATION,
+ AST_VARIABLE_ASSIGNMENT,
AST_VARIABLE
} ast_node_kind_t;
@@ -106,6 +113,7 @@ typedef union
ast_literal_t literal;
ast_return_stmt_t return_stmt;
ast_variable_declaration_t variable_declaration;
+ ast_variable_assignment_t variable_assignment;
ast_identifier_t identifier;
ast_variable_t variable;
} ast_node_data_t;