From 89834ac39097c01a059c85542f22812f7c600920 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 4 Sep 2022 22:30:14 -0400 Subject: [PATCH] The syntax tree is no longer passed by reference --- parser/parser.go | 6 +++--- parser/test-common.go | 9 --------- parser/tree.go | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index 3a07318..c360b19 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -14,15 +14,15 @@ type ParsingOperation struct { tokens []lexer.Token tokenIndex int - tree *SyntaxTree + tree SyntaxTree } // Parse reads the files located in the module specified by modulePath, and // converts them into an abstract syntax tree. -func Parse (modulePath string) (tree *SyntaxTree, err error) { +func Parse (modulePath string) (tree SyntaxTree, err error) { parser := ParsingOperation { modulePath: modulePath, - tree: &SyntaxTree { + tree: SyntaxTree { sections: make(map[string] Section), }, } diff --git a/parser/test-common.go b/parser/test-common.go index b983534..2784087 100644 --- a/parser/test-common.go +++ b/parser/test-common.go @@ -7,15 +7,6 @@ import "testing" func checkTree (modulePath string, correct string, test *testing.T) { tree, err := Parse(modulePath) - if tree == nil { - test.Log("TREE IS NIL!") - if err != io.EOF && err != nil { - test.Log("returned error:") - test.Log(err) - } - test.Fail() - return - } treeString := tree.ToString(0) treeRunes := []rune(treeString) diff --git a/parser/tree.go b/parser/tree.go index d563942..03a429f 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -44,7 +44,7 @@ type Identifier struct { trail []string } -// TypeKind represents what kind of type a type is +// TypeKind represents what kind of type a type is. type TypeKind int const (