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_pretty_printer.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/ast_pretty_printer.c') diff --git a/src/ast_pretty_printer.c b/src/ast_pretty_printer.c index 718d22a..e2d007a 100644 --- a/src/ast_pretty_printer.c +++ b/src/ast_pretty_printer.c @@ -63,6 +63,31 @@ ast_pretty_printer_print_ast(ast_pretty_printer_t *printer, ast_node_t *ast) assert(ast); switch (ast->kind) { + case AST_IF_STMT: { + ast_if_stmt_t if_stmt = ast->data.if_stmt; + ast_pretty_printer_printf(printer, "IfStmt\n"); + ast_pretty_printer_add_indentation(printer); + { + ast_pretty_printer_printf(printer, "condition:\n"); + ast_pretty_printer_add_indentation(printer); + { + ast_pretty_printer_set_lst_children(printer); + ast_pretty_printer_print_ast(printer, if_stmt.condition); + + ast_pretty_printer_rm_indentation(printer); + } + ast_pretty_printer_printf(printer, "body:\n"); + ast_pretty_printer_add_indentation(printer); + { + ast_pretty_printer_set_lst_children(printer); + ast_pretty_printer_print_ast(printer, if_stmt.body); + + ast_pretty_printer_rm_indentation(printer); + } + ast_pretty_printer_rm_indentation(printer); + } + break; + } case AST_BINARY_OPERATION: { ast_binary_operation_t binop = ast->data.binary_operation; ast_pretty_printer_printf(printer, "BinaryOperation operation='%c'\n", operation_kinds[binop.kind]); -- cgit v1.2.3