diff options
author | Carlos Maniero <carlos@maniero.me> | 2023-05-02 23:45:54 -0300 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-05-03 22:56:15 +0200 |
commit | e255b793d66441097955163e3abb8f5d68ed54ba (patch) | |
tree | 413c1972e2a452ad15ba44e62034391c40b804c2 /src/ast.c | |
parent | d876d8a95cc9a7d4e06a3f6eceaacfce0993046b (diff) |
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 <carlos@maniero.me>
Diffstat (limited to 'src/ast.c')
-rw-r--r-- | src/ast.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -136,6 +136,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) { *node = (ast_node_t){ |