diff options
Diffstat (limited to 'lex.h')
-rw-r--r-- | lex.h | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,35 @@ +#define MAX_IDENT_LENGTH 128 + +enum TOKEN_TYPE { + /* Keywords */ + TOK_MODULE, + TOK_INPUT, + TOK_EXPR, + TOK_COLON, + TOK_EOL, + TOK_OR, + TOK_AND, + TOK_XOR, + TOK_NOT, + + /* Etc */ + TOK_IDENT +}; + +struct location { + size_t line; + size_t column; + size_t leading_whitespace_len; +}; + +struct token { + enum TOKEN_TYPE type; + struct location loc; + char value[MAX_IDENT_LENGTH]; + size_t span; + struct token *next; +}; + +struct token* lex_file(FILE*); +const char *get_token_description(enum TOKEN_TYPE); + |