fmrisc.Syntax
Class ASTUtil

java.lang.Object
  extended by fmrisc.Syntax.ASTUtil

public final class ASTUtil
extends java.lang.Object

Collect state related to handling of abstract syntax trees.


Constructor Summary
ASTUtil()
           
 
Method Summary
static java.lang.String canonicalText(AST exp)
          get canonical text of expression (variable names replaced by numbers).
static java.lang.String getBaseName(java.lang.String name)
          Get base name from name.
static boolean getPrintParens()
          show whether every (sub)expression is to be printed with enclosing parentheses
static boolean getPrintUnique()
          show whether every identifier is printed with its unique name
static boolean getPrintVarNumber()
          show whether every local variable is printed with its variable number
static java.lang.String getUniqueName(java.lang.String name)
          Create unique identifier name from given name.
static int getVarNumber()
          get current variable number for printing
static int incVarNumber()
          increase the current variable number for printing by one
static void setPrintParens(boolean flag)
          signal whether every (sub)expression is to be printed with enclosing parentheses
static void setPrintUnique(boolean flag)
          signal whether every identifier is printed with its unique name
static void setPrintVarNumber(boolean flag)
          signal whether every identifier is printed with its variable number
static void setVarNumber(int varNumber)
          set the current variable number for printing
static Expression toConjunction(Expression[] formulas)
          Construct conjunction of sequence of formulas.
static Declaration[] toDeclarationArray(java.util.Vector v)
          converts vector v of Declaration objects to Declaration array
static Expression toDisjunction(Expression[] formulas)
          Construct disjunction of sequence of formulas.
static Expression[] toExpressionArray(java.util.Vector v)
          converts vector v of Expression objects to Expression array
static Reference[] toReferenceArray(java.util.Vector v)
          converts vector v of Reference objects toarray
static Selector[] toSelectorArray(java.util.Vector v)
          converts vector v of Selector objects to Selector array
static java.lang.String[] toStringArray(java.util.Vector v)
          converts vector v of String objects to String array
static Type[] toTypeArray(java.util.Vector v)
          converts vector v of Type objects to Type array
static TypeDeclaration[] toTypeDeclarationArray(java.util.Vector v)
          converts vector v of TypeDeclaration objects to TypeDeclaration array
static TypedIdentifier[] toTypedIdentifierArray(java.util.Vector v)
          converts vector v of TypedIdentifer objects to TypedIdentifier array
static ValueDeclaration[] toValueDeclarationArray(java.util.Vector v)
          converts vector v of ValueDeclaration objects to ValueDeclaration array
static ValuedIdentifier[] toValuedIdentifierArray(java.util.Vector v)
          converts vector v of ValuedIdentifer objects to ValuedIdentifier array
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASTUtil

public ASTUtil()
Method Detail

setPrintParens

public static void setPrintParens(boolean flag)
signal whether every (sub)expression is to be printed with enclosing parentheses

Parameters:
flag - true iff enclosing parenthesis are to be printed

getPrintParens

public static boolean getPrintParens()
show whether every (sub)expression is to be printed with enclosing parentheses

Returns:
true iff enclosing parenthesis are to be printed

setPrintUnique

public static void setPrintUnique(boolean flag)
signal whether every identifier is printed with its unique name

Parameters:
flag - true iff unique name is to be printed

getPrintUnique

public static boolean getPrintUnique()
show whether every identifier is printed with its unique name

Returns:
true iff unique name is printed

setPrintVarNumber

public static void setPrintVarNumber(boolean flag)
signal whether every identifier is printed with its variable number

Parameters:
flag - true iff variable number is to be printed

getPrintVarNumber

public static boolean getPrintVarNumber()
show whether every local variable is printed with its variable number

Returns:
true iff variable number is printed

setVarNumber

public static void setVarNumber(int varNumber)
set the current variable number for printing

Parameters:
varNumber - the variable number

incVarNumber

public static int incVarNumber()
increase the current variable number for printing by one

Returns:
the old variable number

getVarNumber

public static int getVarNumber()
get current variable number for printing

Returns:
the variable number

toStringArray

public static java.lang.String[] toStringArray(java.util.Vector v)
converts vector v of String objects to String array

Parameters:
v - a vector holding String objects
Returns:
an array holding these objects

toReferenceArray

public static Reference[] toReferenceArray(java.util.Vector v)
converts vector v of Reference objects toarray

Parameters:
v - a vector holding Reference objects
Returns:
an array holding these objects

toDeclarationArray

public static Declaration[] toDeclarationArray(java.util.Vector v)
converts vector v of Declaration objects to Declaration array

Parameters:
v - a vector holding Declaration objects
Returns:
an array holding these objects

toValueDeclarationArray

public static ValueDeclaration[] toValueDeclarationArray(java.util.Vector v)
converts vector v of ValueDeclaration objects to ValueDeclaration array

Parameters:
v - a vector holding ValueDeclaration objects
Returns:
an array holding these objects

toTypeDeclarationArray

public static TypeDeclaration[] toTypeDeclarationArray(java.util.Vector v)
converts vector v of TypeDeclaration objects to TypeDeclaration array

Parameters:
v - a vector holding TypeDeclaration objects
Returns:
an array holding these objects

toTypeArray

public static Type[] toTypeArray(java.util.Vector v)
converts vector v of Type objects to Type array

Parameters:
v - a vector holding AST objects
Returns:
an array holding these objects

toExpressionArray

public static Expression[] toExpressionArray(java.util.Vector v)
converts vector v of Expression objects to Expression array

Parameters:
v - a vector holding Expression objects
Returns:
an array holding these objects

toSelectorArray

public static Selector[] toSelectorArray(java.util.Vector v)
converts vector v of Selector objects to Selector array

Parameters:
v - a vector holding Selector objects
Returns:
an array holding these objects

toTypedIdentifierArray

public static TypedIdentifier[] toTypedIdentifierArray(java.util.Vector v)
converts vector v of TypedIdentifer objects to TypedIdentifier array

Parameters:
v - a vector holding TypedIdentifier objects
Returns:
an array holding these objects

toValuedIdentifierArray

public static ValuedIdentifier[] toValuedIdentifierArray(java.util.Vector v)
converts vector v of ValuedIdentifer objects to ValuedIdentifier array

Parameters:
v - a vector holding ValuedIdentifier objects
Returns:
an array holding these objects

getUniqueName

public static java.lang.String getUniqueName(java.lang.String name)
Create unique identifier name from given name.

Parameters:
name - of an identifier
Returns:
a unique version of name not in use anywhere else as a unique id.

getBaseName

public static java.lang.String getBaseName(java.lang.String name)
Get base name from name.

Parameters:
name - a name (possible unique as returned by getUniqueName()).
Returns:
the original base name (which may be the name itself).

canonicalText

public static java.lang.String canonicalText(AST exp)
get canonical text of expression (variable names replaced by numbers).

Returns:
the canonical text of expression

toConjunction

public static Expression toConjunction(Expression[] formulas)
Construct conjunction of sequence of formulas.

Parameters:
formulas - a sequence of formulas.
Returns:
the conjunction of these formulas.

toDisjunction

public static Expression toDisjunction(Expression[] formulas)
Construct disjunction of sequence of formulas.

Parameters:
formulas - a sequence of formulas.
Returns:
the disjunction of these formulas.