summaryrefslogtreecommitdiff
path: root/tnslc/ast
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-12-15 02:34:04 -0500
committerKyle Gunger <kgunger12@gmail.com>2022-12-15 02:34:04 -0500
commitaa5db10e7b653d9f6c3bda0c55b770f1f66a922f (patch)
tree946334b86d2e06cbf97966fb99b0a0c096851bb2 /tnslc/ast
parentecf3e4075141163459200a2b2d05bd8b866c371d (diff)
Change label format
+ Support modules + Track member types better ~ Remove unused files
Diffstat (limited to 'tnslc/ast')
-rw-r--r--tnslc/ast/ast.tnsl48
-rw-r--r--tnslc/ast/block.tnsl15
-rw-r--r--tnslc/ast/list.tnsl75
-rw-r--r--tnslc/ast/statement.tnsl95
-rw-r--r--tnslc/ast/tree.tnsl51
-rw-r--r--tnslc/ast/value.tnsl55
6 files changed, 0 insertions, 339 deletions
diff --git a/tnslc/ast/ast.tnsl b/tnslc/ast/ast.tnsl
deleted file mode 100644
index 71470f6..0000000
--- a/tnslc/ast/ast.tnsl
+++ /dev/null
@@ -1,48 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; export module ast
- :include "ast/block.tnsl"
- :include "ast/list.tnsl"
- :include "ast/statement.tnsl"
- :include "ast/tree.tnsl"
- :include "ast/value.tnsl"
-;/
-
-;{}charp CNULL = ""
-
-# AST node (non-block)
-;struct Node {
- tnslc.Token
- # associated token to the node
- tok,
-
- ~{}Node
- # sub-nodes
- sub
-}
-
-;enum NODE_TYPE [int] {
- FILE = 9,
- TYPE = 10,
- VALUE = 11,
- DEFN = 12,
-
- #...
-
- PREP = 1000
-}
-
diff --git a/tnslc/ast/block.tnsl b/tnslc/ast/block.tnsl
deleted file mode 100644
index 8fa0f27..0000000
--- a/tnslc/ast/block.tnsl
+++ /dev/null
@@ -1,15 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/ \ No newline at end of file
diff --git a/tnslc/ast/list.tnsl b/tnslc/ast/list.tnsl
deleted file mode 100644
index b65b336..0000000
--- a/tnslc/ast/list.tnsl
+++ /dev/null
@@ -1,75 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; 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)
- ;out.append(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)
- ;out.append(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/statement.tnsl b/tnslc/ast/statement.tnsl
deleted file mode 100644
index 15f6e26..0000000
--- a/tnslc/ast/statement.tnsl
+++ /dev/null
@@ -1,95 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; is_keyword_statement ({}charp word) [bool]
- ;return string_equate(word, "struct") || string_equate(word, "interface") || string_equate(word, "enum") ||
- string_equate(word, "continue") || string_equate(word, "break") || string_equate(word, "label") ||
- string_equate(word, "goto") || string_equate(word, "virtual") || string_equate(word, "asm") ||
- string_equate(word, "delete")
-;/
-
-/; 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]
- ;i`++
- /; if (i` !< len tokens`)
- ;return make_null_node()
-
- ;; else if (is_keyword_statement(tokens`{i`}.data`))
- ;return tree_keyword_statement(tokens, i)
-
- ;; else if (is_definition(tokens, i))
- ;return tree_definition(tokens, i)
-
- ;/
-
- ;return tree_value(tokens, i)
-;/
-
-/; tree_preproc [Node]
-
-;/ \ No newline at end of file
diff --git a/tnslc/ast/tree.tnsl b/tnslc/ast/tree.tnsl
deleted file mode 100644
index 0e8f9dc..0000000
--- a/tnslc/ast/tree.tnsl
+++ /dev/null
@@ -1,51 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; make_null_node [Node]
- ;Token null_tok = {0, 0, 0, ~CNULL}
- ;{}Node sub = {}
- ;return {null_tok, ~sub}
-;/
-
-/#
- # This should be the main entry point into the AST module
- #
-#; make_tree (~{}Token tokens, {}charp name) [Node]
- ;Token root = {0, 0, NODE_TYPE.FILE, ~name}
- ;{}Node sub = {}
-
- /; loop (int i = 0; i < len tokens`) [i++]
- ;{}charp to_check = tokens`{i}.data`
-
- /; if (string_equate(to_check, ";"))
- ;sub.append(tree_statement(tokens, ~i))
-
- ;; else if (string_equate(to_check, ":"))
- ;sub.append(tree_preproc(tokens, ~i))
-
- ;; else if (string_equate(to_check, "/;"))
- ;sub.append(tree_block(tokens, ~i))
-
- ;; else if (string_equate(to_check, "/:"))
- ;sub.append(tree_preblock(tokens, ~i))
-
- ;; else
- ;break
- ;/
- ;/
-
- ;return {root, ~sub}
-;/
diff --git a/tnslc/ast/value.tnsl b/tnslc/ast/value.tnsl
deleted file mode 100644
index 59655c7..0000000
--- a/tnslc/ast/value.tnsl
+++ /dev/null
@@ -1,55 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; tree_type (~{}Token tok, ~int cur) [Node]
- ;Token type_tok = {NODE_TYPE.TYPE, 0, 0, ~CNULL}
- ;{}Node type_sub = {}
-
- # Pre type keyword checks
- /; loop (tok`{cur`}.token_type !== TOKEN_TYPE.DEFWORD && tok`{cur`}.token_type !== TOKEN_TYPE.KEYTYPE)
- /; if (tok`{cur`}.token_type == TOKEN_TYPE.KEYWORD)
-
- ;/
- ;/
-
- /;
-
- ;/
-
- ;return {type_tok, ~type_sub}
-;/
-
-/; tree_value [Node]
- ;Token def_tok = {NODE_TYPE.VALUE, 0, 0, ~CNULL}
- ;{}Node def_sub = {}
-
- ;return {def_tok, ~def_sub}
-;/
-
-/; tree_definition [Node]
- ;Token def_tok = {NODE_TYPE.DEFN, 0, 0, ~CNULL}
- ;{}Node def_sub = {}
-
- ;def_sub.append(tree_type())
-
- ;{}Node vals = tree_list_value()
-
- /; loop (int i = 0; i < len vals) [i++]
- ;def_sub.append(vals{i})
- ;/
-
- ;return {def_tok, ~def_sub}
-;/ \ No newline at end of file