From ad54ee1182b1549880eddc8b1969d3992d9f7f1d Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Tue, 9 May 2023 16:18:18 -0300 Subject: 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 --- src/ast.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/ast.h') diff --git a/src/ast.h b/src/ast.h index 1637173..b2c565c 100644 --- a/src/ast.h +++ b/src/ast.h @@ -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 */ -- cgit v1.2.3