diff options
author | David Phillips <david@sighup.nz> | 2018-08-06 01:06:51 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2018-08-06 01:06:51 +1200 |
commit | b768269f91355292c7a5f5ecccdc80f6eec74634 (patch) | |
tree | 60eabd4d2388c10ee7339e30ed1f7ce334081b3b /token.h | |
parent | 5652b840200cada7686196cffc1c7c62b2b91ed9 (diff) | |
download | hence-b768269f91355292c7a5f5ecccdc80f6eec74634.tar.xz |
Factor token definitions out
Diffstat (limited to 'token.h')
-rw-r--r-- | token.h | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#ifndef HENCE_TOKEN_H +#define HENCE_TOKEN_H + +#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, + TOK_NAND, + TOK_NOR, + + /* 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; +}; + +#endif |