Rename TomlTree to Tree (#159)

Avoid stutter.

Fixes #55
This commit is contained in:
Thomas Pelletier
2017-05-10 17:53:23 -07:00
committed by GitHub
parent 23f644976a
commit 685a1f1cb7
20 changed files with 170 additions and 170 deletions
+19 -19
View File
@@ -14,7 +14,7 @@ import (
type tomlParser struct {
flow chan token
tree *TomlTree
tree *Tree
tokensBuffer []token
currentTable []string
seenTableKeys []string
@@ -106,18 +106,18 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
}
p.tree.createSubTree(keys[:len(keys)-1], startToken.Position) // create parent entries
destTree := p.tree.GetPath(keys)
var array []*TomlTree
var array []*Tree
if destTree == nil {
array = make([]*TomlTree, 0)
} else if target, ok := destTree.([]*TomlTree); ok && target != nil {
array = destTree.([]*TomlTree)
array = make([]*Tree, 0)
} else if target, ok := destTree.([]*Tree); ok && target != nil {
array = destTree.([]*Tree)
} else {
p.raiseError(key, "key %s is already assigned and not of type table array", key)
}
p.currentTable = keys
// add a new tree to the end of the table array
newTree := newTomlTree()
newTree := newTree()
newTree.position = startToken.Position
array = append(array, newTree)
p.tree.SetPath(p.currentTable, array)
@@ -183,11 +183,11 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
}
// find the table to assign, looking out for arrays of tables
var targetNode *TomlTree
var targetNode *Tree
switch node := p.tree.GetPath(tableKey).(type) {
case []*TomlTree:
case []*Tree:
targetNode = node[len(node)-1]
case *TomlTree:
case *Tree:
targetNode = node
default:
p.raiseError(key, "Unknown table type for path: %s",
@@ -212,7 +212,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
var toInsert interface{}
switch value.(type) {
case *TomlTree, []*TomlTree:
case *Tree, []*Tree:
toInsert = value
default:
toInsert = &tomlValue{value, key.Position}
@@ -289,8 +289,8 @@ func tokenIsComma(t *token) bool {
return t != nil && t.typ == tokenComma
}
func (p *tomlParser) parseInlineTable() *TomlTree {
tree := newTomlTree()
func (p *tomlParser) parseInlineTable() *Tree {
tree := newTree()
var previous *token
Loop:
for {
@@ -360,22 +360,22 @@ func (p *tomlParser) parseArray() interface{} {
p.getToken()
}
}
// An array of TomlTrees is actually an array of inline
// An array of Trees is actually an array of inline
// tables, which is a shorthand for a table array. If the
// array was not converted from []interface{} to []*TomlTree,
// array was not converted from []interface{} to []*Tree,
// the two notations would not be equivalent.
if arrayType == reflect.TypeOf(newTomlTree()) {
tomlArray := make([]*TomlTree, len(array))
if arrayType == reflect.TypeOf(newTree()) {
tomlArray := make([]*Tree, len(array))
for i, v := range array {
tomlArray[i] = v.(*TomlTree)
tomlArray[i] = v.(*Tree)
}
return tomlArray
}
return array
}
func parseToml(flow chan token) *TomlTree {
result := newTomlTree()
func parseToml(flow chan token) *Tree {
result := newTree()
result.position = Position{1, 1}
parser := &tomlParser{
flow: flow,