From 77dbf3a5011566b4a6274b3cdfa075dd723642d3 Mon Sep 17 00:00:00 2001 From: Carlos Maniero Date: Tue, 2 May 2023 23:45:49 -0300 Subject: Parser: Make the parser function return the ast_node In many situations, the parser is responsible for reserving memory for nodes, particularly during function body parsing. This commit introduces a new standard where parser functions not only allocate memory for ast_nodes, but also return them. In case of a parser error, a NULL pointer is returned. This standard will be extended to other parsers in future commits, ensuring consistency throughout the codebase. Signed-off-by: Carlos Maniero --- src/parser.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/parser.h') diff --git a/src/parser.h b/src/parser.h index d3e1431..27feb17 100644 --- a/src/parser.h +++ b/src/parser.h @@ -40,8 +40,9 @@ typedef struct parser_t void parser_init(parser_t *parser, lexer_t *lexer, scope_t *scope); -bool -parser_parse_function_declaration(parser_t *parser, ast_node_t *node); +ast_node_t * +parser_parse_function_declaration(parser_t *parser); + bool parser_parse_expression(parser_t *parser, ast_node_t *node); -- cgit v1.2.3