summaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-02 23:45:54 -0300
committerJohnny Richard <johnny@johnnyrichard.com>2023-05-03 22:56:15 +0200
commite255b793d66441097955163e3abb8f5d68ed54ba (patch)
tree413c1972e2a452ad15ba44e62034391c40b804c2 /src/ast.c
parentd876d8a95cc9a7d4e06a3f6eceaacfce0993046b (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.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index d83e5e6..8a86890 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -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){