2010/12/3 Justin Chase <justin.m.ch...@gmail.com>

> From there the precedence of all the operators is determined by the
> ordering but can have nested lower precedence rules. This same principle
> applies for binary arithmetic expressions and can also be used for things
> like expression chaining (e.g. x[0].y(z)() )
>
> But if you were to introduce indirect left recursion into this it would
> either cause this pattern to no longer work or be so complex I'm not sure
> you would be able to reason about unexpected results very well. I would be
> interested to hear evidence otherwise, or to hear about features that are
> enabled by iLR that you cannot solve without.
>
>
That's a pretty interesting question. I guess you could always turn LR or
iLR rules into sets of non-LR rules,
 and still match left-precedence right with some side-work, so I don't think
there is anywhere you really
NEED iLR or even LR. It's just a lot more convenient in some cases.

>From what I've found out concerning PEGs, I still have difficulties
believing what you stated,
that a combination of the ordering of choices and (i)LR can define a solid
precedence system.
Look for instance at this grammar :

EXP <- EXP '*' EXP |  EXP '+' EXP | NUM
NUM <- [0-9]+
Following the two PEGs axiom of greedy match AND ordered choice,
I haven't found a way to get '*' and '+' precedence to match the intuition
in every possible cases.
It may exist, but it's not implied by most PEG-support-for-LR algorithms I
saw.

For instance :
1+1*1+1 should parse (((1)+(1*1))+1),
and 1*1+1*1 should parse ((1*1)+(1*1))

Of course if you have an algorithm that does so, I absolutely need and want
to look at it :).

Cheers,
Alex

PS : Laurence Tratt did some work about associativity in LR-PEG, it's surely
worth taking a look at it. I don't think precedence is managed though (I'm
asking him right away).
http://tratt.net/laurie/research/publications/



On Fri, Dec 3, 2010 at 3:18 AM, Alex Repain <alex.rep...@gmail.com> wrote:
>
>>
>>
>> 2010/12/3 Gordon Tisher <gor...@balafon.net>
>>
>>> Hi Justin,
>>>
>>
>>
>>> LR is useful for handling operator precedence, for example.  I'm afraid
>>> that I have no evidence that indirect left-recursion does not result in
>>> increased complexity -- being able to handle the increased complexity
>>> was the attraction for me in implementing the algorithm.
>>>
>>>
>> Is there some study work about how LR is supposed to help setting operator
>> precedences ?
>>
>> I have worked around with left-recursion support for PEGs, and I still
>> have doubts that PEG+LR really offers 'native' support for operator
>> precedence...
>>
>> Cheers,
>> Alex
>>
>>
>>
>>> Cheers,
>>>
>>> Gordon
>>>
>>> --
>>> Gordon Tisher
>>> http://balafon.net
>>>
>>>
>>> _______________________________________________
>>> PEG mailing list
>>> PEG@lists.csail.mit.edu
>>> https://lists.csail.mit.edu/mailman/listinfo/peg
>>>
>>
>>
>
>
> --
> Justin Chase
> http://www.justinmchase.com
>
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to