diff options
Diffstat (limited to 'include/token.h')
| -rw-r--r-- | include/token.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/include/token.h b/include/token.h new file mode 100644 index 0000000..c6a61cd --- /dev/null +++ b/include/token.h @@ -0,0 +1,71 @@ +#ifndef __TOKEN_H +#define __TOKEN_H + +enum TokenType { + // Single-character tokens. + LEFT_PAREN, + RIGHT_PAREN, + LEFT_BRACE, + RIGHT_BRACE, + COMMA, + DOT, + MINUS, + PLUS, + SEMICOLON, + SLASH, + STAR, + + // One or two character tokens. + BANG, + BANG_EQUAL, + EQUAL, + EQUAL_EQUAL, + GREATER, + GREATER_EQUAL, + LESS, + LESS_EQUAL, + + // Literals. + IDENTIFIER, + STRING, + NUMBER, + + // Keywords. + AND, + CLASS, + ELSE, + FUN, + FOR, + IF, + NIL, + OR, + PRINT, + RETURN, + SUPER, + THIS, + VAR, + WHILE, + + TRUE, + FALSE, + + EOFF +}; + +class Token +{ +private: + TokenType type; + char *lexeme; + // literal + unsigned int line; + char *string; + +public: + Token(TokenType type, char *lexeme, unsigned int line); + + char *to_string(void); + void clean(void); +}; + +#endif |
