def csv(value)
      (value >> (whitespaces? >> comma >> whitespaces? >> value).repeat).repeat
 end

 seems odd..

 csv(str("x")) matches "", "x" and "x ,x".. fine.. but also "xx" and
"x,xx,x" which seems odd.

 ---
"No man is an island... except Philip"


On Mon, Mar 25, 2013 at 10:38 AM, Nigel Thorne <[email protected]>wrote:

> I would change it to be
> ((interpolation_end.absent? >> phrase.repeat*(1)*).repeat(0).as(
> :interpolation))
>
> Inside the repeat(0) you have something that has to consume something.
> However.. the repeat(0) lets the inside be optional.
>
>
> ---
> "No man is an island... except Philip"
>
>
> On Mon, Mar 25, 2013 at 10:16 AM, Thomas Ingram 
> <[email protected]>wrote:
>
>> Thanks for the feedback. I'll reply inline....
>>
>>
>> On Sun, Mar 24, 2013 at 6:16 PM, Nigel Thorne <[email protected]>wrote:
>>
>>> Just looking at the grammar, the alarm bells for me are ...
>>>
>>> rule(:line_breaks) { line_break.repeat } # SMELL: repeat default 0, so
>>> this rules can consume nothing.... puts a '?' on the end of the name by
>>> convention. Or change to repeat(1).
>>>
>> Fixed this. I'm not sure how I missed it.
>>
>>
>>>
>>>
>>> rule(:comment) { pound < /span>>> (line_break.absent? >> any).repeat.as(
>>> :comment) >> line_break.maybe } # T he 'maybe' on line_break I assume
>>> is to allow the file to end at this point.... change this to be line_break
>>> | eof where eof is defined as rule(:eof) { any.absent? }
>>>
>> You assume correctly. I made this change.
>>
>>
>>>
>>> ((interpolation_end.absent? >> phr ase.repeat).repeat.as(:interpolation))
>>> ## This can loop for ever. absent? and repeat don't have to consume
>>> anything.
>>>
>> I adapted this rule from my string rule (see def string_parser at bottom
>> of file). What if I do this?
>>
>> rule(:interpolation) { interpolation_start >> interpolation_end.absent?
>> >> lines.as(:interpolation) >> interpolation_end }
>>
>> Also do I have an issue with string_parser? I seem to recall seeing the
>> pattern in string_parser somewhere on the parslet website, and I've adapted
>> it for comment, string, regular expression and interpolation.
>>
>>
>>> ---
>>> "No man is an island... except Philip"
>>>
>>
>> --
>> Thomas Ingram
>>
>
>

Reply via email to