summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tnslc/ast/ast.tnsl3
-rw-r--r--tnslc/ast/list.tnsl2
-rw-r--r--tnslc/ast/statement.tnsl49
-rw-r--r--tnslc/ast/value.tnsl3
-rw-r--r--tnslc/parse/parse.tnsl12
-rw-r--r--tnslc/tnslc.tnsl4
6 files changed, 66 insertions, 7 deletions
diff --git a/tnslc/ast/ast.tnsl b/tnslc/ast/ast.tnsl
index bece84e..6e75da6 100644
--- a/tnslc/ast/ast.tnsl
+++ b/tnslc/ast/ast.tnsl
@@ -44,4 +44,5 @@
#...
PREP = 1000
-} \ No newline at end of file
+}
+
diff --git a/tnslc/ast/list.tnsl b/tnslc/ast/list.tnsl
index ee5d0cf..a5849a3 100644
--- a/tnslc/ast/list.tnsl
+++ b/tnslc/ast/list.tnsl
@@ -17,5 +17,7 @@
/; tree_list_value [{}Node]
;{}Node out = {}
+
+
;return out
;/
diff --git a/tnslc/ast/statement.tnsl b/tnslc/ast/statement.tnsl
index d8b4877..6023de2 100644
--- a/tnslc/ast/statement.tnsl
+++ b/tnslc/ast/statement.tnsl
@@ -21,10 +21,57 @@
string_equate(word, "delete")
;/
-/; is_definition (~{}Token tokens, ~int i) [bool] ;/
+/; is_closing (Token t) [bool]
+ /; if (t.token_type == TOKEN_TYPE.DELIMIT)
+ ;return string_equate(t.data`, ")") || string_equate(t.data`, "]") || string_equate(t.data`, "}")
+ ;/
+ ;return false
+;/
+
+/; get_closing (~{}Token tokens, int i) [int]
+ ;{}charp end = ")"
+ /; if (string_equate(tokens`{i}.data`, "["))
+ ;end = "]"
+ ;; else if (string_equate(tokens`{i}.data`, "{"))
+ ;end = "}"
+ ;/
+
+ ;int delims = 0
+
+ /; loop (i++; i < len tokens`) [i++]
+ /; if (is_closing(tokens`{i}))
+ /; if (delims > 0)
+ ;delims--
+ ;; else if (string_equate(end, tokens`{i}.data`))
+ ;return i
+ ;; else
+ ;return -1
+ ;/
+ ;; else if (tokens`{i}.token_type == TOKEN_TYPE.DELIMIT)
+ ;delims++
+ ;/
+ ;/
+
+ ;return -1
+;/
+
+
+/; is_definition (~{}Token tokens, ~int i) [bool]
+
+ /; loop (int j = i`; j < len tokens`) [j++]
+ /; if (tokens`{j}.token_type == TOKEN_TYPE.KEYTYPE)
+
+ ;; else if ()
+ ;/
+ ;/
+ ;return false
+;/
/; tree_keyword_statement (~{}Token tokens, ~int i) [Node]
+ ;Token def_tok = {TOKEN_TYPE.KEYWORD, 0, 0, ~CNULL}
+ ;{}Node def_sub = {}
+ ;return {def_tok, ~def_sub}
;/
/; tree_statement (~{}Token tokens, ~int i) [Node]
diff --git a/tnslc/ast/value.tnsl b/tnslc/ast/value.tnsl
index 2cefb62..d90c00a 100644
--- a/tnslc/ast/value.tnsl
+++ b/tnslc/ast/value.tnsl
@@ -21,7 +21,10 @@
;/
/; tree_value [Node]
+ ;Token def_tok = {NODE_TYPE.VALUE, 0, 0, ~CNULL}
+ ;{}Node def_sub = {}
+ ;return {def_tok, ~def_sub}
;/
/; tree_definition [Node]
diff --git a/tnslc/parse/parse.tnsl b/tnslc/parse/parse.tnsl
index 9927d56..dbd9354 100644
--- a/tnslc/parse/parse.tnsl
+++ b/tnslc/parse/parse.tnsl
@@ -19,6 +19,14 @@
:include "parse/tokenizer.tnsl"
;/
+/; create_panic ({}charp err)
+ ;tnsl.io.println("ABOUT TO INDUCE PANIC... STAND BY")
+ ;tnsl.io.print("Error code given: ")
+ ;tnsl.io.println(err)
+ ;{}int i = {0}
+ ;i{2}
+;/
+
/# The various types of tokens #/
; enum TOKEN_TYPE [int] {
LINESEP = 0,
@@ -64,7 +72,7 @@
/; add_char (~{}charp part)
# ;uint l = len self.data`
# ;realloc self.data, l + len part
- /;loop (int i = 0; i < len part`) [i++]
+ /; loop (int i = 0; i < len part`) [i++]
# ;self.data`{l + i} = part{i}
;self.data`.append(part`{i})
;/
@@ -72,7 +80,7 @@
;/
/; print_tokens(~{}Token dat)
- /;loop (int i = 0; i < len dat`) [i++]
+ /; loop (int i = 0; i < len dat`) [i++]
;dat`{i}.print()
;/
;tnsl.io.print("\n")
diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl
index 194464e..21dbb45 100644
--- a/tnslc/tnslc.tnsl
+++ b/tnslc/tnslc.tnsl
@@ -28,7 +28,7 @@
/; main ({}{}charp args) [int]
/; if (len args < 1)
- # ;tnsl.io.println("Usage: tnslc [File to compile] <path to libtnsl>")
+ ;tnsl.io.println("Usage: tnslc [File to compile] <path to libtnsl>")
;return 1
;/
@@ -42,7 +42,5 @@
;tnslc.Node tree_node = tnslc.ast.make_tree(psrc, args{0})
-
-
;return 0
;/