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

@ -26,7 +26,8 @@ struct token
/*
* @brief: returns the next (newly allocated) token without consuming it.
* if end of input is reached, returns a token of type TOKEN_EOF.
* if end of input is reached, enters in EOF looping node,
* returning only the same token of type TOKEN_EOF.
*
*/
struct token *peek_token(void);
@ -34,6 +35,10 @@ struct token *peek_token(void);
/*
* @brief: returns the next (newly allocated) token and consumes it.
* if end of input is reached, returns a token of type TOKEN_EOF.
* It also frees the last token created if there was one.
* @warning: if the last returned token was a token EOF, it frees it
* and returns NULL. This means that after peeking a token EOF
* in the parser, there must be EXACTLY ONE call to pop_token().
*
*/
struct token *pop_token(void);
@ -58,7 +63,7 @@ struct token *new_token(char *begin, ssize_t size);
/* @brief: frees the token given in argument
*
*/
void free_token(struct token *tok);
void free_token(struct token **tok);
/*
* @brief: checks if the stream used for the last token creation is empty.