From e255b793d66441097955163e3abb8f5d68ed54ba Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Tue, 2 May 2023 23:45:54 -0300 Subject: parser: Variable assignment allocates their own node This commit makes variable assignment parser to allocate memory for the node. It also moves the node initialization to the ast.c to follow our standard for node initialization. Signed-off-by: Carlos Maniero --- src/ast.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index d83e5e6..8a86890 100644 --- a/src/ast.c +++ b/src/ast.c @@ -135,6 +135,20 @@ ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name }; } +void +ast_node_init_variable_assignment(ast_node_t *node, ast_identifier_t *identifier, ast_node_t *expression) +{ + *node = (ast_node_t){ + .kind = AST_VARIABLE_ASSIGNMENT, + .data = { + .variable_assignment = { + .identifier = identifier, + .expression = expression, + }, + }, + }; +} + void ast_node_init_variable(ast_node_t *node, ast_identifier_t *identifier) { -- cgit v1.2.3