Merge branch 'parser' into dev

This commit is contained in:
Matteo Flebus 2026-01-16 20:28:24 +01:00
commit ebcc647bda
2 changed files with 10 additions and 6 deletions

View file

@ -18,12 +18,12 @@
struct ast *get_ast() struct ast *get_ast()
{ {
struct token *token = PEEK_TOKEN(); struct token *token = PEEK_TOKEN();
struct ast *res;
if (token->type == TOKEN_EOF) if (token->type == TOKEN_EOF)
{ {
token = pop_token(); token = pop_token();
// TODO return ast_create_end();
// return ast END.
} }
else if (token->type == TOKEN_NEWLINE) else if (token->type == TOKEN_NEWLINE)
{ {
@ -32,7 +32,7 @@ struct ast *get_ast()
} }
else // TOKEN WORD 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 res;
return result;
} }
// TODO // TODO

View file

@ -18,6 +18,11 @@
puts("Internal error: cannot get the following token"); \ puts("Internal error: cannot get the following token"); \
return NULL; \ 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) /* @brief Parses a simple list of words (command and arguments)
* and returns the resulting ast * and returns the resulting ast
*/ */
@ -44,4 +49,4 @@ struct ast* parse_and_or(void);
*/ */
struct ast* parse_else_clause(void); struct ast* parse_else_clause(void);
#define /* ! PARSING_UTILS_H */ #endif /* ! PARSING_UTILS_H */