From 91e97acd9b4eeb5bdc6c7ec1d9181ba08a176c84 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Wed, 18 Nov 2020 15:48:08 -0500 Subject: Remove link to parent from nodes --- src/tparse/resolver.go | 3 ++- src/tparse/token.go | 6 ++---- src/tparse/tree.go | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') 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 -- cgit v1.2.3