summaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-04-30 01:48:18 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2023-04-30 01:55:29 +0200
commitef07fab261cce781ca750c1288574d4001f14bcf (patch)
tree9b4da44aee7cc64cec448adeee31b38e12d29e6d /src/ast.c
parent88a08db927629032d6d4c662e00f0dce2c112ce4 (diff)
parser: Registry identifiers on scope
We are parsing variables/functions and checking if they are defined on scope. Otherwise we fail the parsing with a nice message. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com> Co-authored-by: Carlos Maniero <carlosmaniero@gmail.com>
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c
index d3e9a28..49d772a 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -108,6 +108,13 @@ ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name
}
void
+ast_node_init_variable(ast_node_t *node, ast_identifier_t *identifier)
+{
+ node->kind = AST_VARIABLE;
+ node->data = (ast_node_data_t){ .variable_ex = { .identifier = identifier } };
+}
+
+void
ast_node_init_identifier(ast_node_t *node, string_view_t name)
{
node->kind = AST_IDENTIFIER;