From ef07fab261cce781ca750c1288574d4001f14bcf Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Sun, 30 Apr 2023 01:48:18 +0200 Subject: 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 Co-authored-by: Carlos Maniero --- src/ast.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index d3e9a28..49d772a 100644 --- a/src/ast.c +++ b/src/ast.c @@ -107,6 +107,13 @@ ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name (ast_node_data_t){ .variable = { .identifier = { .name = variable_name }, .type = type, .value = value } }; } +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) { -- cgit v1.2.3