diff options
author | Özgür Kesim <oec@codeblau.de> | 2021-05-07 21:52:26 +0200 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2021-05-07 21:52:26 +0200 |
commit | afd70fad39c8e7e4a7bab4322a9897b7217dc785 (patch) | |
tree | 8d7bebb79b211ed72982d15550b87d575e9eaef1 /combinator.go | |
parent | 75b7b13781a355c49889f54110ed07434dec2d95 (diff) | |
parent | e2c58411159b77a6135be3731c4a174f01d9d7a5 (diff) |
Diffstat (limited to 'combinator.go')
-rw-r--r-- | combinator.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/combinator.go b/combinator.go index b6b888b..ea75589 100644 --- a/combinator.go +++ b/combinator.go @@ -2,6 +2,7 @@ package goparsify import ( "bytes" + "strings" ) // Seq matches all of the given parsers in order and returns their result as .Child[n] @@ -51,11 +52,13 @@ func Any(parsers ...Parserish) Parser { startpos := ps.Pos var longestError Error + expected := []string{} for _, parser := range parserfied { parser(ps, node) if ps.Errored() { if ps.Error.pos >= longestError.pos { longestError = ps.Error + expected = append(expected, ps.Error.expected) } if ps.Cut > startpos { break @@ -68,7 +71,10 @@ func Any(parsers ...Parserish) Parser { return } - ps.Error = longestError + ps.Error = Error{ + pos: longestError.pos, + expected: strings.Join(expected, " or "), + } ps.Pos = startpos }) } |