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

@ -8,24 +8,6 @@
#include "lexer/lexer.h"
#include "utils/ast/ast.h"
// === Macros
#define PEEK_TOKEN() \
peek_token(); \
if (token == NULL) \
{ \
puts("Internal error: cannot get the following token"); \
return NULL; \
}
#define POP_TOKEN() \
pop_token(); \
if (token == NULL) \
{ \
puts("Internal error: cannot get the following token"); \
return NULL; \
}
// === Static functions
/* Returns true if c is a command terminator, false otherwise
@ -58,8 +40,9 @@ struct ast *parse_simple_command(void)
while (!isterminator(token))
{
command_elements = list_append(command_elements, token->data);
token = POP_TOKEN();
command_elements = list_append(command_elements, token->data);
token = PEEK_TOKEN();
}
struct ast *result = ast_create_command(command_elements);