diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parcom/parser.cr | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/parcom/parser.cr b/src/parcom/parser.cr index d8f44c8..d13219d 100644 --- a/src/parcom/parser.cr +++ b/src/parcom/parser.cr @@ -255,11 +255,10 @@ module Parcom # try to parse with both parsers and return both results. If either # sub-parser fails, the whole parser fails. def +(other : Parser(T, V)) : Parser(T, {U, V}) forall V - Parser(T, {U, V}).new("#{@name} + #{other.name}") do |tokens| - r1 = self.parse(tokens) - r2 = other.parse(r1.tokens) - Result.new(r2.tokens, {r1.value, r2.value}) - end + parser_chain "#{@name} + #{other.name}", T, {U, V}, + {x, self}, + {y, other}, + finally: Parser(T, {U, V}).pure({x, y}) end # Same as `#+`, but discards the second parser's result. |
