Tiny fix in variable naming, because the test had grown in a different direction.
This commit is contained in:
parent
e1534f678e
commit
1e7ec7553a
|
@ -13,9 +13,9 @@ import (
|
||||||
"git.makaay.nl/mauricem/go-parsekit"
|
"git.makaay.nl/mauricem/go-parsekit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type letterCollection []string
|
type chunks []string
|
||||||
|
|
||||||
func (l *letterCollection) AddChopped(s string, chunkSize int) *parsekit.Error {
|
func (l *chunks) AddChopped(s string, chunkSize int) *parsekit.Error {
|
||||||
parser := parsekit.NewParser(func(p *parsekit.ParseAPI) {
|
parser := parsekit.NewParser(func(p *parsekit.ParseAPI) {
|
||||||
for p.On(parsekit.C.MinMax(1, chunkSize, parsekit.A.AnyRune)).Accept() {
|
for p.On(parsekit.C.MinMax(1, chunkSize, parsekit.A.AnyRune)).Accept() {
|
||||||
*l = append(*l, p.BufLiteral())
|
*l = append(*l, p.BufLiteral())
|
||||||
|
@ -26,11 +26,11 @@ func (l *letterCollection) AddChopped(s string, chunkSize int) *parsekit.Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Example_usingSliceAsParserState() {
|
func Example_usingSliceAsParserState() {
|
||||||
letters := &letterCollection{}
|
chunks := &chunks{}
|
||||||
letters.AddChopped("This string will", 4)
|
chunks.AddChopped("This string will", 4)
|
||||||
letters.AddChopped("be cut to bits!!!!!!", 8)
|
chunks.AddChopped("be cut to bits!!!!!!", 8)
|
||||||
|
|
||||||
fmt.Printf("Matches = %q", *letters)
|
fmt.Printf("Matches = %q", *chunks)
|
||||||
// Output:
|
// Output:
|
||||||
// Matches = ["This" " str" "ing " "will" "be cut t" "o bits!!" "!!!!"]
|
// Matches = ["This" " str" "ing " "will" "be cut t" "o bits!!" "!!!!"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue