diff options
author | Özgür Kesim <oec@codeblau.de> | 2019-06-18 13:41:06 +0200 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2019-06-18 13:41:06 +0200 |
commit | ef954d857ce5a6e9952f7d6487662b6b164a127c (patch) | |
tree | c2d766cb03902bd03466b12a8e69ad8cc3087581 /combinator.go | |
parent | 6b9cd80df517fd7d85a256a950f3de726d7e619e (diff) | |
parent | 9bc60a23116a1992e56d3a2754df6523bc565e99 (diff) |
Merge branch 'master' of github.com:/oec/goparsify
Diffstat (limited to 'combinator.go')
-rw-r--r-- | combinator.go | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/combinator.go b/combinator.go index 5b0d584..ae4d31c 100644 --- a/combinator.go +++ b/combinator.go @@ -35,7 +35,6 @@ func NoAutoWS(parser Parserish) Parser { // Any matches the first successful parser and returns its result func Any(parsers ...Parserish) Parser { parserfied := ParsifyAll(parsers...) - // Records which parser was successful for each byte, and will use it first next time. return NewParser("Any()", func(ps *State, node *Result) { ps.WS(ps) @@ -45,13 +44,7 @@ func Any(parsers ...Parserish) Parser { } startpos := ps.Pos - longestError := ps.Error - if ps.Cut <= startpos { - ps.Recover() - } else { - return - } - + var longestError Error for _, parser := range parserfied { parser(ps, node) if ps.Errored() { @@ -72,14 +65,14 @@ func Any(parsers ...Parserish) Parser { }) } -// Some matches one or more parsers and returns the value as .Child[n] +// Some matches zero or more parsers and returns the value as .Child[n] // an optional separator can be provided and that value will be consumed // but not returned. Only one separator can be provided. func Some(parser Parserish, separator ...Parserish) Parser { return NewParser("Some()", manyImpl(0, parser, separator...)) } -// Many matches zero or more parsers and returns the value as .Child[n] +// Many matches one or more parsers and returns the value as .Child[n] // an optional separator can be provided and that value will be consumed // but not returned. Only one separator can be provided. func Many(parser Parserish, separator ...Parserish) Parser { |