-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
subprojects/core/src/main/java/hu/bme/mit/theta/core/dsl/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
/** | ||
* This package contains the domain specific language (DSL) and the parser for | ||
* expressions. | ||
* | ||
* @see hu.bme.mit.theta.core.dsl.CoreDslManager | ||
* expressions. Use {@link hu.bme.mit.theta.core.dsl.CoreDslManager} as the entry point. | ||
*/ | ||
|
||
package hu.bme.mit.theta.core.dsl; |
19 changes: 10 additions & 9 deletions
19
subprojects/core/src/main/java/hu/bme/mit/theta/core/type/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
/** | ||
* This package contains types (e.g., boolean, integer) and expressions | ||
* operating over them (e.g., boolean connectives, arithmetic operations), | ||
* This package contains types (e.g., Boolean, integer) and expressions | ||
* operating over them (e.g., Boolean connectives, arithmetic operations), | ||
* grouped into subpackages. Constructors of the types and expressions are | ||
* usually package private. Use the factory classes instead. | ||
* | ||
* - {@link hu.bme.mit.theta.core.type.Expr} is the main interface for expressions. | ||
* - {@link hu.bme.mit.theta.core.type.anytype.Exprs} and {@link hu.bme.mit.theta.core.type.abstracttype.AbstractExprs} | ||
* work for multiple types (e.g., conditional). | ||
* - {@link hu.bme.mit.theta.core.type.booltype.BoolExprs} can create Boolean type and expressions (e.g., and, or). | ||
* - {@link hu.bme.mit.theta.core.type.inttype.IntExprs} can create mathematical (SMT) integer type and expressions | ||
* | ||
* - {@link hu.bme.mit.theta.core.type.anytype} and {@link hu.bme.mit.theta.core.type.abstracttype} | ||
* are expressions for multiple types (e.g., conditional). | ||
* - {@link hu.bme.mit.theta.core.type.booltype} contains the Boolean type and expressions (e.g., and, or). | ||
* - {@link hu.bme.mit.theta.core.type.inttype} contains the mathematical (SMT) integer type and expressions | ||
* (e.g., add, multiply). | ||
* - {@link hu.bme.mit.theta.core.type.rattype.RatExprs} can create rational type and expression (e.g., division). | ||
* - {@link hu.bme.mit.theta.core.type.arraytype.ArrayExprs} can create SMT array type (associative mapping from a | ||
* - {@link hu.bme.mit.theta.core.type.rattype} contains the rational type and expression (e.g., division). | ||
* - {@link hu.bme.mit.theta.core.type.arraytype} contains the SMT array type (associative mapping from a | ||
* key type to a value type) and expressions (e.g., read, write). | ||
* - {@link hu.bme.mit.theta.core.type.functype.FuncExprs} can create function type and expressions. | ||
* - {@link hu.bme.mit.theta.core.type.functype} contains the function type and expressions. | ||
*/ | ||
|
||
package hu.bme.mit.theta.core.type; |
58 changes: 58 additions & 0 deletions
58
subprojects/core/src/test/java/hu/bme/mit/theta/core/dsl/StmtDslTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package hu.bme.mit.theta.core.dsl; | ||
|
||
import hu.bme.mit.theta.core.decl.Decl; | ||
import hu.bme.mit.theta.core.decl.Decls; | ||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.stmt.Stmt; | ||
import hu.bme.mit.theta.core.type.inttype.IntExprs; | ||
import hu.bme.mit.theta.core.type.inttype.IntType; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import static hu.bme.mit.theta.core.type.booltype.BoolExprs.True; | ||
import static hu.bme.mit.theta.core.type.inttype.IntExprs.*; | ||
import static hu.bme.mit.theta.core.stmt.Stmts.*; | ||
|
||
@RunWith(Parameterized.class) | ||
public class StmtDslTest { | ||
@Parameterized.Parameter(value = 0) | ||
public String actual; | ||
|
||
@Parameterized.Parameter(value = 1) | ||
public Stmt expected; | ||
|
||
@Parameterized.Parameter(value = 2) | ||
public Collection<Decl<?>> decls; | ||
|
||
private static VarDecl<IntType> x = Decls.Var("x", IntExprs.Int()); | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][]{ | ||
|
||
{"assume true", Assume(True()), null}, | ||
|
||
{"x := x + 1", Assign(x, Add(x.getRef(), Int(1))) , Collections.singleton(x)}, | ||
|
||
{"havoc x", Havoc(x) , Collections.singleton(x)} | ||
|
||
}); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
final CoreDslManager manager = new CoreDslManager(); | ||
|
||
if (decls != null) { | ||
decls.forEach(decl -> manager.declare(decl)); | ||
} | ||
|
||
Assert.assertEquals(expected, manager.parseStmt(actual)); | ||
} | ||
} |