From ce60a95471f894fc15028777b9fff11a84458677 Mon Sep 17 00:00:00 2001 From: Matteo Flebus Date: Fri, 16 Jan 2026 20:27:57 +0100 Subject: [PATCH] fix(parser): made it compile --- src/parser/parser.c | 9 ++++----- src/parser/parsing_utils.h | 7 ++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/parser/parser.c b/src/parser/parser.c index 5edae88..0cce2fb 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -18,12 +18,12 @@ struct ast *get_ast() { struct token *token = PEEK_TOKEN(); + struct ast *res; if (token->type == TOKEN_EOF) { token = pop_token(); - // TODO - // return ast END. + return ast_create_end(); } else if (token->type == TOKEN_NEWLINE) { @@ -32,7 +32,7 @@ struct ast *get_ast() } else // TOKEN WORD { - current_node = parse_list(); + res = parse_list(); } /* @@ -44,8 +44,7 @@ struct ast *get_ast() } */ - struct ast *result = ast_create_list(result_list); - return result; + return res; } // TODO diff --git a/src/parser/parsing_utils.h b/src/parser/parsing_utils.h index a133ef0..a380a85 100644 --- a/src/parser/parsing_utils.h +++ b/src/parser/parsing_utils.h @@ -18,6 +18,11 @@ puts("Internal error: cannot get the following token"); \ return NULL; \ } + +/* @brief: parses a list of [and_or] rules, separated by semicolons. + */ +struct ast *parse_list(void); + /* @brief Parses a simple list of words (command and arguments) * and returns the resulting ast */ @@ -44,4 +49,4 @@ struct ast* parse_and_or(void); */ struct ast* parse_else_clause(void); -#define /* ! PARSING_UTILS_H */ +#endif /* ! PARSING_UTILS_H */