summaryrefslogtreecommitdiff
path: root/tnslc/tnslc.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-03-29 16:55:01 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-03-29 16:55:01 -0400
commit606ab9da9e4231564c91e4613bfbbb8883f7eb9d (patch)
tree2be0ef587d12aa11f863b4e48c388d988a665a9f /tnslc/tnslc.tnsl
parentc4638488d9a73df832542e40204f56c7d7d179e2 (diff)
File read test
Diffstat (limited to 'tnslc/tnslc.tnsl')
-rw-r--r--tnslc/tnslc.tnsl43
1 files changed, 27 insertions, 16 deletions
diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl
index 0e4e04e..23d3531 100644
--- a/tnslc/tnslc.tnsl
+++ b/tnslc/tnslc.tnsl
@@ -1,10 +1,6 @@
:import "c_wrap_linux.tnsl"
-/; module utils
- :import "vector.tnsl"
- :import "file.tnsl"
-;/
-
+:import "utils/utils.tnsl"
:import "compile/compile.tnsl"
~uint8 DEFAULT_FOUT = "out.asm\0"
@@ -17,7 +13,11 @@ usage:
\0"
-~uint8 split_test = "test/whatever/file.tnsl\0"
+~uint8 FOPEN_ERR = "Error opening file\n\0"
+
+~uint8 char_str = "%c\0"
+~uint8 newline = "\n\0"
+~uint8 rel_pth = "../../tnslc.tnsl\0"
/; main (int argc, ~~uint8 argv) [int]
asm "mov r10, rdi"
@@ -28,18 +28,29 @@ usage:
return 1
;/
- utils.Artifact art
-
- art.init()
- # art.push(split_test)
- # _printf(art.strings{0})
+ utils.File fin
+ fin.init(argv{1})
+ fin.open()
+
+ /; if (fin.at_end == true)
+ _printf(FOPEN_ERR)
+ fin.end()
+ return 2
+ ;/
+
+ /; loop (fin.at_end == false)
+ _print_num(char_str, fin.read())
+ ;/
- art.split_cstr(split_test, '/')
- ~uint8 file = art.to_cstr('/')
- _printf(file)
- _delete(file)
+ utils.File rel = fin.relative(rel_pth)
+ ~uint8 str = rel.path.to_cstr('/')
+ _printf(str)
+ _printf(newline)
+ _delete(str)
+ rel.end()
- art.end()
+ fin.close()
+ fin.end()
return 0
;/