From e3d8e031c6f20c68f2227028ee8b3e73cd9b8161 Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Mon, 1 May 2023 01:57:22 +0200 Subject: 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 Co-authored-by: Carlos Maniero --- src/ast.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ast.h') 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; -- cgit v1.2.3