Browse Source
Improved handling of undefined constants in properties files:
Improved handling of undefined constants in properties files:
* don't need to provide values for all constants, just those required for model checking And a few related bug fixes: * in error handling for constants in PrismCL * in export of labels from properties file with constants And some small related API changes: * don't need to call setUndefinedConstants on ModulesFile/PropertiesFile if there are no undefined constants * more flexible UndefinedConstants classes git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3319 bbc10eb1-c90d-0410-af57-cb519fbb1720master
12 changed files with 427 additions and 113 deletions
-
17prism/src/parser/ast/ASTElement.java
-
101prism/src/parser/ast/ConstantList.java
-
21prism/src/parser/ast/ModulesFile.java
-
98prism/src/parser/ast/PropertiesFile.java
-
81prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java
-
6prism/src/prism/Prism.java
-
67prism/src/prism/PrismCL.java
-
5prism/src/prism/ResultsCollection.java
-
119prism/src/prism/UndefinedConstants.java
-
2prism/src/userinterface/properties/GUIExperiment.java
-
17prism/src/userinterface/properties/GUIMultiProperties.java
-
6prism/src/userinterface/simulator/GUISimulator.java
@ -0,0 +1,81 @@ |
|||
//============================================================================== |
|||
// |
|||
// Copyright (c) 2002- |
|||
// Authors: |
|||
// * Dave Parker <david.parker@comlab.ox.ac.uk> (University of Oxford, formerly University of Birmingham) |
|||
// |
|||
//------------------------------------------------------------------------------ |
|||
// |
|||
// 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.visitor; |
|||
|
|||
import java.util.Vector; |
|||
|
|||
import parser.ast.*; |
|||
import prism.PrismLangException; |
|||
|
|||
/** |
|||
* Get all undefined constants used (i.e. in ExpressionConstant objects) recursively and return as a list. |
|||
* Recursive decent means that we find e.g. constants that are used within other constants, labels. |
|||
*/ |
|||
public class GetAllUndefinedConstantsRecursively extends ASTTraverse |
|||
{ |
|||
private Vector<String> v; |
|||
private ConstantList constantList; |
|||
private LabelList labelList; |
|||
|
|||
public GetAllUndefinedConstantsRecursively(Vector<String> v, ConstantList constantList, LabelList labelList) |
|||
{ |
|||
this.v = v; |
|||
this.constantList = constantList; |
|||
this.labelList = labelList; |
|||
} |
|||
|
|||
public void visitPost(ExpressionConstant e) throws PrismLangException |
|||
{ |
|||
// Look up this constant in the constant list |
|||
int i = constantList.getConstantIndex(e.getName()); |
|||
if (i == -1) |
|||
throw new PrismLangException("Unknown constant \"" + e.getName() + "\""); |
|||
Expression expr = constantList.getConstant(i); |
|||
// If constant is undefined, add to the list |
|||
if (expr == null) { |
|||
if (!v.contains(e.getName())) { |
|||
v.addElement(e.getName()); |
|||
} |
|||
} |
|||
// If not, check constant definition recursively for more undefined constants |
|||
else { |
|||
expr.accept(this); |
|||
} |
|||
} |
|||
|
|||
public void visitPost(ExpressionLabel e) throws PrismLangException |
|||
{ |
|||
// Look up this label in the label list |
|||
int i = labelList.getLabelIndex(e.getName()); |
|||
if (i == -1) |
|||
throw new PrismLangException("Unknown label \"" + e.getName() + "\""); |
|||
Expression expr = labelList.getLabel(i); |
|||
// Check label definition recursively for more undefined constants |
|||
expr.accept(this); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue