2026-01-07 20:18:11 +01:00
|
|
|
#ifndef LEXER_H
|
|
|
|
|
#define LEXER_H
|
|
|
|
|
|
2026-01-21 16:19:10 +01:00
|
|
|
#include <sys/types.h>
|
2026-01-21 18:43:17 +01:00
|
|
|
|
|
|
|
|
#include "lexer_utils.h"
|
2026-01-13 17:45:15 +01:00
|
|
|
/*
|
|
|
|
|
* @brief: returns the next (newly allocated) token without consuming it.
|
2026-01-13 19:44:56 +01:00
|
|
|
* if end of input is reached, returns a token of type TOKEN_EOF.
|
2026-01-13 17:45:15 +01:00
|
|
|
*/
|
2026-01-20 18:59:40 +01:00
|
|
|
struct token *peek_token(struct lexer_context *ctx);
|
2026-01-13 17:45:15 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief: returns the next (newly allocated) token and consumes it.
|
2026-01-13 19:44:56 +01:00
|
|
|
* if end of input is reached, returns a token of type TOKEN_EOF.
|
2026-01-16 19:31:58 +01:00
|
|
|
* It also frees the last token created if there was one.
|
2026-01-17 10:43:23 +01:00
|
|
|
*
|
2026-01-16 19:31:58 +01:00
|
|
|
* @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().
|
2026-01-08 16:32:48 +01:00
|
|
|
*/
|
2026-01-20 18:59:40 +01:00
|
|
|
struct token *pop_token(struct lexer_context *ctx);
|
2026-01-08 16:32:48 +01:00
|
|
|
|
2026-01-17 10:43:23 +01:00
|
|
|
/* @note: maybe usefull for subshells.
|
2026-01-08 16:32:48 +01:00
|
|
|
*
|
2026-01-17 10:43:23 +01:00
|
|
|
* @warning: NOT IMPLEMENTED.
|
2026-01-08 16:32:48 +01:00
|
|
|
*/
|
|
|
|
|
|
2026-01-13 19:44:56 +01:00
|
|
|
struct token *get_token_str(void);
|
2026-01-08 16:32:48 +01:00
|
|
|
|
2026-01-07 20:18:11 +01:00
|
|
|
#endif /* ! LEXER_H */
|