kschiess / parslet

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

repeat with repeat will loop endlessly #89

Closed muja closed 11 years ago

muja commented 11 years ago
line = (match('$').absent? >> any).repeat >> match('$')
line.parse("Hello world!") # => "Hello world!"@0
line.parse("Hello world!\n") # => "Hello world!\n"@0
line.repeat.parse("Hello\nThis\nis\na\nmultiline\nstring.") # never returns
kschiess commented 11 years ago

Yes. Both repeats will accept a zero width match. The first one doesn't consume anything, the second one repeats that success.