Ah-ha, I always forget that repeat defaults to 0.

On Tue, Oct 2, 2012 at 3:32 PM, Kaspar Schiess <[email protected]> wrote:
>> My first thoughts are to do thusly:
>>
>> ``` diff
>> - rule(:expressions) { expression.repeat.maybe.as(:expressions) >> eol? }
>> - root(:expressions)
>> + rule(:expressions) { expression.repeat.maybe.as(:expressions) >> eol? }
>> + rule(:line) { expressions.repeat.as :line }
>> + root(:line)
>> ```
>>
>> However this results in an infinite loop. I'm not sure I can figure
>> out what's going wrong here.
>>
>> Anyone with any ideas?
>>
>
> Shooting from my hip: something.repeat.repeat will loop forever, since
> the inner repeat accepts no chars matched (0 repetitions) and the outer
> loop will keep repeating that (since it works so nicely).
>
> You should assert that you really consume input, then the parser will work.
>
> kaspar
>
>



-- 
Kurtis Rainbolt-Greene, Hacker
Difference Engineers, LLC
1631 8th Street
New Orleans, LA 70115

Reply via email to