feat(parser): parse_list() implemented

This commit is contained in:
Matteo Flebus 2026-01-16 20:12:29 +01:00
parent f33498fb13
commit ed42f0b93d
2 changed files with 50 additions and 16 deletions

View file

@ -17,9 +17,6 @@
struct ast *get_ast()
{
// struct list *result_list = NULL;
// struct ast *current_node = NULL;
struct token *token = PEEK_TOKEN();
if (token->type == TOKEN_EOF)
@ -31,25 +28,21 @@ struct ast *get_ast()
else if (token->type == TOKEN_NEWLINE)
{
token = pop_token();
// TODO
// return ast EMPTY.
return ast_create_void();
}
else // TOKEN WORD
{
// TODO
// call parse_list
current_node = parse_simple_command();
result_list = list_append(result_list, current_node);
current_node = parse_list();
}
/*
if (token == NULL)
{
puts("Internal error: cannot get the following token");
puts("Hint: EOF might be missing");
return NULL;
}
*/
if (token == NULL)
{
puts("Internal error: cannot get the following token");
puts("Hint: EOF might be missing");
return NULL;
}
*/
struct ast *result = ast_create_list(result_list);
return result;