diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-06-29 20:15:46 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-06-29 20:15:46 -0400 |
commit | fc5a382661262b4dac085d75739c4ac0601574a7 (patch) | |
tree | a705dcb7387e316a05c5162c0351488bd664e55a /tnslc/ast | |
parent | 2572cd049ee5e1e2685b1abe6bfcfbb8aa988a71 (diff) |
[TNSLC] General updates
Diffstat (limited to 'tnslc/ast')
-rw-r--r-- | tnslc/ast/list.tnsl | 52 | ||||
-rw-r--r-- | tnslc/ast/tree.tnsl | 3 |
2 files changed, 53 insertions, 2 deletions
diff --git a/tnslc/ast/list.tnsl b/tnslc/ast/list.tnsl index a5849a3..b9d8080 100644 --- a/tnslc/ast/list.tnsl +++ b/tnslc/ast/list.tnsl @@ -16,8 +16,60 @@ /; tree_list_value [{}Node] ;{}Node out = {} + ;return out +;/ + +/; tree_list_type [{}Node] + ;{}Node out = {} + ;return out +;/ + +/; tree_list_statement (~{}Token tok, ~int cur) [{}Node] + ;{}Node out = {} + + /; loop (cur` < len tok`) [cur` = cur` + 1] + ;Node stmt = tree_statement(tok, cur) + ;append(out, stmt) + ;Token tmp = tok`{cur`} + /; if (string_equate(tmp.data, "]") || string_equate(tmp.data, ")")) + ;cur` = cur` + 1 + ;break + ;; else if (string_equate(tmp.data, ";") == false) + ;create_panic("Unexpected token in list of statements") + ;/ + ;/ + ;return out +;/ + +/; tree_list_params (~{}Token tok, ~int cur) [{}Node] + ;{}Node out = {} + + /; if (string_equate(tok`{cur`}.data, ")")) + ;return out + ;/ + + /; if (type_then_name(tok, cur) == false) + ;create_panic("Parameter list must start with a type and name combo.") + ;/ + + /; loop (cur` < len tok`) [cur` = cur` + 1] + ;Node tmp + /; if (type_then_name(tok, cur)) + ;tmp = tree_type(tok, cur) + ;append(out, tmp) + ;/ + + ;tmp = tree_value(tok, cur) + + /; if (string_equate(tok`{cur`}.data, ")")) + ;cur` = cur` + 1 + ;break + ;; else if (string_equate(tok`{cur`}.data, ",") == false) + ;create_panic("A value in a list of params must be followed with a comma") + ;/ + ;/ ;return out ;/ diff --git a/tnslc/ast/tree.tnsl b/tnslc/ast/tree.tnsl index fe6baab..db901de 100644 --- a/tnslc/ast/tree.tnsl +++ b/tnslc/ast/tree.tnsl @@ -15,8 +15,7 @@ #/ /; make_null_node [Node] - ;{}charp null_str = "" - ;Token null_tok = {0, 0, 0, ~null_str} + ;Token null_tok = {0, 0, 0, ~CNULL} ;{}Node sub = {} ;return {null_tok, ~sub} ;/ |