diff --git a/helpers_test.go b/helpers_test.go index 21527ae..823ab9c 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -25,7 +25,7 @@ func runStatesTs(t *testing.T, tests []statesT) { // ToArray returns Parser items as an array. // When an error occurs during scanning, a partial result will be // returned, accompanied by the error that occurred. -func parseItemsToArray(p *parsekit.P) ([]parsekit.Item, *parsekit.Error) { +func parseItemsToArray(p *parsekit.Run) ([]parsekit.Item, *parsekit.Error) { var items []parsekit.Item for { item, err, more := p.Next() @@ -54,7 +54,7 @@ func runStatesT(t *testing.T, c statesT) { t.Errorf("[%s] Unexpected number of parser items:\nexpected: %d\nactual: %d\n", c.name, len(expected), len(l)) } for i, e := range expected { - v := ParserItemToString(l[i]) + v := parserItemToString(l[i]) if v != e { t.Errorf("[%s] Unexpected parser item at index %d:\nexpected: %s\nactual: %s\n", c.name, i, e, v) } @@ -62,7 +62,7 @@ func runStatesT(t *testing.T, c statesT) { case string: a := make([]string, len(l)) for _, v := range l { - a = append(a, ParserItemToString(v)) + a = append(a, parserItemToString(v)) } actual := strings.Join(a, "") if actual != expected { @@ -71,8 +71,8 @@ func runStatesT(t *testing.T, c statesT) { } } -// ParserItemToString returns a string representation of the parsekit.Item. -func ParserItemToString(i parsekit.Item) string { +// parserItemToString returns a string representation of the parsekit.Item. +func parserItemToString(i parsekit.Item) string { switch i.Type { case parser.ItemComment: return fmt.Sprintf("#(%s)", i.Value) @@ -85,6 +85,6 @@ func ParserItemToString(i parsekit.Item) string { case parser.ItemAssignment: return "=" default: - panic(fmt.Sprintf("No string representation available for parsekit.Item id %d", i.Type)) + panic(fmt.Sprintf("parsekit bug: no string formatting exists for parsekit.Item id %d", i.Type)) } } diff --git a/toml.go b/toml.go index 8c37be6..564d0b8 100644 --- a/toml.go +++ b/toml.go @@ -19,6 +19,6 @@ var ( // NewParser creates a new parser, using the provided input string // as the data to parse. -func NewParser(input string) *parsekit.P { - return parsekit.New(input, startKeyValuePair) +func NewParser(input string) *parsekit.Run { + return parsekit.New(startKeyValuePair).Parse(input) }