Hello!
I wonder if someone could help me with a certain assertion made in this
paper: http://arxiv.org/abs/1207.0443v3 (Medeiros, Mascarenhas,
Ierusalimschy. "Left Recursion in Parsing Expression Grammars" v3).
The last paragraph on p.14:
> We could impose left-associativity as the default in case of a grammar that
> mixes left and right recursion just by changing k ≥ k' in rule lvar.4 to k >
> k'
> and by changing k < k' in rule lvar.5 to k ≤ k'. The disadvantage is that this
> makes specifying precedence levels with right-associative operators a little
> harder
I can't see how it's supposed to work. Consider this grammar:
E = E[1] "+" E[1] / "n"
where [1] is precedence and the initial precedence is also 1.
Default precedence check is "fail if current rule precedence <= memoized
precedence," leading to right associative parse tree, as expected.
Modified precedence check is "fail if current rule precedence < memoized
precedence" and it does NOT lead to left associativity. Instead, recursive
E[1] invocation always fails due to precedence check, reducing the grammar
to E = "n" "+" "n" / "n".
General algorithm producing left association by default would be much
preferred from a usability perspective, if only it was possible.
-Nikita
_______________________________________________
PEG mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/peg