kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
809 stars 95 forks source link

Any absent repeat fails with undefined method for nil class #169

Closed ghost closed 7 years ago

ghost commented 7 years ago
require 'parslet'
include Parslet

any.absent?.repeat(2,2).parse('')
# => NoMethodError: undefined method `+' for nil:NilClass

Is this intended?

The problem appears to be that any.absent?.parse('') returns nil, which can't be concatenated with the second repetition.

I suggest having any.absent?.parse('') return empty string.

kschiess commented 7 years ago

any.absent? ? Like EOS/EOF? What version of parslet are you using? I just tried this on master and cannot reproduce your NoMethodError.

ghost commented 7 years ago

Sorry, had some other things to do. It seems to be fixed now, so i am just going to close the issue. Thanks for looking into it, though.