fix(parser + lexer): interaction -- WIP

This commit is contained in:
Matteo Flebus 2026-01-16 19:31:58 +01:00
parent 04529f858c
commit 10ce140e37
5 changed files with 99 additions and 48 deletions

View file

@ -17,33 +17,39 @@
struct ast *get_ast()
{
struct list *result_list = NULL;
struct ast *current_node = NULL;
// struct list *result_list = NULL;
// struct ast *current_node = NULL;
struct token *token = peek_token();
struct token *token = PEEK_TOKEN();
while (token != NULL && token->type != TOKEN_EOF)
if (token->type == TOKEN_EOF)
{
switch (token->type)
{
case TOKEN_WORD:
token = pop_token();
// TODO
// return ast END.
}
else if (token->type == TOKEN_NEWLINE)
{
token = pop_token();
// TODO
// return ast EMPTY.
}
else // TOKEN WORD
{
// TODO
// call parse_list
current_node = parse_simple_command();
result_list = list_append(result_list, current_node);
break;
default:
// Forward
token = pop_token();
break;
}
token = peek_token();
}
/*
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;