From d69d2e7a7e09c4f08cd416241e2f2d9dc7d7d05f Mon Sep 17 00:00:00 2001 From: kartofen Date: Wed, 9 Jul 2025 22:49:24 +0300 Subject: untested precednece lol --- demos/lexer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'demos/lexer.c') 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 #include -#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; } -- cgit v1.2.3