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
I want to parse ML-style whitespace sensitive function application using operator precedence, so I'd start from a grammar like
%left APP
%%
e : "f"
| e e %prec APP
and I would hope that this would be accepted without conflict by parsing chains of whitespace-separated "f" tokens as left-associated lists.
Alas, it appears that %prec declarations only work if the rule starts with a terminal, or some other hidden condition:
$ bison -v test.y -Wcounterexamples
test.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
test.y: warning: shift/reduce conflict on token "f" [-Wcounterexamples]
Example: e e • "f"
Shift derivation
e
↳ 2: e e
↳ 2: e e
↳ 1: • "f"
Reduce derivation
e
↳ 2: e e
↳ 2: e e • ↳ 1: "f"
If I use an arbitrary infix operator @ instead and specify %left @, all conflicts can be resolved.
Is there some technical reason why the operator-less use case can't be supported?
The text was updated successfully, but these errors were encountered:
I want to parse ML-style whitespace sensitive function application using operator precedence, so I'd start from a grammar like
and I would hope that this would be accepted without conflict by parsing chains of whitespace-separated "f" tokens as left-associated lists.
Alas, it appears that
%prec
declarations only work if the rule starts with a terminal, or some other hidden condition:If I use an arbitrary infix operator
@
instead and specify%left @
, all conflicts can be resolved.Is there some technical reason why the operator-less use case can't be supported?
The text was updated successfully, but these errors were encountered: