aboutsummaryrefslogtreecommitdiff
path: root/include/token.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/token.h')
-rw-r--r--include/token.h10
1 files changed, 10 insertions, 0 deletions
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: