diff options
author | Carlos Maniero <carlos@maniero.me> | 2023-05-09 16:18:18 -0300 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-05-09 22:54:46 +0200 |
commit | ad54ee1182b1549880eddc8b1969d3992d9f7f1d (patch) | |
tree | 34d6a33a6a5ccba3ff6198d0e49f1e1d4701fc27 /src/ast.h | |
parent | 8c8fc8cc30b38ef00d606a4991b655df97a52fb6 (diff) |
parser: parses an if statement no code generation
This commit parses a if statement following the grammar bellow:
if boolean_expression {
n_epressions;
}
No else neither code generation was implemented.
Signed-off-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'src/ast.h')
-rw-r--r-- | src/ast.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -111,6 +111,12 @@ typedef struct ast_variable_assignment_t ast_node_t *expression; } ast_variable_assignment_t; +typedef struct ast_if_stmt_t +{ + ast_node_t *condition; + ast_node_t *body; +} ast_if_stmt_t; + typedef enum { AST_BINARY_OPERATION, @@ -118,6 +124,7 @@ typedef enum AST_FUNCTION_DECLARATION, AST_LITERAL, AST_RETURN_STMT, + AST_IF_STMT, AST_UNKOWN_NODE, AST_VARIABLE_DECLARATION, AST_VARIABLE_ASSIGNMENT, @@ -130,6 +137,7 @@ typedef union ast_function_declaration_t function; ast_literal_t literal; ast_block_t block; + ast_if_stmt_t if_stmt; ast_return_stmt_t return_stmt; ast_variable_declaration_t variable_declaration; ast_variable_assignment_t variable_assignment; @@ -185,4 +193,7 @@ ast_node_new_variable(ast_identifier_t *identifier, type_t result_type); ast_node_t * ast_node_new_variable_assignment(ast_identifier_t *identifier, ast_node_t *expression); +ast_node_t * +ast_node_new_if_stmt(ast_node_t *condition, ast_node_t *body); + #endif /* AST_H */ |