I have a grammar which, depending on the order of setting, 3 happy reports reduce / decrease conflicts or not. The minimum example I can find is:
%tokentype {Token} %token int { Int } '-' { Neg } both { Both } %nonassoc both %left '-' %nonassoc NEG %% E : int {IntE} | both EE {BothE $2 $3} | '-' E %prec NEG {NegE $2} | E '-' E {SubE $1 $3} { data Token = Int | Neg | Both deriving Show data Expr = BothE Expr Expr | IntE | SubE Expr Expr | NegE Expr deriving Show }
It has 3 contraction reduction conflicts based on the inability to distinguish between " both 7 -3 " and " both 7-3 2 ". Fair enough!
However, if you replace the last two pieces for E ( '-' E %prec NEG and E '-' E ), the decrease / decrease conflicts will disappear. More mysteriously, if you then remove the %prec NEG directive, they will return. I am completely confused by what is happening here: why the question of order?
haskell happy lr
sfogarty
source share