diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/lexer.h | 1 | ||||
-rw-r--r-- | include/token.h | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/lexer.h b/include/lexer.h index 8122848..4605142 100644 --- a/include/lexer.h +++ b/include/lexer.h @@ -27,6 +27,7 @@ private: private: void string(void); void number(void); + void identifier(void); private: void add_token(token_type_e type); diff --git a/include/token.h b/include/token.h index 176ff27..92106a2 100644 --- a/include/token.h +++ b/include/token.h @@ -45,9 +45,19 @@ #define GENERATE_ENUM(ENUM) ENUM, #define GENERATE_STRING(STRING) #STRING, +#define N_KEYWORDS 16 + typedef enum { FOREACH_TOKEN(GENERATE_ENUM) } token_type_e; static const char *TOKEN_STRING[] = { FOREACH_TOKEN(GENERATE_STRING) }; +static const char *KEYWORD_STRING_MAPPING[N_KEYWORDS] + = { "and", "class", "else", "false", "for", "fun", "if", "nil", + "or", "print", "return", "super", "this", "true", "var", "while" }; + +static const token_type_e KEYWORD_TYPE_MAPPING[N_KEYWORDS] + = { AND, CLASS, ELSE, FALSE, FOR, FUN, IF, NIL, + OR, PRINT, RETURN, SUPER, THIS, TRUE, VAR, WHILE }; + class Token { private: |