diff --git a/AlgebraicDataflowArchitectureModel/models/JumpGame.model b/AlgebraicDataflowArchitectureModel/models/JumpGame.model index 1a4c6b0..1981df9 100644 --- a/AlgebraicDataflowArchitectureModel/models/JumpGame.model +++ b/AlgebraicDataflowArchitectureModel/models/JumpGame.model @@ -16,13 +16,15 @@ out time(t:Double, gravity(y)) == t + 0.01 } channel CIO2 { - out move(v:Pair, moveX(x:Double)) == pair(x, right(v)) - out move(v, moveY(y:Double)) == pair(left(v), y) + out movex(x:Double, run(x2:Double)) == x2 } channel CIO3 { - out mass(m:Double, setMass(x:Double)) == x + out movey(y:Double, jump(y2:Double)) == y2 } channel CIO4 { + out mass(m:Double, setMass(x:Double)) == x +} +channel CIO5 { out ground(g:Bool, openHole) == false out ground(g, closeHole) == true } @@ -40,24 +42,29 @@ pair(left(v) + 0.01 * left(a2), right(v) + 0.01 * right(a2))) } channel C3 { - ref onground(o, update4(m2, o)) - in move(m, update4(m2, o)) == m2 - out velocity(v:Pair, update4(m2, o)) == if(and(o, ge(right(m2), 0.0)), m2, v) + ref onground(o, update4(x2, o)) + in movex(x, update4(x2, o)) == x2 + out velocity(v:Pair, update4(x2, o)) == if(o, pair(x2, right(v)), v) } channel C4 { - in velocity(v, update5(v2, g)) == v2 - ref ground(g, update5(v2, g)) - out position(p:Pair, update5(v2, g)) == if(and(eq(g, true), lt(right(p) + 0.01 * right(v2), 0.0)), + ref onground(o, update5(x2, o)) + in movey(y, update5(y2, o)) == y2 + out velocity(v:Pair, update5(y2, o)) == if(o, pair(left(v), y2), v) +} +channel C5 { + in velocity(v, update6(v2, g)) == v2 + ref ground(g, update6(v2, g)) + out position(p:Pair, update6(v2, g)) == if(and(eq(g, true), lt(right(p) + 0.01 * right(v2), 0.0)), pair(left(p) + 0.01 * left(v2), 0.0), pair(left(p) + 0.01 * left(v2), right(p) + 0.01 * right(v2))) } -channel C5 { +channel C6 { in position(p, update2(p2, g2)) == p2 in ground(g, update2(p2, g2)) == g2 out onground(o:Bool, update2(p2, g2)) == and(eq(g2, true), le(right(p2), 0.0)) } -channel C6 { - in position(p, update6(p2)) == p2 - out clear(c:Bool, update6(p2)) == if(gt(left(p2), 100.0), true, false) - out gameover(go:Bool, update6(p2)) == if(lt(right(p2), -1.0), true, false) +channel C7 { + in position(p, update7(p2)) == p2 + out clear(c:Bool, update7(p2)) == if(gt(left(p2), 100.0), true, false) + out gameover(go:Bool, update7(p2)) == if(lt(right(p2), -1.0), true, false) } \ No newline at end of file diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java index 9d68816..159febc 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataConstraintModel/DataConstraintModel.java @@ -33,6 +33,7 @@ public static final Symbol mul = new Symbol(Parser.MUL, 2, Symbol.Type.INFIX);; public static final Symbol sub = new Symbol(Parser.SUB, 2, Symbol.Type.INFIX); public static final Symbol div = new Symbol(Parser.DIV, 2, Symbol.Type.INFIX); + public static final Symbol mod = new Symbol(Parser.MOD, 2, Symbol.Type.INFIX); public static final Symbol minus = new Symbol(Parser.MINUS, 1); public static final Symbol cons = new Symbol("cons", 2, Symbol.Type.PREFIX, "($x,$y)->$x.add(0, $y)", Symbol.Type.LAMBDA_WITH_SIDE_EFFECT, new int[] {1, 0}); public static final Symbol head = new Symbol("head", 1, Symbol.Type.PREFIX, "($x)->$x.get(0)", Symbol.Type.LAMBDA); @@ -159,6 +160,7 @@ addSymbol(mul); addSymbol(sub); addSymbol(div); + addSymbol(mod); addSymbol(minus); addSymbol(cons); addSymbol(head); diff --git a/AlgebraicDataflowArchitectureModel/src/parser/Parser.java b/AlgebraicDataflowArchitectureModel/src/parser/Parser.java index c41a255..4372911 100644 --- a/AlgebraicDataflowArchitectureModel/src/parser/Parser.java +++ b/AlgebraicDataflowArchitectureModel/src/parser/Parser.java @@ -34,11 +34,13 @@ public static final String MUL = "*"; public static final String SUB = "-"; public static final String DIV = "/"; + public static final String MOD = "%"; public static final String MINUS = "-"; public static final String ADD_REGX = "\\+"; public static final String MUL_REGX = "\\*"; public static final String SUB_REGX = "\\-"; public static final String DIV_REGX = "/"; + public static final String MOD_REGX = "\\%"; public static final String IN = "in"; public static final String OUT = "out"; public static final String REF = "ref"; @@ -292,6 +294,8 @@ operators.add(DataFlowModel.sub); // not minus } else if (operator.equals(DIV)) { operators.add(DataFlowModel.div); + } else if (operator.equals(MOD)) { + operators.add(DataFlowModel.mod); } else { break; } @@ -356,17 +360,20 @@ splitBy( splitBy( splitBy( - splitBy( - splitBy( - Arrays.asList(line.split("[ \t]")), - ADD, - ADD_REGX), - MUL, - MUL_REGX), - SUB, - SUB_REGX), - DIV, - DIV_REGX), + splitBy( + splitBy( + splitBy( + Arrays.asList(line.split("[ \t]")), + ADD, + ADD_REGX), + MUL, + MUL_REGX), + SUB, + SUB_REGX), + DIV, + DIV_REGX), + MOD, + MOD_REGX), COMMA, COMMA), COLON,