31 lines
914 B
C
31 lines
914 B
C
#ifndef LEXER_H
|
|
#define LEXER_H
|
|
|
|
#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.
|
|
*
|
|
* @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(struct lexer_context *ctx);
|
|
|
|
/* @note: maybe usefull for subshells.
|
|
*
|
|
* @warning: NOT IMPLEMENTED.
|
|
*/
|
|
|
|
struct token *get_token_str(void);
|
|
|
|
#endif /* ! LEXER_H */
|