org.overturetool.vdmj.patterns
Class Pattern

java.lang.Object
  extended by org.overturetool.vdmj.patterns.Pattern
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BooleanPattern, CharacterPattern, ConcatenationPattern, ExpressionPattern, IdentifierPattern, IgnorePattern, IntegerPattern, QuotePattern, RealPattern, RecordPattern, SeqPattern, SetPattern, StringPattern, TuplePattern, UnionPattern

public abstract class Pattern
extends java.lang.Object
implements java.io.Serializable

The parent type of all patterns.

See Also:
Serialized Form

Field Summary
 LexLocation location
          The textual location of the pattern.
 
Constructor Summary
Pattern(LexLocation location)
          Create a pattern at the given location.
 
Method Summary
 void detail(java.lang.String tag, java.lang.Object obj)
           
 void detail2(java.lang.String tag1, java.lang.Object obj1, java.lang.String tag2, java.lang.Object obj2)
           
abstract  DefinitionList getDefinitions(Type type, NameScope scope)
          Get a list of definitions for the pattern's variables.
 int getLength()
           
abstract  Expression getMatchingExpression()
          An expression that matches the pattern.
abstract  NameValuePairList getNamedValues(Value expval, Context ctxt)
          Get a name/value pair list for the pattern's variables.
abstract  Type getPossibleType()
          Get the type(s) that could match this pattern.
 LexNameList getVariableNames()
           
 boolean isConstrained()
           
 void patternFail(int number, java.lang.String msg)
          Throw a PatternMatchException with the given message.
 Value patternFail(ValueException ve)
          Throw a PatternMatchException with a message from the ValueException.
 void report(int number, java.lang.String msg)
           
abstract  java.lang.String toString()
           
 void typeResolve(Environment env)
          Resolve any types that the pattern may use by looking up the type names in the environment passed.
 void unResolve()
          Clear the recursive type resolution flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

location

public final LexLocation location
The textual location of the pattern.

Constructor Detail

Pattern

public Pattern(LexLocation location)
Create a pattern at the given location.

Method Detail

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object

typeResolve

public void typeResolve(Environment env)
Resolve any types that the pattern may use by looking up the type names in the environment passed.

Parameters:
env - The environment to resolve types.

unResolve

public void unResolve()
Clear the recursive type resolution flag. This is a deep clear, used when recovering from type resolution errors.


getDefinitions

public abstract DefinitionList getDefinitions(Type type,
                                              NameScope scope)
Get a list of definitions for the pattern's variables.


getNamedValues

public abstract NameValuePairList getNamedValues(Value expval,
                                                 Context ctxt)
                                          throws PatternMatchException
Get a name/value pair list for the pattern's variables.

Throws:
PatternMatchException

getPossibleType

public abstract Type getPossibleType()
Get the type(s) that could match this pattern.


getVariableNames

public LexNameList getVariableNames()
Returns:
A list of the pattern's variable names.

getLength

public int getLength()
Returns:
The "length" of the pattern (eg. sequence and set patterns).

isConstrained

public boolean isConstrained()
Returns:
True if the pattern has constraints, such that matching values should be permuted, where necessary, to find a match.

getMatchingExpression

public abstract Expression getMatchingExpression()
An expression that matches the pattern. This is used in PO generation when parameter patterns have to be passed to pre/post conditions as arguments. The result is almost the same as toString(), except for IgnorePatterns, which produce "don't care" variables.

Returns:
An expression, being a value that matches the pattern.

report

public void report(int number,
                   java.lang.String msg)
See Also:
Definition.report(int, java.lang.String)

patternFail

public void patternFail(int number,
                        java.lang.String msg)
                 throws PatternMatchException
Throw a PatternMatchException with the given message.

Throws:
PatternMatchException

patternFail

public Value patternFail(ValueException ve)
                  throws PatternMatchException
Throw a PatternMatchException with a message from the ValueException.

Throws:
PatternMatchException

detail

public void detail(java.lang.String tag,
                   java.lang.Object obj)
See Also:
Definition.detail(java.lang.String, java.lang.Object)

detail2

public void detail2(java.lang.String tag1,
                    java.lang.Object obj1,
                    java.lang.String tag2,
                    java.lang.Object obj2)
See Also:
Definition.detail2(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object)


Copyright © 2009. All Rights Reserved.