summaryrefslogtreecommitdiff
path: root/tnslc/ast/statement.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/ast/statement.tnsl')
-rw-r--r--tnslc/ast/statement.tnsl49
1 files changed, 48 insertions, 1 deletions
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]