diff options
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; } |