diff options
Diffstat (limited to 'Token.h')
-rw-r--r-- | Token.h | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -0,0 +1,40 @@ +#pragma once +#include <stdbool.h> + +enum { + TOK_NONE, + TOK_KEYWORD, + TOK_STRING, + TOK_INTEGER, + /* single char toks */ + TOK_PAREN_OPEN, + TOK_PAREN_CLOS, + TOK_CURL_OPEN, + TOK_CURL_CLOS, + TOK_SQUAR_OPEN, + TOK_SQUAR_CLOS, + TOK_SEMICOLON, + TOK_ASSIGN, + TOK_COMMA, + TOK_COMP_LESS, + TOK_MODULO, + /* double char toks */ + TOK_INCREMENT, +}; + +union TokenValue { + char *s; + char c; + int i; + double d; + bool b; +}; + +typedef struct Token { + unsigned int type; + unsigned int line; + union TokenValue v; +} Token; + +void token_free(Token *tok); +void token_print(const Token *tok); |