Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.5 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

PerCederberg.Grammatica.Runtime
Class ProductionPatternAlternative

System.Object
   |
   +--ProductionPatternAlternative

   in ProductionPatternAlternative.cs

public class ProductionPatternAlternative
extends System.Object

A production pattern alternative. This class represents a list of production pattern elements. In order to provide productions that cannot be represented with the element occurance counters, multiple alternatives must be created and added to the same production pattern. A production pattern alternative is always contained within a production pattern.


Field Summary
 int Count
          The production pattern element count property (read-only).
 internal LookAheadSet LookAhead
          The look-ahead set property.
 ProductionPattern Pattern
          The production pattern property (read-only).
 ProductionPatternElement[ int index ] this
          The production pattern element index (read-only).
 
Constructor Summary
ProductionPatternAlternative()
          Creates a new production pattern alternative.
 
Method Summary
 void AddElement( ProductionPatternElement elem )
          Adds a production pattern element to this alternative.
 void AddElement( ProductionPatternElement elem, int min, int max )
          Adds a production pattern element to this alternative.
 void AddProduction( int id, int min, int max )
          Adds a production to this alternative.
 void AddToken( int id, int min, int max )
          Adds a token to this alternative.
 override bool Equals( object obj )
          Checks if this object is equal to another.
 bool Equals( ProductionPatternAlternative alt )
          Checks if this alternative is equal to another.
 ProductionPatternElement GetElement( int pos )
          Deprecated. Use the class indexer instead.
 int GetElementCount()
          Deprecated. Use the Count property instead.
 override int GetHashCode()
          Returns a hash code for this object.
 int GetMaxElementCount()
          Returns the maximum number of elements needed to satisfy this alternative.
 int GetMinElementCount()
          Returns the minimum number of elements needed to satisfy this alternative.
 ProductionPattern GetPattern()
          Deprecated. Use the Pattern property instead.
 bool IsLeftRecursive()
          Checks if this alternative is recursive on the left-hand side.
 bool IsMatchingEmpty()
          Checks if this alternative would match an empty stream of tokens.
 bool IsRightRecursive()
          Checks if this alternative is recursive on the right-hand side.
 internal void SetPattern( ProductionPattern pattern )
          Changes the production pattern containing this alternative.
 override string ToString()
          Returns a string representation of this object.
 

Field Detail

Count

public int Count;
The production pattern element count property (read-only).
Since:
1.5

LookAhead

 internal LookAheadSet LookAhead;
The look-ahead set property. This property contains the look-ahead set associated with this alternative.

Pattern

public ProductionPattern Pattern;
The production pattern property (read-only). This property contains the pattern having this alternative.
Since:
1.5

this

public ProductionPatternElement this[ int index ];
The production pattern element index (read-only).
Parameters:
index - the element index, 0 <= pos < Count
Returns:
the element found
Since:
1.5


Constructor Detail

ProductionPatternAlternative

public ProductionPatternAlternative();
Creates a new production pattern alternative.


Method Detail

AddElement

public void AddElement( ProductionPatternElement elem );
Adds a production pattern element to this alternative. The element is appended to the end of the element list.
Parameters:
elem - the production pattern element

AddElement

public void AddElement( ProductionPatternElement elem, int min, int max );
Adds a production pattern element to this alternative. The multiplicity values in the element will be overridden with the specified values. The element is appended to the end of the element list.
Parameters:
elem - the production pattern element
min - the minimum number of occurancies
max - the maximum number of occurancies, or -1 for infinite

AddProduction

public void AddProduction( int id, int min, int max );
Adds a production to this alternative. The production is appended to the end of the element list. The multiplicity values specified define if the production is optional or required, and if it can be repeated.
Parameters:
id - the production (pattern) id
min - the minimum number of occurancies
max - the maximum number of occurancies, or -1 for infinite

AddToken

public void AddToken( int id, int min, int max );
Adds a token to this alternative. The token is appended to the end of the element list. The multiplicity values specified define if the token is optional or required, and if it can be repeated.
Parameters:
id - the token (pattern) id
min - the minimum number of occurancies
max - the maximum number of occurancies, or -1 for infinite

Equals

public override bool Equals( object obj );
Checks if this object is equal to another. This method only returns true for another production pattern alternative with identical elements in the same order.
Parameters:
obj - the object to compare with
Returns:
true if the object is identical to this one, or false otherwise

Equals

public bool Equals( ProductionPatternAlternative alt );
Checks if this alternative is equal to another. This method returns true if the other production pattern alternative has identical elements in the same order.
Parameters:
alt - the alternative to compare with
Returns:
true if the object is identical to this one, or false otherwise

GetElement

public ProductionPatternElement GetElement( int pos );
Deprecated. Use the class indexer instead.

Returns an element in this alternative.

Parameters:
pos - the element position, 0 <= pos < count
Returns:
the element found

GetElementCount

public int GetElementCount();
Deprecated. Use the Count property instead.

Returns the number of elements in this alternative.

Returns:
the number of elements in this alternative
See Also:
Count

GetHashCode

public override int GetHashCode();
Returns a hash code for this object.
Returns:
a hash code for this object

GetMaxElementCount

public int GetMaxElementCount();
Returns the maximum number of elements needed to satisfy this alternative. The value returned is the sum of all the elements maximum count.
Returns:
the maximum number of elements

GetMinElementCount

public int GetMinElementCount();
Returns the minimum number of elements needed to satisfy this alternative. The value returned is the sum of all the elements minimum count.
Returns:
the minimum number of elements

GetPattern

public ProductionPattern GetPattern();
Deprecated. Use the Pattern property instead.

Returns the production pattern containing this alternative.

Returns:
the production pattern for this alternative
See Also:
Pattern

IsLeftRecursive

public bool IsLeftRecursive();
Checks if this alternative is recursive on the left-hand side. This method checks all the possible left side elements and returns true if the pattern itself is among them.
Returns:
true if the alternative is left side recursive, or false otherwise

IsMatchingEmpty

public bool IsMatchingEmpty();
Checks if this alternative would match an empty stream of tokens. This check is equivalent of getMinElementCount() returning zero (0).
Returns:
true if the rule can match an empty token stream, or false otherwise

IsRightRecursive

public bool IsRightRecursive();
Checks if this alternative is recursive on the right-hand side. This method checks all the possible right side elements and returns true if the pattern itself is among them.
Returns:
true if the alternative is right side recursive, or false otherwise

SetPattern

 internal void SetPattern( ProductionPattern pattern );
Changes the production pattern containing this alternative. This method should only be called by the production pattern class.
Parameters:
pattern - the new production pattern

ToString

public override string ToString();
Returns a string representation of this object.
Returns:
a token string representation

 Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.5 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD