Skip to content
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

Heapster: Avoid shift/reduce conflicts involving bitvector negation #1795

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion heapster-saw/src/Verifier/SAW/Heapster/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import Verifier.SAW.Heapster.UntypedAST

}

%expect 0 -- shift/reduce conflicts

%tokentype { Located Token }
%token
'(' { Located $$ TOpenParen }
Expand Down Expand Up @@ -108,6 +110,7 @@ NAT { (traverse tokenNat -> Just $$) }
%left '+'
%left '*'
%nonassoc '@'
%left NEGPREC

%%

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