Browse Source

Add getAllLabels method to ASTElement (not used currently).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@7243 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 13 years ago
parent
commit
a73b36685b
  1. 12
      prism/src/parser/ast/ASTElement.java
  2. 53
      prism/src/parser/visitor/GetAllLabels.java

12
prism/src/parser/ast/ASTElement.java

@ -337,6 +337,18 @@ public abstract class ASTElement
return evaluatePartially(new EvaluateContextValues(null, varValues));
}
/**
* Get all labels (i.e. ExpressionLabel objects), store names in set.
* Special labels "deadlock", "init" *are* included in the list.
*/
public Vector<String> getAllLabels() throws PrismLangException
{
Vector<String> v = new Vector<String>();
GetAllLabels visitor = new GetAllLabels(v);
accept(visitor);
return v;
}
/**
* Expand labels, return result.
* Special labels "deadlock", "init" and any not in list are left.

53
prism/src/parser/visitor/GetAllLabels.java

@ -0,0 +1,53 @@
//==============================================================================
//
// 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.visitor;
import java.util.Vector;
import parser.ast.*;
import prism.PrismLangException;
/**
* Get all variables (i.e. ExpressionVar objects), store names in set.
*/
public class GetAllLabels extends ASTTraverse
{
private Vector<String> v;
public GetAllLabels(Vector<String> v)
{
this.v = v;
}
public void visitPost(ExpressionLabel e) throws PrismLangException
{
if (!v.contains(e.getName())) {
v.addElement(e.getName());
}
}
}
Loading…
Cancel
Save