summaryrefslogtreecommitdiff
path: root/src/tparse
diff options
context:
space:
mode:
authorKyle Gunger <corechg@gmail.com>2020-11-18 15:48:08 -0500
committerKyle Gunger <corechg@gmail.com>2020-11-18 15:48:08 -0500
commit91e97acd9b4eeb5bdc6c7ec1d9181ba08a176c84 (patch)
tree981d7c2351d06cbfbcbe646cbeee3ed4ae110016 /src/tparse
parent93cdd2cb58d0d2c1058ffe3568391be556245136 (diff)
Remove link to parent from nodes
Diffstat (limited to 'src/tparse')
-rw-r--r--src/tparse/resolver.go3
-rw-r--r--src/tparse/token.go6
-rw-r--r--src/tparse/tree.go3
3 files changed, 5 insertions, 7 deletions
diff --git a/src/tparse/resolver.go b/src/tparse/resolver.go
index 8408a1c..5267887 100644
--- a/src/tparse/resolver.go
+++ b/src/tparse/resolver.go
@@ -19,5 +19,6 @@ package tparse
//TODO: Everything
/*
- This file is suppost to contain code to include other files when asked, and represents the most important part of the pre-processor
+ This file is support code to include other files when asked, and represents the most important part of the pre-processor
+ Maybe we will do this when writing the native compiler though
*/
diff --git a/src/tparse/token.go b/src/tparse/token.go
index 51a2123..182b2e0 100644
--- a/src/tparse/token.go
+++ b/src/tparse/token.go
@@ -26,12 +26,10 @@ type Token struct {
// Node represents a node in an AST
type Node struct {
- Parent *Node
- Data Token
- Sub []Node
+ Data Token
+ Sub []Node
}
func makeParent(parent *Node, child Node) {
- child.Parent = parent
parent.Sub = append(parent.Sub, child)
}
diff --git a/src/tparse/tree.go b/src/tparse/tree.go
index 02c8171..ed19e6d 100644
--- a/src/tparse/tree.go
+++ b/src/tparse/tree.go
@@ -194,7 +194,7 @@ func parseType(tokens *[]Token, tok, max int, param bool) (Node, int) {
errOut("Error: unexpected token when parsing type", t)
}
- working.Sub = append(working.Sub, Node{Parent: working})
+ makeParent(working, Node{})
working = &(working.Sub[0])
}
@@ -220,7 +220,6 @@ func parseValue(tokens *[]Token, tok, max int) (Node, int) {
func MakeTree(tokens *[]Token, file string) Node {
out := Node{}
out.Data = Token{9, file, 0, 0}
- out.Parent = &out
tmp := Node{}
working := &tmp