diff options
author | kartofen <mladenovnasko0@gmail.com> | 2025-07-09 22:49:24 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2025-07-09 22:49:24 +0300 |
commit | d69d2e7a7e09c4f08cd416241e2f2d9dc7d7d05f (patch) | |
tree | d8b32a0749e79ddc79ce998a382ee7dc06f0a175 /demos/lexer.c | |
parent | 2c85f2d087b9b2f3922b856beed4e2dd5b0fc126 (diff) |
untested precednece lol
Diffstat (limited to 'demos/lexer.c')
-rw-r--r-- | demos/lexer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/demos/lexer.c b/demos/lexer.c index a206066..01ec950 100644 --- a/demos/lexer.c +++ b/demos/lexer.c @@ -3,7 +3,8 @@ #include <ctype.h> #include <string.h> -#include "dict.c" +#include "util/dict.h" +static struct dict d; struct token { enum symbol { @@ -77,7 +78,7 @@ static char *next_token(char *str) } } else if(isalpha(c0)) { // iden or named symbol char *substr = substring(str, off); - if((tok.sym = dict_check(substr)) == -1) { + if((tok.sym = dict_check(&d, substr)) == -1) { tok.sym = IDEN; tok.iden = strdup(substr); } @@ -92,7 +93,11 @@ static char *next_token(char *str) int main(void) { - dict_compile(); + d.strings = strings; + d.nstrings = nstrings; + d.char_to_bit = char_to_bit; + + dict_compile(&d); char *str = "blah 0 1 443 test{here}13}{1\"fdlkfjakl{fher} fdsfj\" here {therern{there{tok {wow} {"; while((str = next_token(str))) @@ -111,6 +116,6 @@ int main(void) printf("\n"); - dict_free(); + dict_free(&d); return 0; } |