Makes sense, I just read too much into "Associativity is always left when
left recursing".

I tend to disagree that it's not worthwhile and changing the grammar is the
right solution.

This being said, newer version of my tool eschew perform this by
"rewriting" (not really but I don't want to get into the specifics) a
right-associative parse tree into a left-associative one if required. So
left-associativity is still available, but does not need to be encoded in
the parser anymore.

Nicolas LAURENT

On 16 May 2017 at 04:31, Juancarlo Añez <apal...@gmail.com> wrote:

> Hello Nicolas,
>
> Here is a very crude example:
>>
>> E = E + E
>> E = Integer
>>
>> input: 1 + 2 + 3
>>
>
> Yes. TatSu will produce a right-associative tree for that example.
>
> The tool currently doesn't provide for defining left/right associative
> rules. I'm not sure how useful that feature would be, as the desired
> associativity can be obtained by transforming the grammar (removing the
> direct right-recursion).
>
> E = E + T
> E = T
> T = Integer
>
> Cheers,
>
> --
> Juancarlo *Añez*
>
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to