feat(lexer): quote handling
This commit is contained in:
parent
f4d7f58ef5
commit
c81afc2c69
2 changed files with 127 additions and 77 deletions
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
enum lexing_mode
|
||||
{
|
||||
LEXER_NORMAL,
|
||||
LEXER_QUOTE,
|
||||
LEXER_DOUBLE_QUOTE
|
||||
};
|
||||
|
||||
enum token_type
|
||||
{
|
||||
// Special characters
|
||||
|
|
@ -10,8 +17,12 @@ enum token_type
|
|||
TOKEN_EOF,
|
||||
TOKEN_WORD,
|
||||
TOKEN_NEWLINE,
|
||||
|
||||
// WARNING: quote and double quote should never be used inside a token.
|
||||
// Its only use is to know if we are inside a quote, and which type of quote
|
||||
TOKEN_QUOTE,
|
||||
TOKEN_DOUBLE_QUOTE,
|
||||
|
||||
TOKEN_GRAVE,
|
||||
TOKEN_SEMICOLON,
|
||||
TOKEN_COMMENT,
|
||||
|
|
@ -43,8 +54,6 @@ struct token
|
|||
|
||||
/*
|
||||
* @brief: returns the next (newly allocated) token without consuming it.
|
||||
* if end of input is reached, enters in EOF looping node,
|
||||
* returning only the same token of type TOKEN_EOF.
|
||||
* if end of input is reached, returns a token of type TOKEN_EOF.
|
||||
*/
|
||||
struct token *peek_token(void);
|
||||
|
|
@ -57,7 +66,6 @@ struct token *peek_token(void);
|
|||
* @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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue