Browse Source

Add strategy operators (<<>> and [[]]) to parser, but no support model checking.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@9219 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 12 years ago
parent
commit
8cb6a437cd
  1. 937
      prism/src/parser/PrismParser.java
  2. 32
      prism/src/parser/PrismParser.jj
  3. 56
      prism/src/parser/PrismParserConstants.java
  4. 198
      prism/src/parser/PrismParserTokenManager.java
  5. 175
      prism/src/parser/ast/ExpressionStrategy.java
  6. 10
      prism/src/parser/visitor/ASTTraverse.java
  7. 10
      prism/src/parser/visitor/ASTTraverseModify.java
  8. 1
      prism/src/parser/visitor/ASTVisitor.java
  9. 6
      prism/src/parser/visitor/CheckValid.java
  10. 7
      prism/src/parser/visitor/Rename.java
  11. 5
      prism/src/parser/visitor/TypeCheck.java

937
prism/src/parser/PrismParser.java
File diff suppressed because it is too large
View File

32
prism/src/parser/PrismParser.jj

@ -437,12 +437,16 @@ TOKEN :
| < RPARENTH: ")" >
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < DLBRACKET: "[[" >
| < DRBRACKET: "]]" >
| < LBRACE: "{" >
| < RBRACE: "}" >
| < EQ: "=" >
| < NE: "!=" >
| < LT: "<" >
| < GT: ">" >
| < DLT: "<<" >
| < DGT: ">>" >
| < LE: "<=" >
| < GE: ">=" >
| < PLUS: "+" >
@ -1320,6 +1324,8 @@ Expression ExpressionBasic(boolean prop, boolean pathprop) :
ret = ExpressionExists(prop, pathprop)
|
ret = ExpressionForAll(prop, pathprop)
|
ret = ExpressionStrategy(prop, pathprop)
|
ret = ExpressionLabel(prop, pathprop)
|
@ -1666,6 +1672,32 @@ Expression ExpressionForAll(boolean prop, boolean pathprop) :
}
}
// (Property) expression: ATL strategy operators <<>> and [[]]
Expression ExpressionStrategy(boolean prop, boolean pathprop) :
{
ExpressionStrategy ret;
Expression expr;
Token begin = null;
}
{
// This production is only allowed in expressions if the "prop" parameter is true
{ if (!prop) throw generateParseException(); }
(
// <<...>> or [[...]]
(( begin = <DLT> { ret = new ExpressionStrategy(true); } <DGT> )
| (begin = <DLBRACKET> { ret = new ExpressionStrategy(false); } <DRBRACKET> ))
// Child expression
( expr = ExpressionProb(prop, pathprop) | expr = ExpressionReward(prop, pathprop)
| expr = ExpressionParenth(prop, pathprop) | expr = ExpressionFuncOrIdent(prop, pathprop) )
{ ret.setExpression(expr); }
)
{
ret.setPosition(begin, getToken(0));
return ret;
}
}
// (Property) expression: label (including "init")
Expression ExpressionLabel(boolean prop, boolean pathprop) :

56
prism/src/parser/PrismParserConstants.java

@ -141,49 +141,57 @@ public interface PrismParserConstants {
/** RegularExpression Id. */
int RBRACKET = 65;
/** RegularExpression Id. */
int LBRACE = 66;
int DLBRACKET = 66;
/** RegularExpression Id. */
int RBRACE = 67;
int DRBRACKET = 67;
/** RegularExpression Id. */
int EQ = 68;
int LBRACE = 68;
/** RegularExpression Id. */
int NE = 69;
int RBRACE = 69;
/** RegularExpression Id. */
int LT = 70;
int EQ = 70;
/** RegularExpression Id. */
int GT = 71;
int NE = 71;
/** RegularExpression Id. */
int LE = 72;
int LT = 72;
/** RegularExpression Id. */
int GE = 73;
int GT = 73;
/** RegularExpression Id. */
int PLUS = 74;
int DLT = 74;
/** RegularExpression Id. */
int MINUS = 75;
int DGT = 75;
/** RegularExpression Id. */
int TIMES = 76;
int LE = 76;
/** RegularExpression Id. */
int DIVIDE = 77;
int GE = 77;
/** RegularExpression Id. */
int PRIME = 78;
int PLUS = 78;
/** RegularExpression Id. */
int RENAME = 79;
int MINUS = 79;
/** RegularExpression Id. */
int QMARK = 80;
int TIMES = 80;
/** RegularExpression Id. */
int DQUOTE = 81;
int DIVIDE = 81;
/** RegularExpression Id. */
int REG_INT = 82;
int PRIME = 82;
/** RegularExpression Id. */
int REG_DOUBLE = 83;
int RENAME = 83;
/** RegularExpression Id. */
int REG_IDENTPRIME = 84;
int QMARK = 84;
/** RegularExpression Id. */
int REG_IDENT = 85;
int DQUOTE = 85;
/** RegularExpression Id. */
int PREPROC = 86;
int REG_INT = 86;
/** RegularExpression Id. */
int LEXICAL_ERROR = 87;
int REG_DOUBLE = 87;
/** RegularExpression Id. */
int REG_IDENTPRIME = 88;
/** RegularExpression Id. */
int REG_IDENT = 89;
/** RegularExpression Id. */
int PREPROC = 90;
/** RegularExpression Id. */
int LEXICAL_ERROR = 91;
/** Lexical state. */
int DEFAULT = 0;
@ -256,12 +264,16 @@ public interface PrismParserConstants {
"\")\"",
"\"[\"",
"\"]\"",
"\"[[\"",
"\"]]\"",
"\"{\"",
"\"}\"",
"\"=\"",
"\"!=\"",
"\"<\"",
"\">\"",
"\"<<\"",
"\">>\"",
"\"<=\"",
"\">=\"",
"\"+\"",

198
prism/src/parser/PrismParserTokenManager.java

@ -21,56 +21,56 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
switch (pos)
{
case 0:
if ((active0 & 0x387c5fb5ff6f0L) != 0L)
{
jjmatchedKind = 89;
return 23;
}
if ((active0 & 0xc783a04a00908L) != 0L)
return 23;
if ((active1 & 0x2000L) != 0L)
if ((active1 & 0x20000L) != 0L)
return 1;
if ((active0 & 0x2000000000000000L) != 0L)
return 11;
if ((active0 & 0x387c5fb5ff6f0L) != 0L)
{
jjmatchedKind = 85;
return 23;
}
return -1;
case 1:
if ((active0 & 0x39fddfb5ff6f0L) != 0L)
{
if (jjmatchedPos != 1)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 1;
}
return 23;
}
return -1;
case 2:
if ((active0 & 0x100e8000000L) != 0L)
return 23;
if ((active0 & 0x39edd135ff6f0L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 2;
return 23;
}
if ((active0 & 0x100e8000000L) != 0L)
return 23;
return -1;
case 3:
if ((active0 & 0x21ad801100490L) != 0L)
return 23;
if ((active0 & 0x18405124ff260L) != 0L)
{
if (jjmatchedPos != 3)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 3;
}
return 23;
}
if ((active0 & 0x21ad801100490L) != 0L)
return 23;
return -1;
case 4:
if ((active0 & 0x18445024df200L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 4;
return 23;
}
@ -82,7 +82,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
return 23;
if ((active0 & 0x84440205f000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 5;
return 23;
}
@ -90,7 +90,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
case 6:
if ((active0 & 0x80440201e000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 6;
return 23;
}
@ -100,27 +100,27 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
case 7:
if ((active0 & 0x80440201e000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 7;
return 23;
}
return -1;
case 8:
if ((active0 & 0x2014000L) != 0L)
return 23;
if ((active0 & 0x80440000a000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 8;
return 23;
}
if ((active0 & 0x2014000L) != 0L)
return 23;
return -1;
case 9:
if ((active0 & 0x800000008000L) != 0L)
return 23;
if ((active0 & 0x4400002000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 9;
return 23;
}
@ -128,7 +128,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
case 10:
if ((active0 & 0x4400002000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 10;
return 23;
}
@ -138,7 +138,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
return 23;
if ((active0 & 0x4400000000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 11;
return 23;
}
@ -148,7 +148,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
return 23;
if ((active0 & 0x400000000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 12;
return 23;
}
@ -156,7 +156,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
case 13:
if ((active0 & 0x400000000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 13;
return 23;
}
@ -164,7 +164,7 @@ private static final int jjStopStringLiteralDfa_0(int pos, long active0, long ac
case 14:
if ((active0 & 0x400000000L) != 0L)
{
jjmatchedKind = 85;
jjmatchedKind = 89;
jjmatchedPos = 14;
return 23;
}
@ -189,45 +189,45 @@ static private int jjMoveStringLiteralDfa0_0()
{
case 33:
jjmatchedKind = 52;
return jjMoveStringLiteralDfa1_0(0x0L, 0x20L);
return jjMoveStringLiteralDfa1_0(0x0L, 0x80L);
case 34:
return jjStopAtPos(0, 81);
return jjStopAtPos(0, 85);
case 38:
return jjStopAtPos(0, 53);
case 39:
return jjStopAtPos(0, 78);
return jjStopAtPos(0, 82);
case 40:
return jjStopAtPos(0, 62);
case 41:
return jjStopAtPos(0, 63);
case 42:
return jjStopAtPos(0, 76);
return jjStopAtPos(0, 80);
case 43:
return jjStopAtPos(0, 74);
return jjStopAtPos(0, 78);
case 44:
return jjStopAtPos(0, 60);
case 45:
jjmatchedKind = 75;
jjmatchedKind = 79;
return jjMoveStringLiteralDfa1_0(0x200000000000000L, 0x0L);
case 46:
return jjMoveStringLiteralDfa1_0(0x2000000000000000L, 0x0L);
case 47:
return jjStartNfaWithStates_0(0, 77, 1);
return jjStartNfaWithStates_0(0, 81, 1);
case 58:
return jjStopAtPos(0, 58);
case 59:
return jjStopAtPos(0, 59);
case 60:
jjmatchedKind = 70;
return jjMoveStringLiteralDfa1_0(0x100000000000000L, 0x8100L);
jjmatchedKind = 72;
return jjMoveStringLiteralDfa1_0(0x100000000000000L, 0x81400L);
case 61:
jjmatchedKind = 68;
jjmatchedKind = 70;
return jjMoveStringLiteralDfa1_0(0x80000000000000L, 0x0L);
case 62:
jjmatchedKind = 71;
return jjMoveStringLiteralDfa1_0(0x0L, 0x200L);
jjmatchedKind = 73;
return jjMoveStringLiteralDfa1_0(0x0L, 0x2800L);
case 63:
return jjStopAtPos(0, 80);
return jjStopAtPos(0, 84);
case 65:
return jjStartNfaWithStates_0(0, 3, 23);
case 67:
@ -255,9 +255,11 @@ static private int jjMoveStringLiteralDfa0_0()
case 88:
return jjStartNfaWithStates_0(0, 33, 23);
case 91:
return jjStopAtPos(0, 64);
jjmatchedKind = 64;
return jjMoveStringLiteralDfa1_0(0x0L, 0x4L);
case 93:
return jjStopAtPos(0, 65);
jjmatchedKind = 65;
return jjMoveStringLiteralDfa1_0(0x0L, 0x8L);
case 98:
return jjMoveStringLiteralDfa1_0(0x10L, 0x0L);
case 99:
@ -287,11 +289,11 @@ static private int jjMoveStringLiteralDfa0_0()
case 116:
return jjMoveStringLiteralDfa1_0(0x2000000000000L, 0x0L);
case 123:
return jjStopAtPos(0, 66);
return jjStopAtPos(0, 68);
case 124:
return jjStopAtPos(0, 54);
case 125:
return jjStopAtPos(0, 67);
return jjStopAtPos(0, 69);
default :
return jjMoveNfa_0(0, 0);
}
@ -306,29 +308,43 @@ static private int jjMoveStringLiteralDfa1_0(long active0, long active1)
switch(curChar)
{
case 45:
if ((active1 & 0x8000L) != 0L)
return jjStopAtPos(1, 79);
if ((active1 & 0x80000L) != 0L)
return jjStopAtPos(1, 83);
break;
case 46:
if ((active0 & 0x2000000000000000L) != 0L)
return jjStopAtPos(1, 61);
break;
case 60:
if ((active1 & 0x400L) != 0L)
return jjStopAtPos(1, 74);
break;
case 61:
if ((active1 & 0x20L) != 0L)
return jjStopAtPos(1, 69);
else if ((active1 & 0x100L) != 0L)
if ((active1 & 0x80L) != 0L)
return jjStopAtPos(1, 71);
else if ((active1 & 0x1000L) != 0L)
{
jjmatchedKind = 72;
jjmatchedKind = 76;
jjmatchedPos = 1;
}
else if ((active1 & 0x200L) != 0L)
return jjStopAtPos(1, 73);
else if ((active1 & 0x2000L) != 0L)
return jjStopAtPos(1, 77);
return jjMoveStringLiteralDfa2_0(active0, 0x100000000000000L, active1, 0L);
case 62:
if ((active0 & 0x80000000000000L) != 0L)
return jjStopAtPos(1, 55);
else if ((active0 & 0x200000000000000L) != 0L)
return jjStopAtPos(1, 57);
else if ((active1 & 0x800L) != 0L)
return jjStopAtPos(1, 75);
break;
case 91:
if ((active1 & 0x4L) != 0L)
return jjStopAtPos(1, 66);
break;
case 93:
if ((active1 & 0x8L) != 0L)
return jjStopAtPos(1, 67);
break;
case 97:
return jjMoveStringLiteralDfa2_0(active0, 0x20030020000L, active1, 0L);
@ -863,14 +879,14 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 23:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 85)
kind = 85;
if (kind > 89)
kind = 89;
jjCheckNAdd(22);
}
else if (curChar == 39)
{
if (kind > 84)
kind = 84;
if (kind > 88)
kind = 88;
}
if ((0x3ff000000000000L & l) != 0L)
jjCheckNAddTwoStates(20, 21);
@ -878,8 +894,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 0:
if ((0x3ff000000000000L & l) != 0L)
{
if (kind > 83)
kind = 83;
if (kind > 87)
kind = 87;
jjCheckNAddStates(0, 3);
}
else if ((0x100002600L & l) != 0L)
@ -895,14 +911,14 @@ static private int jjMoveNfa_0(int startState, int curPos)
jjstateSet[jjnewStateCnt++] = 1;
if ((0x3fe000000000000L & l) != 0L)
{
if (kind > 82)
kind = 82;
if (kind > 86)
kind = 86;
jjCheckNAdd(8);
}
else if (curChar == 48)
{
if (kind > 82)
kind = 82;
if (kind > 86)
kind = 86;
}
break;
case 1:
@ -932,20 +948,20 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 7:
if ((0x3fe000000000000L & l) == 0L)
break;
if (kind > 82)
kind = 82;
if (kind > 86)
kind = 86;
jjCheckNAdd(8);
break;
case 8:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 82)
kind = 82;
if (kind > 86)
kind = 86;
jjCheckNAdd(8);
break;
case 9:
if (curChar == 48 && kind > 82)
kind = 82;
if (curChar == 48 && kind > 86)
kind = 86;
break;
case 10:
if (curChar == 46)
@ -954,8 +970,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 11:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 83)
kind = 83;
if (kind > 87)
kind = 87;
jjCheckNAddTwoStates(11, 12);
break;
case 13:
@ -965,8 +981,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 14:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 83)
kind = 83;
if (kind > 87)
kind = 87;
jjCheckNAdd(14);
break;
case 15:
@ -978,14 +994,14 @@ static private int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddTwoStates(16, 17);
break;
case 17:
if (curChar == 35 && kind > 86)
kind = 86;
if (curChar == 35 && kind > 90)
kind = 90;
break;
case 18:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 83)
kind = 83;
if (kind > 87)
kind = 87;
jjCheckNAddStates(0, 3);
break;
case 20:
@ -993,14 +1009,14 @@ static private int jjMoveNfa_0(int startState, int curPos)
jjCheckNAddTwoStates(20, 21);
break;
case 21:
if (curChar == 39 && kind > 84)
kind = 84;
if (curChar == 39 && kind > 88)
kind = 88;
break;
case 22:
if ((0x3ff000000000000L & l) == 0L)
break;
if (kind > 85)
kind = 85;
if (kind > 89)
kind = 89;
jjCheckNAdd(22);
break;
default : break;
@ -1017,8 +1033,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 23:
if ((0x7fffffe87fffffeL & l) != 0L)
{
if (kind > 85)
kind = 85;
if (kind > 89)
kind = 89;
jjCheckNAdd(22);
}
if ((0x7fffffe87fffffeL & l) != 0L)
@ -1027,8 +1043,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 0:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 85)
kind = 85;
if (kind > 89)
kind = 89;
jjCheckNAddStates(7, 9);
break;
case 2:
@ -1048,8 +1064,8 @@ static private int jjMoveNfa_0(int startState, int curPos)
case 22:
if ((0x7fffffe87fffffeL & l) == 0L)
break;
if (kind > 85)
kind = 85;
if (kind > 89)
kind = 89;
jjCheckNAdd(22);
break;
default : break;
@ -1124,16 +1140,16 @@ public static final String[] jjstrLiteralImages = {
"\162\145\167\141\162\144\163", "\122\155\141\170", "\122\155\151\156", "\122", "\123",
"\163\164\157\143\150\141\163\164\151\143", "\163\171\163\164\145\155", "\164\162\165\145", "\125", "\127", "\41", "\46",
"\174", "\75\76", "\74\75\76", "\55\76", "\72", "\73", "\54", "\56\56", "\50", "\51",
"\133", "\135", "\173", "\175", "\75", "\41\75", "\74", "\76", "\74\75", "\76\75",
"\53", "\55", "\52", "\57", "\47", "\74\55", "\77", "\42", null, null, null, null,
null, null, };
"\133", "\135", "\133\133", "\135\135", "\173", "\175", "\75", "\41\75", "\74", "\76",
"\74\74", "\76\76", "\74\75", "\76\75", "\53", "\55", "\52", "\57", "\47", "\74\55",
"\77", "\42", null, null, null, null, null, null, };
/** Lexer state names. */
public static final String[] lexStateNames = {
"DEFAULT",
};
static final long[] jjtoToken = {
0xfffffffffffffff9L, 0xffffffL,
0xfffffffffffffff9L, 0xfffffffL,
};
static final long[] jjtoSkip = {
0x6L, 0x0L,
@ -1246,9 +1262,9 @@ public static Token getNextToken()
jjmatchedKind = 0x7fffffff;
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_0();
if (jjmatchedPos == 0 && jjmatchedKind > 87)
if (jjmatchedPos == 0 && jjmatchedKind > 91)
{
jjmatchedKind = 87;
jjmatchedKind = 91;
}
if (jjmatchedKind != 0x7fffffff)
{

175
prism/src/parser/ast/ExpressionStrategy.java

@ -0,0 +1,175 @@
//==============================================================================
//
// Copyright (c) 2002-
// Authors:
// * Dave Parker <d.a.parker@cs.bham.ac.uk> (University of Birmingham/Oxford)
//
//------------------------------------------------------------------------------
//
// This file is part of PRISM.
//
// PRISM is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// PRISM is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with PRISM; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//==============================================================================
package parser.ast;
import java.util.ArrayList;
import java.util.List;
import parser.EvaluateContext;
import parser.visitor.ASTVisitor;
import prism.PrismLangException;
import prism.PrismUtils;
/**
* Class to represent ATL <<.>> and [[.]] operators, i.e. quantification over strategies
* ("there exists a strategy" or "for all strategies").
*/
public class ExpressionStrategy extends Expression
{
/** "There exists a strategy" (true) or "for all strategies" (false) */
protected boolean thereExists = false;
// Coalition info (for game models)
/** Coalition: list of player names */
protected List<String> coalition = null;
/** Child expression */
protected Expression expression = null;
// Constructors
public ExpressionStrategy()
{
}
public ExpressionStrategy(boolean thereExists)
{
this.thereExists = thereExists;
}
public ExpressionStrategy(boolean thereExists, Expression expression)
{
this.thereExists = thereExists;
this.expression = expression;
}
// Set methods
public void setThereExists(boolean thereExists)
{
this.thereExists = thereExists;
}
public void setCoalition(List<String> coalition)
{
this.coalition = coalition;
}
public void setExpression(Expression expression)
{
this.expression = expression;
}
// Get methods
public boolean isThereExists()
{
return thereExists;
}
/**
* Get a string ""<<>>"" or "[[]]" indicating type of quantification.
*/
public String getOperatorString()
{
return thereExists ? "<<>>" : "[[]]";
}
public List<String> getCoalition()
{
return coalition;
}
public Expression getExpression()
{
return expression;
}
// Methods required for Expression:
@Override
public boolean isConstant()
{
return false;
}
@Override
public boolean isProposition()
{
return false;
}
@Override
public Object evaluate(EvaluateContext ec) throws PrismLangException
{
throw new PrismLangException("Cannot evaluate a " + getOperatorString() + " operator without a model");
}
@Override
public String getResultName()
{
return expression.getResultName();
}
@Override
public boolean returnsSingleValue()
{
return false;
}
// Methods required for ASTElement:
@Override
public Object accept(ASTVisitor v) throws PrismLangException
{
return v.visit(this);
}
@Override
public String toString()
{
String s = "";
s += (thereExists ? "<<" : "[[");
s += PrismUtils.joinString(coalition, ",");
s += (thereExists ? ">>" : "]]");
s += " " + expression.toString();
return s;
}
@Override
public Expression deepCopy()
{
ExpressionStrategy expr = new ExpressionStrategy();
expr.setThereExists(isThereExists());
expr.setCoalition(new ArrayList<String>(coalition));
expr.setExpression(expression == null ? null : expression.deepCopy());
expr.setType(type);
expr.setPosition(this);
return expr;
}
}

10
prism/src/parser/visitor/ASTTraverse.java

@ -542,6 +542,16 @@ public class ASTTraverse implements ASTVisitor
}
public void visitPost(ExpressionForAll e) throws PrismLangException { defaultVisitPost(e); }
// -----------------------------------------------------------------------------------
public void visitPre(ExpressionStrategy e) throws PrismLangException { defaultVisitPre(e); }
public Object visit(ExpressionStrategy e) throws PrismLangException
{
visitPre(e);
if (e.getExpression() != null) e.getExpression().accept(this);
visitPost(e);
return null;
}
public void visitPost(ExpressionStrategy e) throws PrismLangException { defaultVisitPost(e); }
// -----------------------------------------------------------------------------------
public void visitPre(ExpressionLabel e) throws PrismLangException { defaultVisitPre(e); }
public Object visit(ExpressionLabel e) throws PrismLangException
{

10
prism/src/parser/visitor/ASTTraverseModify.java

@ -555,6 +555,16 @@ public class ASTTraverseModify implements ASTVisitor
}
public void visitPost(ExpressionForAll e) throws PrismLangException { defaultVisitPost(e); }
// -----------------------------------------------------------------------------------
public void visitPre(ExpressionStrategy e) throws PrismLangException { defaultVisitPre(e); }
public Object visit(ExpressionStrategy e) throws PrismLangException
{
visitPre(e);
if (e.getExpression() != null) e.setExpression((Expression)(e.getExpression().accept(this)));
visitPost(e);
return e;
}
public void visitPost(ExpressionStrategy e) throws PrismLangException { defaultVisitPost(e); }
// -----------------------------------------------------------------------------------
public void visitPre(ExpressionLabel e) throws PrismLangException { defaultVisitPre(e); }
public Object visit(ExpressionLabel e) throws PrismLangException
{

1
prism/src/parser/visitor/ASTVisitor.java

@ -76,6 +76,7 @@ public interface ASTVisitor
public Object visit(ExpressionSS e) throws PrismLangException;
public Object visit(ExpressionExists e) throws PrismLangException;
public Object visit(ExpressionForAll e) throws PrismLangException;
public Object visit(ExpressionStrategy e) throws PrismLangException;
public Object visit(ExpressionLabel e) throws PrismLangException;
public Object visit(ExpressionProp e) throws PrismLangException;
public Object visit(ExpressionFilter e) throws PrismLangException;

6
prism/src/parser/visitor/CheckValid.java

@ -116,4 +116,10 @@ public class CheckValid extends ASTTraverse
/*if (modelType.nondeterministic() && e.getRelOp() == RelOp.EQ)
throw new PrismLangException("Can't use \"S=?\" for nondeterministic models; use \"Smin=?\" or \"Smax=?\"");*/
}
public void visitPost(ExpressionStrategy e) throws PrismLangException
{
if (!modelType.nondeterministic())
throw new PrismLangException("The " + e.getOperatorString() + " operator is only meaningful for models with nondeterminism");
}
}

7
prism/src/parser/visitor/Rename.java

@ -147,5 +147,12 @@ public class Rename extends ASTTraverseModify
// at the level of an individual module (and below)
throw new PrismLangException("A operator should never be renamed");
}
public void visitPost(ExpressionStrategy e) throws PrismLangException
{
// This renaming is only designed to be applied
// at the level of an individual module (and below)
throw new PrismLangException(e.getOperatorString() + " operator should never be renamed");
}
}

5
prism/src/parser/visitor/TypeCheck.java

@ -557,6 +557,11 @@ public class TypeCheck extends ASTTraverse
e.setType(TypeBool.getInstance());
}
public void visitPost(ExpressionStrategy e) throws PrismLangException
{
e.setType(e.getExpression().getType());
}
public void visitPost(ExpressionLabel e) throws PrismLangException
{
e.setType(TypeBool.getInstance());

Loading…
Cancel
Save