Skip to content

Commit 4fe1be3

Browse files
authored
Merge pull request #1795 from GaloisInc/T1794
Heapster: Avoid shift/reduce conflicts involving bitvector negation
2 parents 7a6c8e1 + 1dcdee3 commit 4fe1be3

File tree

1 file changed

+6
-1
lines changed
  • heapster-saw/src/Verifier/SAW/Heapster

1 file changed

+6
-1
lines changed

heapster-saw/src/Verifier/SAW/Heapster/Parser.y

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import Verifier.SAW.Heapster.UntypedAST
2222

2323
}
2424

25+
%expect 0 -- shift/reduce conflicts
26+
2527
%tokentype { Located Token }
2628
%token
2729
'(' { Located $$ TOpenParen }
@@ -108,6 +110,7 @@ NAT { (traverse tokenNat -> Just $$) }
108110
%left '+'
109111
%left '*'
110112
%nonassoc '@'
113+
%left NEGPREC
111114

112115
%%
113116

@@ -136,7 +139,9 @@ expr :: { AstExpr }
136139
| NAT { ExNat (pos $1) (locThing $1) }
137140
| 'unit' { ExUnit (pos $1) }
138141
| expr '+' expr { ExAdd (pos $2) $1 $3 }
139-
| '-' expr { ExNeg (pos $1) $2 }
142+
-- NB: Give negation the highest possible precedence to avoid shift/reduce
143+
-- conflicts with other operators, such as + and *.
144+
| '-' expr %prec NEGPREC { ExNeg (pos $1) $2 }
140145
| expr '*' expr { ExMul (pos $2) $1 $3 }
141146
| 'struct' '(' list(expr) ')' { ExStruct (pos $1) $3 }
142147
| lifetime 'array' '(' expr ',' expr ',' '<' expr ',' '*' expr ',' expr ')'

0 commit comments

Comments
 (0)