summaryrefslogtreecommitdiff
path: root/tnslc/ast
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-05-05 16:14:01 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-05-05 16:14:01 -0400
commit2572cd049ee5e1e2685b1abe6bfcfbb8aa988a71 (patch)
treeb191126f961c6befc6da2c65c28d5bef69077579 /tnslc/ast
parent5cf518362e6bc08eb44eb8d6ed74a0a23c2c3a5f (diff)
Add methods to crash in a defined way
Diffstat (limited to 'tnslc/ast')
-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
4 files changed, 55 insertions, 2 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]