summaryrefslogtreecommitdiff
path: root/tnslc
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2023-09-09 17:37:20 -0400
committerKyle Gunger <kgunger12@gmail.com>2023-09-09 17:37:20 -0400
commit093045f77f80c9c63c8464dbf5d7b9310ba03b55 (patch)
tree8e9507225345fea43ccf9ec1d0ad181f0e2bb72a /tnslc
parent3bfdbd26958e3b8193500dd5fad8dcd58c5a8457 (diff)
Wrapped version of just the tokenizer
Diffstat (limited to 'tnslc')
-rw-r--r--tnslc/tokenizer_wrapped.tnsl35
1 files changed, 35 insertions, 0 deletions
diff --git a/tnslc/tokenizer_wrapped.tnsl b/tnslc/tokenizer_wrapped.tnsl
new file mode 100644
index 0000000..70a074e
--- /dev/null
+++ b/tnslc/tokenizer_wrapped.tnsl
@@ -0,0 +1,35 @@
+:include "c_wrap_linux.tnsl"
+:include "logging.tnsl"
+:include "utils.tnsl"
+:include "vector.tnsl"
+:include "tokenizer.tnsl"
+
+{}uint8 w_usage = "Usage: tokenizer [file in] [file out]"
+
+/; main (int argc, ~~uint8 argv) [int]
+ asm "mov r8, rdi"
+ asm "mov r9, rsi"
+
+ /; if (argc < 3)
+ _printf(~w_usage{0})
+ return 1
+ ;/
+
+ ~void fin = _open_file(argv{1})
+ ~void fout = _create_file(argv{2})
+
+ Vector tokens = tokenize_file(fin)
+ ~Token tok
+
+ /; loop (int i = 0; i < tokens.num_el) [i++]
+ tok = tokens.get(i)
+ print_token(tok`, fout)
+ tok`._del()
+ ;/
+
+ _close_file(fin)
+ _close_file(fout)
+
+ return 0
+;/
+