diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parcom.cr | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/parcom.cr b/src/parcom.cr index 9e90562..dbdd44d 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -176,17 +176,15 @@ module Parcom end class Phrase(T, V) - def initialize(@p : Parser(T, V)) + @p : Map(T, {V, Nil}, V) + + def initialize(p : Parser(T, V)) + f = ->(tup : {V, Nil}) { tup[0] } + @p = (p + Eof(T).new).map(f) end def parse(tokens : TokenStream(T)) : Result(T, V) - r = @p.parse(tokens) - - unless r.tokens.empty? - raise ParserException.new("Phrase: some of the input was not parsed") - end - - r + @p.parse(tokens) end end |
