feat(lexer): implementing assignements
This commit is contained in:
parent
e1291107d4
commit
f0a7173b11
3 changed files with 41 additions and 6 deletions
|
|
@ -14,6 +14,9 @@ struct lexer_context
|
|||
// tells us if we only lexed digits in current token.
|
||||
bool only_digits;
|
||||
|
||||
// usefull to detect assignments, and syntax errors with '='.
|
||||
int equal_count;
|
||||
|
||||
struct token *previous_token;
|
||||
struct token *current_token;
|
||||
};
|
||||
|
|
@ -34,10 +37,13 @@ enum token_type
|
|||
// Blanks
|
||||
TOKEN_NULL = 0,
|
||||
TOKEN_EOF,
|
||||
TOKEN_WORD,
|
||||
TOKEN_NEWLINE,
|
||||
|
||||
// SPecial characters
|
||||
// words
|
||||
TOKEN_WORD,
|
||||
TOKEN_ASSIGNMENT_WORD,
|
||||
|
||||
// Special characters
|
||||
TOKEN_GRAVE,
|
||||
TOKEN_SEMICOLON,
|
||||
TOKEN_COMMENT,
|
||||
|
|
@ -87,12 +93,13 @@ struct token
|
|||
*/
|
||||
bool is_special_char(char *stream, ssize_t i);
|
||||
|
||||
/* @brief: return a newly allocated token, with the corresponding type.
|
||||
/* @brief: return a newly allocated token, with the type corresponding
|
||||
* to the context given in arguments.
|
||||
* The data contains [size] char, starting from [begin].
|
||||
*
|
||||
* @return: NULL on error, a token otherwise.
|
||||
*/
|
||||
struct token *new_token(char *begin, ssize_t size, bool only_digits);
|
||||
struct token *new_token(char *begin, ssize_t size, bool only_digits, int equal_count);
|
||||
|
||||
/* @brief: frees the token given in argument
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue