The syntax tree is no longer passed by reference
This commit is contained in:
parent
7af575e865
commit
89834ac390
@ -14,15 +14,15 @@ type ParsingOperation struct {
|
|||||||
tokens []lexer.Token
|
tokens []lexer.Token
|
||||||
tokenIndex int
|
tokenIndex int
|
||||||
|
|
||||||
tree *SyntaxTree
|
tree SyntaxTree
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse reads the files located in the module specified by modulePath, and
|
// Parse reads the files located in the module specified by modulePath, and
|
||||||
// converts them into an abstract syntax tree.
|
// 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 {
|
parser := ParsingOperation {
|
||||||
modulePath: modulePath,
|
modulePath: modulePath,
|
||||||
tree: &SyntaxTree {
|
tree: SyntaxTree {
|
||||||
sections: make(map[string] Section),
|
sections: make(map[string] Section),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,6 @@ import "testing"
|
|||||||
|
|
||||||
func checkTree (modulePath string, correct string, test *testing.T) {
|
func checkTree (modulePath string, correct string, test *testing.T) {
|
||||||
tree, err := Parse(modulePath)
|
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)
|
treeString := tree.ToString(0)
|
||||||
treeRunes := []rune(treeString)
|
treeRunes := []rune(treeString)
|
||||||
|
@ -44,7 +44,7 @@ type Identifier struct {
|
|||||||
trail []string
|
trail []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeKind represents what kind of type a type is
|
// TypeKind represents what kind of type a type is.
|
||||||
type TypeKind int
|
type TypeKind int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user