42sh/src/lexer/lexer.h

32 lines
914 B
C
Raw Normal View History

#ifndef LEXER_H
#define LEXER_H
2026-01-21 16:19:10 +01:00
#include <sys/types.h>
#include "lexer_utils.h"
/*
* @brief: returns the next (newly allocated) token without consuming it.
* if end of input is reached, returns a token of type TOKEN_EOF.
*/
struct token *peek_token(struct lexer_context *ctx);
/*
* @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.
2026-01-17 10:43:23 +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
*/
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
*/
struct token *get_token_str(void);
2026-01-08 16:32:48 +01:00
#endif /* ! LEXER_H */