diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-31 03:09:06 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-31 03:09:06 -0400 |
commit | acc33ffeb8f5eae5e6bb805f1cb409841f0aad75 (patch) | |
tree | 5801ecf64408ba281362310b325c80ca1f028b20 /tnslc/compile/generator.tnsl | |
parent | d90f254a65e7443e7d6ee7d4a3e89df21bdd4e8c (diff) |
Tenative tokenizer
Diffstat (limited to 'tnslc/compile/generator.tnsl')
-rw-r--r-- | tnslc/compile/generator.tnsl | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tnslc/compile/generator.tnsl b/tnslc/compile/generator.tnsl index 28a834d..eedc552 100644 --- a/tnslc/compile/generator.tnsl +++ b/tnslc/compile/generator.tnsl @@ -1,16 +1,25 @@ -/; generate (utils.File fin, fout) - fin.open() - fout.create() +~uint8 TOKEN_COUNT = "Token count: %d\n\0" - uint8 buf = fin.read() - /; loop (fin.at_end == false && fout.at_end == false) - fout.write(buf) - buf = fin.read() +/; generate (~utils.File fin, fout) + + utils.Vector tokens = tokenize(fin) + + _print_num(TOKEN_COUNT, tokens.count) + + fout`.create() + + /; loop (int i = 0; i < tokens.count) [i++] + ~Token tok = tokens.get(i) + ~uint8 buf = tok`.sprint() + fout`.write_cstr(buf) + fout`.write('\n') + _delete(buf) ;/ - fin.close() - fout.close() + fout`.close() + + free_token_list(~tokens) ;/ |