|
|
|
@ -39,51 +39,47 @@ public class ReplaceAccumulationExpression extends ASTTraverseModify { |
|
|
|
if (sym.isMinus()) { |
|
|
|
throw(new PrismLangException("Accumulation with past is not supported.")); |
|
|
|
} |
|
|
|
|
|
|
|
// This expression is of the form OR{0..(l-1)}(init_i AND (run_i UNTIL goal_i)) |
|
|
|
|
|
|
|
if (sym.isUntil()) { |
|
|
|
throw(new PrismLangException("ACCUNTIL is not supported.")); |
|
|
|
} else { |
|
|
|
// This expression is of the form OR{0..(l-1)}(init_i AND (run_i UNTIL goal_i)) |
|
|
|
|
|
|
|
// Build all the subexpressions... |
|
|
|
ArrayList<ExpressionBinaryOp> clauses = new ArrayList<>(); |
|
|
|
Expression result = null; |
|
|
|
// Build all the subexpressions... |
|
|
|
ArrayList<ExpressionBinaryOp> clauses = new ArrayList<>(); |
|
|
|
Expression result = null; |
|
|
|
|
|
|
|
for(int i=0; i<accLength; i++) { |
|
|
|
Expression init = new ExpressionLabel(initLabels.get(i)); |
|
|
|
Expression run = new ExpressionLabel(runLabels.get(i)); |
|
|
|
Expression goal = new ExpressionLabel(goalLabels.get(i)); |
|
|
|
|
|
|
|
for(int i=0; i<accLength; i++) { |
|
|
|
Expression init = new ExpressionLabel(initLabels.get(i)); |
|
|
|
Expression run = new ExpressionLabel(runLabels.get(i)); |
|
|
|
Expression goal = new ExpressionLabel(goalLabels.get(i)); |
|
|
|
|
|
|
|
// if this is until: |
|
|
|
// append first operand to run |
|
|
|
// append second operand to goal |
|
|
|
if(accexp.getOperand1() != null) { |
|
|
|
run = new ExpressionBinaryOp(ExpressionBinaryOp.AND, run, accexp.getOperand1()); |
|
|
|
} |
|
|
|
if(accexp.getOperand2() != null) { |
|
|
|
goal = new ExpressionBinaryOp(ExpressionBinaryOp.AND, goal, accexp.getOperand2()); |
|
|
|
} |
|
|
|
|
|
|
|
// until: (run_i UNTIL goal_i) |
|
|
|
ExpressionTemporal until = new ExpressionTemporal(ExpressionTemporal.P_U, run, goal); |
|
|
|
// and: (init_i AND until) |
|
|
|
ExpressionBinaryOp and = new ExpressionBinaryOp(ExpressionBinaryOp.AND, init, until); |
|
|
|
|
|
|
|
clauses.add(and); |
|
|
|
if(i==0) { |
|
|
|
result = and; |
|
|
|
} else { |
|
|
|
result = new ExpressionBinaryOp(ExpressionBinaryOp.OR, result, and); |
|
|
|
} |
|
|
|
// if this is until: |
|
|
|
// append first operand to run |
|
|
|
// append second operand to goal |
|
|
|
if(accexp.getOperand1() != null) { |
|
|
|
run = new ExpressionBinaryOp(ExpressionBinaryOp.AND, run, accexp.getOperand1()); |
|
|
|
} |
|
|
|
if(accexp.getOperand2() != null) { |
|
|
|
goal = new ExpressionBinaryOp(ExpressionBinaryOp.AND, goal, accexp.getOperand2()); |
|
|
|
} |
|
|
|
|
|
|
|
// If its a BOX, negate it |
|
|
|
if (sym.isBox()) { |
|
|
|
return new ExpressionUnaryOp(ExpressionUnaryOp.NOT, result); |
|
|
|
// until: (run_i UNTIL goal_i) |
|
|
|
ExpressionTemporal until = new ExpressionTemporal(ExpressionTemporal.P_U, run, goal); |
|
|
|
// and: (init_i AND until) |
|
|
|
ExpressionBinaryOp and = new ExpressionBinaryOp(ExpressionBinaryOp.AND, init, until); |
|
|
|
|
|
|
|
clauses.add(and); |
|
|
|
if(i==0) { |
|
|
|
result = and; |
|
|
|
} else { |
|
|
|
return result; |
|
|
|
result = new ExpressionBinaryOp(ExpressionBinaryOp.OR, result, and); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If its a BOX, negate it |
|
|
|
if (sym.isBox()) { |
|
|
|
return new ExpressionUnaryOp(ExpressionUnaryOp.NOT, result); |
|
|
|
} else { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} else { |
|
|
|
return expr; |
|
|
|
} |
|
|
|
|