diff options
| author | David Moc <personal@cdatgoose.org> | 2026-03-08 15:02:30 +0100 |
|---|---|---|
| committer | David Moc <personal@cdatgoose.org> | 2026-03-08 15:02:30 +0100 |
| commit | ad035ac5d942c6448a6a0464b995c2868a8378db (patch) | |
| tree | 9c2c779d544a45b4234a6a3c311aa7b612ea975e /src/token.h | |
| parent | 0385817bb1301a778bb33f8405a435293b9f8905 (diff) | |
Gosh.\nFixed bugs in offsetting. Added syscalls. Cleaned up the previous commenting (used to pass the project thu claude to add comments but LLMs are dumb). Removed the LLM made test runner cuz fuck AI.HEADmaster
Diffstat (limited to 'src/token.h')
| -rw-r--r-- | src/token.h | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/token.h b/src/token.h index e99294e..1e57662 100644 --- a/src/token.h +++ b/src/token.h @@ -3,12 +3,14 @@ #include <string.h> -/* Token and type definitions shared by lexer, parser, and JIT. - * The type system uses a base kind plus pointer/array decorations. */ typedef enum { - TY_INT = 0, - TY_CHAR = 1, - TY_BOOL = 2, + TY_INT = 0, + TY_CHAR = 1, + TY_BOOL = 2, + TY_VOID = 3, + TY_FLOAT = 4, + TY_LONG = 5, + TY_SHORT = 6, } _TYBASE; typedef struct { @@ -19,9 +21,13 @@ typedef struct { static inline const char *tybase_name(_TYBASE b) { switch (b) { - case TY_INT: return "int"; - case TY_CHAR: return "char"; - case TY_BOOL: return "bool"; + case TY_INT: return "int"; + case TY_CHAR: return "char"; + case TY_BOOL: return "bool"; + case TY_VOID: return "void"; + case TY_FLOAT: return "float"; + case TY_LONG: return "long"; + case TY_SHORT: return "short"; default: return "?"; } } @@ -30,6 +36,10 @@ static inline const char *tybase_name(_TYBASE b) { _(TK_BEGIN, "begin") \ _(TK_INT, "int") \ _(TK_CHAR, "char") \ + _(TK_VOID, "void") \ + _(TK_FLOAT, "float") \ + _(TK_LONG, "long") \ + _(TK_SHORT, "short") \ _(TK_ASSIGN, "=") \ _(TK_EQ, "==") \ _(TK_NE, "!=") \ @@ -42,6 +52,9 @@ static inline const char *tybase_name(_TYBASE b) { _(TK_ELSE, "else") \ _(TK_FOR, "for") \ _(TK_WHILE, "while") \ + _(TK_DO, "do") \ + _(TK_BREAK, "break") \ + _(TK_CONTINUE, "continue") \ _(TK_BOOL, "bool") \ _(TK_IDENT, "ident") \ _(TK_NUMBER, "number") \ @@ -69,6 +82,15 @@ static inline const char *tybase_name(_TYBASE b) { _(TK_LBRACKET, "[") \ _(TK_RBRACKET, "]") \ _(TK_STRING, "string") \ + _(TK_PLUS_EQ, "+=") \ + _(TK_MINUS_EQ, "-=") \ + _(TK_STAR_EQ, "*=") \ + _(TK_SLASH_EQ, "/=") \ + _(TK_INC, "++") \ + _(TK_DEC, "--") \ + _(TK_SIZEOF, "sizeof") \ + _(TK_QUESTION, "?") \ + _(TK_COLON, ":") \ _(TK_EOF, "eof") \ _(TK_COMMA, ",") \ _(TK_INVALID, "invalid") \ @@ -88,8 +110,8 @@ static const char *_TN[] = { typedef struct { _TK kind; - int val; // only valid if kind == TK_NUMBER - char *lxem; // malloc’d lexeme string, or NULL + int val; + char *lxem; } _T; static _TK checkkw(const char *kw) { |
