summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-04-11 18:50:08 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-04-11 18:50:08 -0400
commitd0213b4202ac12d7e92f7125e87c31d9ecb637dd (patch)
tree50164dfa2295c6806f3866c24a897789856337a7
parent41cb9e107b20153449526cedec101e33f21d8630 (diff)
Remove src folders
-rw-r--r--libtnsl/algo/algo.tnsl (renamed from libtnsl/src/algo/algo.tnsl)0
-rw-r--r--libtnsl/algo/alloc.tnsl (renamed from libtnsl/src/algo/alloc.tnsl)0
-rw-r--r--libtnsl/algo/dealloc.tnsl (renamed from libtnsl/src/algo/dealloc.tnsl)0
-rw-r--r--libtnsl/algo/math/math.tnsl (renamed from libtnsl/src/algo/math/math.tnsl)0
-rw-r--r--libtnsl/asm/asm.tnsl (renamed from libtnsl/src/asm/asm.tnsl)0
-rw-r--r--libtnsl/box/box.tnsl (renamed from libtnsl/src/box/box.tnsl)0
-rw-r--r--libtnsl/box/iterator.tnsl (renamed from libtnsl/src/box/iterator.tnsl)0
-rw-r--r--libtnsl/box/map.tnsl (renamed from libtnsl/src/box/map.tnsl)0
-rw-r--r--libtnsl/box/string.tnsl (renamed from libtnsl/src/box/string.tnsl)0
-rw-r--r--libtnsl/box/tree.tnsl (renamed from libtnsl/src/box/tree.tnsl)0
-rw-r--r--libtnsl/box/vector.tnsl (renamed from libtnsl/src/box/vector.tnsl)0
-rw-r--r--libtnsl/io/block.tnsl (renamed from libtnsl/src/io/block.tnsl)0
-rw-r--r--libtnsl/io/file.tnsl (renamed from libtnsl/src/io/file.tnsl)0
-rw-r--r--libtnsl/io/io.tnsl (renamed from libtnsl/src/io/io.tnsl)0
-rw-r--r--libtnsl/io/std.tnsl (renamed from libtnsl/src/io/std.tnsl)0
-rw-r--r--libtnsl/io/stream.tnsl (renamed from libtnsl/src/io/stream.tnsl)0
-rw-r--r--libtnsl/libtnsl.tnsl (renamed from libtnsl/src/libtnsl.tnsl)0
-rw-r--r--libtnsl/reflect/dispatch.tnsl (renamed from libtnsl/src/reflect/dispatch.tnsl)0
-rw-r--r--libtnsl/reflect/reflect.tnsl (renamed from libtnsl/src/reflect/reflect.tnsl)0
-rw-r--r--libtnsl/reflect/resolver.tnsl (renamed from libtnsl/src/reflect/resolver.tnsl)0
-rw-r--r--libtnsl/reflect/type.tnsl (renamed from libtnsl/src/reflect/type.tnsl)0
-rw-r--r--libtnsl/reflect/virtual.tnsl (renamed from libtnsl/src/reflect/virtual.tnsl)0
-rw-r--r--libtnsl/time/alg.tnsl (renamed from libtnsl/src/time/alg.tnsl)0
-rw-r--r--libtnsl/time/conv.tnsl (renamed from libtnsl/src/time/conv.tnsl)0
-rw-r--r--libtnsl/time/parse.tnsl (renamed from libtnsl/src/time/parse.tnsl)0
-rw-r--r--libtnsl/time/time.tnsl (renamed from libtnsl/src/time/time.tnsl)0
-rw-r--r--spec/1.md4
-rw-r--r--tnslc/ast/ast.tnsl (renamed from tnslc/src/ast/ast.tnsl)0
-rw-r--r--tnslc/ast/node.tnsl (renamed from tnslc/src/ast/node.tnsl)0
-rw-r--r--tnslc/compile/arch/arch.tnsl (renamed from tnslc/src/compile/arch/arch.tnsl)0
-rw-r--r--tnslc/compile/arch/common.tnsl (renamed from tnslc/src/compile/arch/common.tnsl)0
-rw-r--r--tnslc/compile/arch/isa_arm.tnsl (renamed from tnslc/src/compile/arch/isa_arm.tnsl)0
-rw-r--r--tnslc/compile/arch/isa_risc_v.tnsl (renamed from tnslc/src/compile/arch/isa_risc_v.tnsl)0
-rw-r--r--tnslc/compile/arch/isa_x86.tnsl (renamed from tnslc/src/compile/arch/isa_x86.tnsl)0
-rw-r--r--tnslc/compile/compile.tnsl (renamed from tnslc/src/compile/compile.tnsl)0
-rw-r--r--tnslc/compile/format/elf.tnsl (renamed from tnslc/src/compile/format/elf.tnsl)0
-rw-r--r--tnslc/compile/format/format.tnsl (renamed from tnslc/src/compile/format/format.tnsl)0
-rw-r--r--tnslc/compile/format/iex.tnsl (renamed from tnslc/src/compile/format/iex.tnsl)0
-rw-r--r--tnslc/compile/format/out.tnsl (renamed from tnslc/src/compile/format/out.tnsl)0
-rw-r--r--tnslc/compile/format/pe.tnsl (renamed from tnslc/src/compile/format/pe.tnsl)0
-rw-r--r--tnslc/flags/flags.tnsl (renamed from tnslc/src/flags/flags.tnsl)0
-rw-r--r--tnslc/parse/parse.tnsl (renamed from tnslc/src/parse/parse.tnsl)8
-rw-r--r--tnslc/parse/token.tnsl (renamed from tnslc/src/parse/token.tnsl)84
-rw-r--r--tnslc/parse/tokenizer.tnsl53
-rw-r--r--tnslc/src/parse/tokenizer.tnsl38
-rw-r--r--tnslc/tnslc.tnsl (renamed from tnslc/src/tnslc.tnsl)27
46 files changed, 115 insertions, 99 deletions
diff --git a/libtnsl/src/algo/algo.tnsl b/libtnsl/algo/algo.tnsl
index 7df9198..7df9198 100644
--- a/libtnsl/src/algo/algo.tnsl
+++ b/libtnsl/algo/algo.tnsl
diff --git a/libtnsl/src/algo/alloc.tnsl b/libtnsl/algo/alloc.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/algo/alloc.tnsl
+++ b/libtnsl/algo/alloc.tnsl
diff --git a/libtnsl/src/algo/dealloc.tnsl b/libtnsl/algo/dealloc.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/algo/dealloc.tnsl
+++ b/libtnsl/algo/dealloc.tnsl
diff --git a/libtnsl/src/algo/math/math.tnsl b/libtnsl/algo/math/math.tnsl
index 5676d09..5676d09 100644
--- a/libtnsl/src/algo/math/math.tnsl
+++ b/libtnsl/algo/math/math.tnsl
diff --git a/libtnsl/src/asm/asm.tnsl b/libtnsl/asm/asm.tnsl
index d0da9a6..d0da9a6 100644
--- a/libtnsl/src/asm/asm.tnsl
+++ b/libtnsl/asm/asm.tnsl
diff --git a/libtnsl/src/box/box.tnsl b/libtnsl/box/box.tnsl
index 2f270b6..2f270b6 100644
--- a/libtnsl/src/box/box.tnsl
+++ b/libtnsl/box/box.tnsl
diff --git a/libtnsl/src/box/iterator.tnsl b/libtnsl/box/iterator.tnsl
index 13b9ef9..13b9ef9 100644
--- a/libtnsl/src/box/iterator.tnsl
+++ b/libtnsl/box/iterator.tnsl
diff --git a/libtnsl/src/box/map.tnsl b/libtnsl/box/map.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/box/map.tnsl
+++ b/libtnsl/box/map.tnsl
diff --git a/libtnsl/src/box/string.tnsl b/libtnsl/box/string.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/box/string.tnsl
+++ b/libtnsl/box/string.tnsl
diff --git a/libtnsl/src/box/tree.tnsl b/libtnsl/box/tree.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/box/tree.tnsl
+++ b/libtnsl/box/tree.tnsl
diff --git a/libtnsl/src/box/vector.tnsl b/libtnsl/box/vector.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/box/vector.tnsl
+++ b/libtnsl/box/vector.tnsl
diff --git a/libtnsl/src/io/block.tnsl b/libtnsl/io/block.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/io/block.tnsl
+++ b/libtnsl/io/block.tnsl
diff --git a/libtnsl/src/io/file.tnsl b/libtnsl/io/file.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/io/file.tnsl
+++ b/libtnsl/io/file.tnsl
diff --git a/libtnsl/src/io/io.tnsl b/libtnsl/io/io.tnsl
index 68e2fc0..68e2fc0 100644
--- a/libtnsl/src/io/io.tnsl
+++ b/libtnsl/io/io.tnsl
diff --git a/libtnsl/src/io/std.tnsl b/libtnsl/io/std.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/io/std.tnsl
+++ b/libtnsl/io/std.tnsl
diff --git a/libtnsl/src/io/stream.tnsl b/libtnsl/io/stream.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/io/stream.tnsl
+++ b/libtnsl/io/stream.tnsl
diff --git a/libtnsl/src/libtnsl.tnsl b/libtnsl/libtnsl.tnsl
index 070bfd2..070bfd2 100644
--- a/libtnsl/src/libtnsl.tnsl
+++ b/libtnsl/libtnsl.tnsl
diff --git a/libtnsl/src/reflect/dispatch.tnsl b/libtnsl/reflect/dispatch.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/reflect/dispatch.tnsl
+++ b/libtnsl/reflect/dispatch.tnsl
diff --git a/libtnsl/src/reflect/reflect.tnsl b/libtnsl/reflect/reflect.tnsl
index b3640c2..b3640c2 100644
--- a/libtnsl/src/reflect/reflect.tnsl
+++ b/libtnsl/reflect/reflect.tnsl
diff --git a/libtnsl/src/reflect/resolver.tnsl b/libtnsl/reflect/resolver.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/reflect/resolver.tnsl
+++ b/libtnsl/reflect/resolver.tnsl
diff --git a/libtnsl/src/reflect/type.tnsl b/libtnsl/reflect/type.tnsl
index 7a19b7d..7a19b7d 100644
--- a/libtnsl/src/reflect/type.tnsl
+++ b/libtnsl/reflect/type.tnsl
diff --git a/libtnsl/src/reflect/virtual.tnsl b/libtnsl/reflect/virtual.tnsl
index 8891905..8891905 100644
--- a/libtnsl/src/reflect/virtual.tnsl
+++ b/libtnsl/reflect/virtual.tnsl
diff --git a/libtnsl/src/time/alg.tnsl b/libtnsl/time/alg.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/time/alg.tnsl
+++ b/libtnsl/time/alg.tnsl
diff --git a/libtnsl/src/time/conv.tnsl b/libtnsl/time/conv.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/time/conv.tnsl
+++ b/libtnsl/time/conv.tnsl
diff --git a/libtnsl/src/time/parse.tnsl b/libtnsl/time/parse.tnsl
index d346464..d346464 100644
--- a/libtnsl/src/time/parse.tnsl
+++ b/libtnsl/time/parse.tnsl
diff --git a/libtnsl/src/time/time.tnsl b/libtnsl/time/time.tnsl
index dc24369..dc24369 100644
--- a/libtnsl/src/time/time.tnsl
+++ b/libtnsl/time/time.tnsl
diff --git a/spec/1.md b/spec/1.md
index 47e6834..493bace 100644
--- a/spec/1.md
+++ b/spec/1.md
@@ -4,9 +4,9 @@
### Folder Structure
-Normal TNSL project structure has a root source folder with TNSL files contained within the folder and sub-folders. It is normal for the root folder to represent a single library or binary, although there is no strict rule enforcing this. Standard organization is to place sub-modules in sub-folders. The file name for the module entry point should match the folder name.
+Normal TNSL project structure has a root source folder with TNSL files contained within the folder and sub-folders. It is normal for the root folder to represent a single library or binary, although there is no strict rule enforcing this. Standard organization is to place sub-modules in sub-folders. The file name for the module's entry point should match the folder name.
-The file representing the compile target is known as the root file, which generally resides in the root source folder. This file will contain a main method, and/or the pre-processor statement `rootfile` to denote the root of a library. If both are present, the compiler will generate an executable by default unless the `--otype` flag is set to `library` or `tlet`.
+The file representing the compile target is known as the root file, which generally resides in the root source folder. This file will contain a main method, and/or the pre-processor statement `rootfile` to denote the root of a library. If both are present, the compiler will generate an executable by default.
### TNSL Files
diff --git a/tnslc/src/ast/ast.tnsl b/tnslc/ast/ast.tnsl
index 405a94a..405a94a 100644
--- a/tnslc/src/ast/ast.tnsl
+++ b/tnslc/ast/ast.tnsl
diff --git a/tnslc/src/ast/node.tnsl b/tnslc/ast/node.tnsl
index 5eeac91..5eeac91 100644
--- a/tnslc/src/ast/node.tnsl
+++ b/tnslc/ast/node.tnsl
diff --git a/tnslc/src/compile/arch/arch.tnsl b/tnslc/compile/arch/arch.tnsl
index 5e81673..5e81673 100644
--- a/tnslc/src/compile/arch/arch.tnsl
+++ b/tnslc/compile/arch/arch.tnsl
diff --git a/tnslc/src/compile/arch/common.tnsl b/tnslc/compile/arch/common.tnsl
index cba0d9f..cba0d9f 100644
--- a/tnslc/src/compile/arch/common.tnsl
+++ b/tnslc/compile/arch/common.tnsl
diff --git a/tnslc/src/compile/arch/isa_arm.tnsl b/tnslc/compile/arch/isa_arm.tnsl
index 0dc3468..0dc3468 100644
--- a/tnslc/src/compile/arch/isa_arm.tnsl
+++ b/tnslc/compile/arch/isa_arm.tnsl
diff --git a/tnslc/src/compile/arch/isa_risc_v.tnsl b/tnslc/compile/arch/isa_risc_v.tnsl
index 0dc3468..0dc3468 100644
--- a/tnslc/src/compile/arch/isa_risc_v.tnsl
+++ b/tnslc/compile/arch/isa_risc_v.tnsl
diff --git a/tnslc/src/compile/arch/isa_x86.tnsl b/tnslc/compile/arch/isa_x86.tnsl
index 0dc3468..0dc3468 100644
--- a/tnslc/src/compile/arch/isa_x86.tnsl
+++ b/tnslc/compile/arch/isa_x86.tnsl
diff --git a/tnslc/src/compile/compile.tnsl b/tnslc/compile/compile.tnsl
index 263dc59..263dc59 100644
--- a/tnslc/src/compile/compile.tnsl
+++ b/tnslc/compile/compile.tnsl
diff --git a/tnslc/src/compile/format/elf.tnsl b/tnslc/compile/format/elf.tnsl
index 8490180..8490180 100644
--- a/tnslc/src/compile/format/elf.tnsl
+++ b/tnslc/compile/format/elf.tnsl
diff --git a/tnslc/src/compile/format/format.tnsl b/tnslc/compile/format/format.tnsl
index 2d4ed4b..2d4ed4b 100644
--- a/tnslc/src/compile/format/format.tnsl
+++ b/tnslc/compile/format/format.tnsl
diff --git a/tnslc/src/compile/format/iex.tnsl b/tnslc/compile/format/iex.tnsl
index e69de29..e69de29 100644
--- a/tnslc/src/compile/format/iex.tnsl
+++ b/tnslc/compile/format/iex.tnsl
diff --git a/tnslc/src/compile/format/out.tnsl b/tnslc/compile/format/out.tnsl
index e69de29..e69de29 100644
--- a/tnslc/src/compile/format/out.tnsl
+++ b/tnslc/compile/format/out.tnsl
diff --git a/tnslc/src/compile/format/pe.tnsl b/tnslc/compile/format/pe.tnsl
index e69de29..e69de29 100644
--- a/tnslc/src/compile/format/pe.tnsl
+++ b/tnslc/compile/format/pe.tnsl
diff --git a/tnslc/src/flags/flags.tnsl b/tnslc/flags/flags.tnsl
index bc5d43f..bc5d43f 100644
--- a/tnslc/src/flags/flags.tnsl
+++ b/tnslc/flags/flags.tnsl
diff --git a/tnslc/src/parse/parse.tnsl b/tnslc/parse/parse.tnsl
index e10ab4c..ec65f7b 100644
--- a/tnslc/src/parse/parse.tnsl
+++ b/tnslc/parse/parse.tnsl
@@ -14,9 +14,7 @@
EXPRESS OR IMPLIED
#/
-/; export module parse
- /:import
- "token.tnsl"
- "tokenizer.tnsl"
- :/
+/; module parse
+ :include "tnslc/parse/token.tnsl"
+ :include "tnslc/parse/tokenizer.tnsl"
;/ \ No newline at end of file
diff --git a/tnslc/src/parse/token.tnsl b/tnslc/parse/token.tnsl
index 21abe7b..0134483 100644
--- a/tnslc/src/parse/token.tnsl
+++ b/tnslc/parse/token.tnsl
@@ -15,7 +15,7 @@
#/
/# The various types of tokens #/
-; enum TOKEN_TYPE [uint] {
+; enum TOKEN_TYPE [int] {
LINESEP = 0,
INLNSEP = 1,
DELIMIT = 2,
@@ -28,8 +28,8 @@
}
/# Token struct definition #/
-;raw struct Token {
- uint
+; struct Token {
+ int
token_type,
line,
col,
@@ -45,10 +45,11 @@
;/
/; add_char (~{}charp part)
- ;uint l = len self.data`
- ;realloc self.data, l + len part
- /;loop (uint i = 0) [i++; i < len part]
- ;self.data`{l + i} = part{i}
+ # ;uint l = len self.data`
+ # ;realloc self.data, l + len part
+ /;loop (int i = 0; i < len part`) [i++]
+ # ;self.data`{l + i} = part{i}
+ ;self.data`.append(part`{i})
;/
;/
;/
@@ -58,7 +59,7 @@
helper funcs for checking their token types.
#/
-;const {}{}charp PREWORDS = {
+;{}{}charp PREWORDS = {
"include",
"define",
"extern",
@@ -95,7 +96,7 @@
"type"
}
-;const {}{}charp KEYWORDS = {
+;{}{}charp KEYWORDS = {
"struct",
"interface",
"enum",
@@ -133,20 +134,22 @@
"delete",
"module",
- "export",
+ "export"
}
-;const {}{}charp LITERALS = {
+;{}{}charp LITERALS = {
"true",
"false"
}
-;const {}charp DELIMITS = "()[]{}"
-;const {}charp LINESEPS = ";:#"
-;const {}charp INLNSEPS = ","
-;const {}charp AUGMENTS = "~`.&|^><!+-*/%"
+;{}charp RESERVED = "`~!#%^&*()-=+[]{}|;:,.<>/"
-;const {}{}charp MDELIMITS = {
+;{}charp DELIMITS = "()[]{}"
+;{}charp LINESEPS = ";:#"
+;{}charp INLNSEPS = ","
+;{}charp AUGMENTS = "~`.&|^><!+-*/%"
+
+;{}{}charp MDELIMITS = {
# Code block
"/;",
";/",
@@ -168,7 +171,7 @@
"#:"
}
-;const {}{}charp MAUGMENTS = {
+;{}{}charp MAUGMENTS = {
# Boolean
"==",
"&&",
@@ -207,16 +210,15 @@
"--"
}
-; const uint MAX_MRESERVED = 3
+;int MAX_MRESERVED = 3
/##
Checks if the character point p is in the string cmp
-#; is_in_string (const {}charp` cmp, charp p) [bool]
-
- /; loop (int i = 0; i < len cmp) [i++]
+#; is_in_string (~{}charp cmp, charp p) [bool]
- /; if (s == cmp{i})
+ /; loop (int i = 0; i < len cmp`) [i++]
+ /; if (s == cmp`{i})
;return true
;/
;/
@@ -224,27 +226,25 @@
;return false
;/
-
/##
Checks if the string s is in the list cmp
-#; is_in_string_list (const {}{}charp` cmp, {}charp` s) [bool]
+#; is_in_string_list (~{}{}charp cmp, ~{}charp s) [bool]
- /; loop (int i = 0; i < len cmp) [i++]
+ /; loop (int i = 0; i < len cmp`) [i++]
- /; if (len s == len cmp{i})
+ /; if (len s == len cmp`{i})
- /; loop (int j = 0; j < len s) [j++]
+ /; loop (int j = 0; j < len s`) [j++]
- /; if (s{j} !== cmp{i}{j})
- ;goto cont_outer
+ /; if (s`{j} !== cmp`{i}{j})
+ ;break 1
;/
;/
;return true
;/
- ;label cont_outer
;/
;return false
@@ -253,35 +253,35 @@
/#
Get the token_type value for a given string of character points
-#; get_token_type ({}charp` s) [int]
+#; get_token_type (~{}charp s) [int]
/; if (len s > 1)
- /; if (is_in_string_list(~PREWORDS, ~s))
+ /; if (is_in_string_list(~PREWORDS, s))
;return TOKEN_TYPE.PREWORD
- ;; else if (is_in_string_list(~KEYTYPES, ~s))
+ ;; else if (is_in_string_list(~KEYTYPES, s))
;return TOKEN_TYPE.KEYTYPE
- ;; else if (is_in_string_list(~KEYWORDS, ~s))
+ ;; else if (is_in_string_list(~KEYWORDS, s))
;return TOKEN_TYPE.KEYWORD
- ;; else if (is_in_string_list(~LITERALS, ~s))
+ ;; else if (is_in_string_list(~LITERALS, s))
;return TOKEN_TYPE.LITERAL
- ;; else if (is_in_string_list(~MDELIMITS, ~s))
+ ;; else if (is_in_string_list(~MDELIMITS, s))
;return TOKEN_TYPE.DELIMIT
- ;; else if (is_in_string_list(~MAUGMENTS, ~s))
+ ;; else if (is_in_string_list(~MAUGMENTS, s))
;return TOKEN_TYPE.AUGMENT
;/
;return TOKEN_TYPE.DEFWORD
- ;;else if (len s == 1)
+ ;;else if (len s` == 1)
- /; if (is_in_string(~DELIMITS, s{0}))
+ /; if (is_in_string(~DELIMITS, s`{0}))
;return TOKEN_TYPE.DELIMIT
- ;; else if (is_in_string(~LINESEPS, s{0}))
+ ;; else if (is_in_string(~LINESEPS, s`{0}))
;return TOKEN_TYPE.LINESEP
- ;; else if (is_in_string(~INLNSEPS, s{0}))
+ ;; else if (is_in_string(~INLNSEPS, s`{0}))
;return TOKEN_TYPE.INLNSEP
- ;; else if (is_in_string(~AUGMENTS, s{0}))
+ ;; else if (is_in_string(~AUGMENTS, s`{0}))
;return TOKEN_TYPE.AUGMENT
;/
diff --git a/tnslc/parse/tokenizer.tnsl b/tnslc/parse/tokenizer.tnsl
new file mode 100644
index 0000000..54671fe
--- /dev/null
+++ b/tnslc/parse/tokenizer.tnsl
@@ -0,0 +1,53 @@
+/#
+ Copyright 2021 Kyle Gunger
+
+ This file is licensed under the CDDL 1.0 (the License)
+ and may only be used in accordance with the License.
+ You should have received a copy of the License with this
+ software/source code. If you did not, a copy can be found
+ at the following URL:
+
+ https://opensource.org/licenses/CDDL-1.0
+
+ THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
+ WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
+ EXPRESS OR IMPLIED
+#/
+
+/; is_space (charp c) [bool]
+ ;return c == '\t' || c == '\n' || c == ' '
+;/
+
+/; break_token ({}charp dat, charp c) [bool]
+ /; if (len dat == 0)
+ ;return false
+
+ ;/
+ ;return is_space(c)
+;/
+
+/; parse_reserved ({}charp dat) [{}Token]
+
+;/
+
+/; tokenize (tnsl.io.File fstr) [~{}Token]
+ ;{}Token out = {}
+ ;{}charp tdat = {}
+
+ /; loop (int i = fstr.read(); i !== -1) [i = fstr.read()]
+ /; if (break_token(tdat, i))
+ /; if (len tdat > 0)
+ ;{}charp tmp = tdat
+ ;Token ttk = {0, 0, 0, ~tmp}
+ ;out.append(ttk)
+ ;tdat = {}
+ ;/
+ ;; else if ( !is_space(i) )
+ ;tdat.append(i)
+ ;/
+ ;/
+
+ ;tnsl.io.println(tdat)
+
+ ;return ~out
+;/
diff --git a/tnslc/src/parse/tokenizer.tnsl b/tnslc/src/parse/tokenizer.tnsl
deleted file mode 100644
index 4e5eeb7..0000000
--- a/tnslc/src/parse/tokenizer.tnsl
+++ /dev/null
@@ -1,38 +0,0 @@
-/#
- Copyright 2021 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-:using 'tnsl'
-
-/##
- parse.numeric_literal tokenizes the next numeric literal value in a file.
- Returns a token with the proper data as well as the number of characters read
-
-#; numeric_literal (io.text_stream fstream) [Token, uint]
- ;Token out = {token_type: TOKEN_TYPE.LITERAL}
- ;uint counter = 0
-
- ;bool l, d, run = false, false, true
- ;~{}charp num
-
- ;num, run = fstream.read_number()
-
- /; loop (run) [num, run = fstream.read_number()]
- ;out.add_data(num)
- ;delete num
- ;/
-
- ;return out, counter
-;/ \ No newline at end of file
diff --git a/tnslc/src/tnslc.tnsl b/tnslc/tnslc.tnsl
index 212819e..99be327 100644
--- a/tnslc/src/tnslc.tnsl
+++ b/tnslc/tnslc.tnsl
@@ -15,24 +15,27 @@
#/
/; module tnslc
- :import "flags/flags.tnsl"
- :import "parse/parse.tnsl"
- :import "ast/ast.tnsl"
- :import "compile/compile.tnsl"
+ :include "tnslc/parse/parse.tnsl"
;/
-/; main (~{}{}char args) [int]
- ;tnslc.flags.Flags argList = tnslc.flags.parse(args)
+/; test
- ;{}tnslc.parse.Token tokenList = tnslc.parse.tokenize(argList)
+;/
+
+/; main ({}{}charp args) [int]
+ /; if (len args < 1)
+ ;tnsl.io.println("Usage: tnslc [File to compile] <path to libtnsl>")
+ ;return 1
+ ;/
- ;tnslc.ast.Node ast = ast.generate(tokenList)
+ ;tnsl.io.File src = tnsl.io.readFile(args{0})
- ;tnsl.io.File outFile = tnsl.io.open_file(argList.outPath)
- ;[]uint8 data = tnslc.compile.generate(argList, ast)
+ ;~{}tnslc.parse.Token psrc = tnslc.parse.tokenize(src)
- ;outFile.write(data)
+ ;tnsl.io.println(psrc`)
+
+ ;src.close()
- ;outFile.close()
+ ;return 0
;/