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.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/ast.h') diff --git a/src/ast.h b/src/ast.h index e25f1bb..4fd1d1d 100644 --- a/src/ast.h +++ b/src/ast.h @@ -37,6 +37,11 @@ typedef struct ast_identifier_t string_view_t name; } ast_identifier_t; +typedef struct ast_variable_t +{ + ast_identifier_t *identifier; +} ast_variable_t; + typedef struct ast_function_declaration_t { ast_identifier_t identifier; @@ -91,6 +96,7 @@ typedef enum AST_RETURN_STMT, AST_UNKOWN_NODE, AST_VARIABLE_DECLARATION, + AST_VARIABLE } ast_node_kind_t; typedef union @@ -99,8 +105,9 @@ typedef union ast_function_declaration_t function; ast_literal_t literal; ast_return_stmt_t return_stmt; - ast_variable_declaration_t variable; + ast_variable_declaration_t variable; // FIXME: Rename to variable_declaration ast_identifier_t identifier; + ast_variable_t variable_ex; // FIXME: Rename to variable } ast_node_data_t; typedef struct ast_node_t @@ -127,5 +134,7 @@ ast_node_init_variable_declaration(ast_node_t *node, string_view_t variable_name // FIXME: use the naming convention void ast_literal_integer_create(ast_node_t *node, uint32_t number); +void +ast_node_init_variable(ast_node_t *node, ast_identifier_t *identifier); #endif /* AST_H */ -- cgit v1.2.3