diff options
author | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-30 01:48:18 +0200 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-30 01:55:29 +0200 |
commit | ef07fab261cce781ca750c1288574d4001f14bcf (patch) | |
tree | 9b4da44aee7cc64cec448adeee31b38e12d29e6d /src/ast.h | |
parent | 88a08db927629032d6d4c662e00f0dce2c112ce4 (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.h')
-rw-r--r-- | src/ast.h | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 */ |