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

Add opaque/reveal to Gobra #715

Merged
merged 23 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/main/antlr4/GobraLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ PROOF : 'proof';
GHOST_EQUALS : '===';
GHOST_NOT_EQUALS : '!==';
WITH : 'with';
OPAQUE : 'opaque' -> mode(NLSEMI);
REVEAL : 'reveal';
12 changes: 7 additions & 5 deletions src/main/antlr4/GobraParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ sqType: (kind=(SEQ | SET | MSET | OPT) L_BRACKET type_ R_BRACKET)

// Specifications

specification returns[boolean trusted = false, boolean pure = false;]:
((specStatement | PURE {$pure = true;} | TRUSTED {$trusted = true;}) eos)*? (PURE {$pure = true;})? // Non-greedily match PURE to avoid missing eos errors.
specification returns[boolean trusted = false, boolean pure = false, boolean opaque = false;]:
((specStatement | OPAQUE {$opaque = true;} | PURE {$pure = true;} | TRUSTED {$trusted = true;}) eos)*? (PURE {$pure = true;})? // Non-greedily match PURE to avoid missing eos errors.
;

specStatement
Expand Down Expand Up @@ -226,11 +226,11 @@ new_: NEW L_PAREN type_ R_PAREN;

// Added specifications and parameter info

specMember: specification (functionDecl[$specification.trusted, $specification.pure] | methodDecl[$specification.trusted, $specification.pure]);
specMember: specification (functionDecl[$specification.trusted, $specification.pure, $specification.opaque] | methodDecl[$specification.trusted, $specification.pure, $specification.opaque]);

functionDecl[boolean trusted, boolean pure]: FUNC IDENTIFIER (signature blockWithBodyParameterInfo?);
functionDecl[boolean trusted, boolean pure, boolean opaque]: FUNC IDENTIFIER (signature blockWithBodyParameterInfo?);

methodDecl[boolean trusted, boolean pure]: FUNC receiver IDENTIFIER (signature blockWithBodyParameterInfo?);
methodDecl[boolean trusted, boolean pure, boolean opaque]: FUNC receiver IDENTIFIER (signature blockWithBodyParameterInfo?);



Expand Down Expand Up @@ -376,7 +376,9 @@ primaryExpr:
| primaryExpr slice_ #slicePrimaryExpr
| primaryExpr seqUpdExp #seqUpdPrimaryExpr
| primaryExpr typeAssertion #typeAssertionPrimaryExpr
// "REVEAL? primaryExpr arguments" doesn't work due to mutual left recursion
| primaryExpr arguments #invokePrimaryExpr
| REVEAL primaryExpr arguments #revealInvokePrimaryExpr
| primaryExpr arguments AS closureSpecInstance #invokePrimaryExprWithSpec
| primaryExpr predConstructArgs #predConstrPrimaryExpr
| call_op=(
Expand Down
1,768 changes: 891 additions & 877 deletions src/main/java/viper/gobra/frontend/GobraLexer.java

Large diffs are not rendered by default.

Loading
Loading