Skip to content

Commit e959ce6

Browse files
committed
Merge branch 'main' into null-support
2 parents aef5189 + 3562af1 commit e959ce6

22 files changed

+215
-72
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package testSuite;
2+
3+
import liquidjava.specification.Ghost;
4+
import liquidjava.specification.StateRefinement;
5+
6+
@Ghost("int n")
7+
public class CorrectDotNotationIncrementOnce {
8+
9+
// explicit this
10+
@StateRefinement(to="this.n() == 0")
11+
public CorrectDotNotationIncrementOnce() {}
12+
13+
// implicit this
14+
@StateRefinement(from="n() == 0", to="n() == old(this).n() + 1")
15+
public void incrementOnce() {}
16+
17+
public static void main(String[] args) {
18+
CorrectDotNotationIncrementOnce t = new CorrectDotNotationIncrementOnce();
19+
t.incrementOnce();
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package testSuite;
2+
3+
import liquidjava.specification.StateRefinement;
4+
import liquidjava.specification.StateSet;
5+
6+
@StateSet({"green", "amber", "red"})
7+
public class CorrectDotNotationTrafficLight {
8+
9+
@StateRefinement(to="this.green()")
10+
public CorrectDotNotationTrafficLight() {}
11+
12+
@StateRefinement(from="this.green()", to="this.amber()")
13+
public void transitionToAmber() {}
14+
15+
@StateRefinement(from="red()", to="green()")
16+
public void transitionToGreen() {}
17+
18+
@StateRefinement(from="this.amber()", to="red()")
19+
public void transitionToRed() {}
20+
21+
public static void main(String[] args) {
22+
CorrectDotNotationTrafficLight tl = new CorrectDotNotationTrafficLight();
23+
tl.transitionToAmber();
24+
tl.transitionToRed();
25+
tl.transitionToGreen();
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// State Refinement Error
2+
package testSuite;
3+
4+
import liquidjava.specification.Ghost;
5+
import liquidjava.specification.StateRefinement;
6+
7+
@Ghost("int n")
8+
public class ErrorDotNotationIncrementOnce {
9+
10+
@StateRefinement(to="this.n() == 0")
11+
public ErrorDotNotationIncrementOnce() {}
12+
13+
@StateRefinement(from="n() == 0", to="n() == old(this).n() + 1")
14+
public void incrementOnce() {}
15+
16+
public static void main(String[] args) {
17+
ErrorDotNotationIncrementOnce t = new ErrorDotNotationIncrementOnce();
18+
t.incrementOnce();
19+
t.incrementOnce(); // error
20+
}
21+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Syntax Error
2+
package testSuite;
3+
4+
import liquidjava.specification.Ghost;
5+
import liquidjava.specification.Refinement;
6+
import liquidjava.specification.StateRefinement;
7+
8+
@Ghost("int size")
9+
public class ErrorDotNotationMultiple {
10+
11+
@StateRefinement(to="size() == 0")
12+
public ErrorDotNotationMultiple() {}
13+
14+
void test() {
15+
@Refinement("_ == this.not.size()")
16+
int x = 0;
17+
}
18+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// State Refinement Error
2+
package testSuite;
3+
4+
import liquidjava.specification.StateRefinement;
5+
import liquidjava.specification.StateSet;
6+
7+
@StateSet({"green", "amber", "red"})
8+
public class ErrorDotNotationTrafficLight {
9+
10+
@StateRefinement(to="this.green()")
11+
public ErrorDotNotationTrafficLight() {}
12+
13+
@StateRefinement(from="this.green()", to="this.amber()")
14+
public void transitionToAmber() {}
15+
16+
@StateRefinement(from="red()", to="green()")
17+
public void transitionToGreen() {}
18+
19+
@StateRefinement(from="this.amber()", to="red()")
20+
public void transitionToRed() {}
21+
22+
public static void main(String[] args) {
23+
ErrorDotNotationTrafficLight tl = new ErrorDotNotationTrafficLight();
24+
tl.transitionToAmber();
25+
tl.transitionToGreen(); // error
26+
tl.transitionToRed();
27+
}
28+
}

liquidjava-example/src/main/java/testSuite/ErrorSyntax1.java renamed to liquidjava-example/src/main/java/testSuite/ErrorSyntaxRefinement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import liquidjava.specification.Refinement;
55

66
@SuppressWarnings("unused")
7-
public class ErrorSyntax1 {
7+
public class ErrorSyntaxRefinement {
88
public static void main(String[] args) {
99
@Refinement("_ < 100 +")
1010
int value = 90 + 4;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Syntax Error
2+
package testSuite;
3+
4+
import liquidjava.specification.StateRefinement;
5+
6+
public class ErrorSyntaxStateRefinement {
7+
8+
@StateRefinement(from="$", to="#")
9+
void test() {}
10+
}

liquidjava-verifier/src/main/antlr4/rj/grammar/RJ.g4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ literalExpression:
3737
'(' literalExpression ')' #litGroup
3838
| literal #lit
3939
| ID #var
40-
| ID '.' functionCall #targetInvocation
4140
| functionCall #invocation
4241
;
4342

4443
functionCall:
4544
ghostCall
46-
| aliasCall;
45+
| aliasCall
46+
| dotCall;
47+
48+
dotCall:
49+
OBJECT_TYPE '(' args? ')'
50+
| ID '(' args? ')' '.' ID '(' args? ')';
4751

4852
ghostCall:
4953
ID '(' args? ')';

liquidjava-verifier/src/main/java/liquidjava/diagnostics/errors/StateConflictError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public StateConflictError(SourcePosition position, Expression state, Translation
1717
super("State Conflict Error",
1818
"Found multiple disjoint states in state transition: state transition can only go to one state of each state set",
1919
position, translationTable);
20-
this.state = state.toSimplifiedString();
20+
this.state = state.toString();
2121
}
2222

2323
public String getState() {

liquidjava-verifier/src/main/java/liquidjava/diagnostics/errors/StateRefinementError.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ public class StateRefinementError extends LJError {
1616

1717
public StateRefinementError(SourcePosition position, Expression expected, Expression found,
1818
TranslationTable translationTable, String customMessage) {
19-
super("State Refinement Error", String.format("Expected state %s but found %s", expected.toSimplifiedString(),
20-
found.toSimplifiedString()), position, translationTable, customMessage);
21-
this.expected = expected.toSimplifiedString();
22-
this.found = found.toSimplifiedString();
19+
super("State Refinement Error",
20+
String.format("Expected state %s but found %s", expected.toString(), found.toString()), position,
21+
translationTable, customMessage);
22+
this.expected = expected.toString();
23+
this.found = found.toString();
2324
}
2425

2526
public String getExpected() {

0 commit comments

Comments
 (0)