You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now it's possible for Ohm programmers to write "ambiguous" left- and right-recursive rules in a grammar, e.g.,
AddExp
= AddExp "+" AddExp -- plus
| AddExp "-" AddExp -- minus
| MulExp
This should be a compile-time error.
Why? Because the associativity of the + and - operators (see above) is not obvious, and it easily could have been. For instance, if you want them to associate to the left, then a much better way to write the above rule is:
AddExp
= AddExp "+" MulExp -- plus
| AddExp "-" MulExp -- minus
| MulExp
And now the associativity is obvious. (Similarly, if right-associativity is desired, then AddExp should be rewritten to be right-recursive.)
The text was updated successfully, but these errors were encountered:
A solution for this should probably use the existing mechanism for detecting left recursion, and build on that. Since we do want to detect this statically, we will probably have to live with some limitations.
(See #55 for the backstory.)
Right now it's possible for Ohm programmers to write "ambiguous" left- and right-recursive rules in a grammar, e.g.,
This should be a compile-time error.
Why? Because the associativity of the
+
and-
operators (see above) is not obvious, and it easily could have been. For instance, if you want them to associate to the left, then a much better way to write the above rule is:And now the associativity is obvious. (Similarly, if right-associativity is desired, then
AddExp
should be rewritten to be right-recursive.)The text was updated successfully, but these errors were encountered: