diff options
author | Thomas Bracht Laumann Jespersen <t@laumann.xyz> | 2025-02-02 08:59:12 +0100 |
---|---|---|
committer | Thomas Bracht Laumann Jespersen <t@laumann.xyz> | 2025-02-02 08:59:12 +0100 |
commit | d8321c1947b644888f92795a75645d0c91a6a92d (patch) | |
tree | 058d5e9e66463b9b173e513c3244a4da93c0a28c /c/token.c | |
parent | 7b72404f5ec31a29aafa6faaf9c284487c819175 (diff) |
Still need to parse numbers, but otherwise the lexer looks
functional. It provides location information for each token (something
the OCaml impl does not do).
Diffstat (limited to 'c/token.c')
-rw-r--r-- | c/token.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,5 +1,8 @@ #include <assert.h> #include <string.h> +#include <stddef.h> +#include <stdint.h> +#include "types.h" #include "token.h" static char *tokennames[] = { @@ -8,11 +11,11 @@ static char *tokennames[] = { [Treturn] = "return", [Tident] = "identifier", [Tconstant] = "constant", - [Tlparen] = "lparen", - [Trparen] = "rparen", - [Tlbrace] = "lbrace", - [Trbrace] = "rbrace", - [Tsemicolon] = "semicolon", + [Tlparen] = "(", + [Trparen] = ")", + [Tlbrace] = "{", + [Trbrace] = "}", + [Tsemicolon] = ";", }; static_assert(sizeof(tokennames) / sizeof(char *) == Ntok, "token name map out of sync with tokens"); |