-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grammar that bison/byacc reports 35 reduce/reduce conflicts but happy none #260
Comments
The translation of these precedences
@mingodad What would be an example that parses wrongly with the |
The happy grammar has this: %right '...' '..'
%left juxtprec
RangeExp
: Exp2 '...' Exp2
| Exp2 '..' Exp2 '...' Exp2
Exp2
| RangeExp
| Exp2 '..' Atom
| Atom '..' Exp2
| ApplyList
ApplyList
: Atom ApplyList %prec juxtprec
| Atom %prec juxtprec The bison grammar has the same: %right "..." ".."
%left juxtprec
RangeExp : Exp2 "..." Exp2 ;
RangeExp : Exp2 ".." Exp2 "..." Exp2 ;
Exp2 : RangeExp ;
Exp2 : Exp2 ".." Atom ;
Exp2 : Atom ".." Exp2 ;
Exp2 : ApplyList ;
ApplyList : Atom ApplyList %prec juxtprec ;
ApplyList : Atom %prec juxtprec ; The counterexample given by
So According to @mingodad Can you argue that a conflict actually exists? Or how should we proceed with this issue? |
The documentation https://haskell-happy.readthedocs.io/en/latest/using.html#how-precedence-works clearly talk about The main issue is applying precedence to mask/hide/resolve For example the sqlite3 grammar splitting I'm still working on it and as soon I found an answer I'll tell you. |
I hadn't considered the possibly that bison doesn't use precedence at all for the reduce/reduce case. In this case it seems that one of the choices would immediately lead to a syntax error and happy figures that out. I think Bison doesn't have enough lookahead to see that it will be in a corner... |
The best I could find is https://www.ibm.com/docs/en/zos/2.1.0?topic=ambiguities-rules-help-remove "Precedence is not consulted in reduce-reduce conflicts. yacc always reduces by the earliest grammar rule, regardless of precedence" I wasn't sure if this also applied to bison, which is why I resorted to looking at the bison source code. |
While converting this grammar https://github.com/diku-dk/futhark/blob/master/src/Language/Futhark/Parser/Parser.y to use in https://mingodad.github.io/parsertl-playground/playground/ I found that bison/yacc/kmyacc reports 35 reduce/reduce conflicts but
happy
none.Attached is the grammar converted using
happy
-i
command line to get the expanded grammar and adding the missing parts manually (%tokens
,%prec
, ...):grammars.zip
The text was updated successfully, but these errors were encountered: