From 4580d68951f7f5bc684b8df42bd41482460caa14 Mon Sep 17 00:00:00 2001 From: Maix0 Date: Wed, 3 Jul 2024 22:48:33 +0200 Subject: [PATCH] Added function decl to printing --- ast/src/print_ast.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ast/src/print_ast.c b/ast/src/print_ast.c index a7579b0f..a8e3162d 100644 --- a/ast/src/print_ast.c +++ b/ast/src/print_ast.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/03 20:38:29 by maiboyer #+# #+# */ -/* Updated: 2024/07/03 22:34:13 by maiboyer ### ########.fr */ +/* Updated: 2024/07/03 22:44:59 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -65,6 +65,7 @@ void ast_print_node_regex(t_ast_node self); void ast_print_node_subshell(t_ast_node self); void ast_print_node_variable_assignment(t_ast_node self); void ast_print_node_word(t_ast_node self); +void ast_print_node_function_definition(t_ast_node self); /*^^^ DONE ^^^*/ /*vvv NOT DONE vvv*/ @@ -75,7 +76,6 @@ void ast_print_node_case_item(t_ast_node self) NOT_DONE; void ast_print_node_elif(t_ast_node self) NOT_DONE; void ast_print_node_else(t_ast_node self) NOT_DONE; void ast_print_node_for(t_ast_node self) NOT_DONE; -void ast_print_node_function_definition(t_ast_node self) NOT_DONE; void ast_print_node_heredoc_redirection(t_ast_node self) NOT_DONE; void ast_print_node_if(t_ast_node self) NOT_DONE; void ast_print_node_until(t_ast_node self) NOT_DONE; @@ -99,6 +99,22 @@ void _print_term(t_ast_terminator_kind term) /// IMPL +void ast_print_node_function_definition(t_ast_node self) +{ + t_usize i; + if (self == NULL) + return; + if (self->kind != AST_FUNCTION_DEFINITION) + return; + printf("%s()", self->data.function_definition.name); + i = 0; + while (i < self->data.function_definition.body.len) + { + ast_print_node(self->data.function_definition.body.buffer[i++]); + printf(" "); + } +} + void ast_print_node_variable_assignment(t_ast_node self) { if (self == NULL)