From fc5a382661262b4dac085d75739c4ac0601574a7 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Wed, 29 Jun 2022 20:15:46 -0400 Subject: [TNSLC] General updates --- tnslc/ast/list.tnsl | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tnslc/ast/tree.tnsl | 3 +-- 2 files changed, 53 insertions(+), 2 deletions(-) (limited to 'tnslc/ast') 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} ;/ -- cgit v1.2.3