Grammatica
Public Member Functions | Properties | List of all members
PerCederberg.Grammatica.Runtime.ProductionPatternAlternative Class Reference

A production pattern alternative. More...

Public Member Functions

 ProductionPatternAlternative ()
 Creates a new production pattern alternative.
 
ProductionPattern GetPattern ()
 Returns the production pattern containing this alternative. More...
 
int GetElementCount ()
 Returns the number of elements in this alternative. More...
 
ProductionPatternElement GetElement (int pos)
 Returns an element in this alternative. More...
 
bool IsLeftRecursive ()
 Checks if this alternative is recursive on the left-hand side. More...
 
bool IsRightRecursive ()
 Checks if this alternative is recursive on the right-hand side. More...
 
bool IsMatchingEmpty ()
 Checks if this alternative would match an empty stream of tokens. More...
 
int GetMinElementCount ()
 Returns the minimum number of elements needed to satisfy this alternative. More...
 
int GetMaxElementCount ()
 Returns the maximum number of elements needed to satisfy this alternative. More...
 
void AddToken (int id, int min, int max)
 Adds a token to this alternative. More...
 
void AddProduction (int id, int min, int max)
 Adds a production to this alternative. More...
 
void AddElement (ProductionPatternElement elem)
 Adds a production pattern element to this alternative. More...
 
void AddElement (ProductionPatternElement elem, int min, int max)
 Adds a production pattern element to this alternative. More...
 
override bool Equals (object obj)
 Checks if this object is equal to another. More...
 
bool Equals (ProductionPatternAlternative alt)
 Checks if this alternative is equal to another. More...
 
override int GetHashCode ()
 Returns a hash code for this object. More...
 
override string ToString ()
 Returns a string representation of this object. More...
 

Properties

ProductionPattern Pattern [get]
 The production pattern property (read-only). More...
 
int Count [get]
 The production pattern element count property (read-only). More...
 
ProductionPatternElement this[int index] [get]
 The production pattern element index (read-only). More...
 

Detailed Description

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.

Author
Per Cederberg
Version
1.5

Member Function Documentation

void PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.AddElement ( ProductionPatternElement  elem)
inline

Adds a production pattern element to this alternative.

The element is appended to the end of the element list.

Parameters
elemthe production pattern element
void PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.AddElement ( ProductionPatternElement  elem,
int  min,
int  max 
)
inline

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
elemthe production pattern element
minthe minimum number of occurancies
maxthe maximum number of occurancies, or -1 for infinite
void PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.AddProduction ( int  id,
int  min,
int  max 
)
inline

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
idthe production (pattern) id
minthe minimum number of occurancies
maxthe maximum number of occurancies, or -1 for infinite
void PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.AddToken ( int  id,
int  min,
int  max 
)
inline

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
idthe token (pattern) id
minthe minimum number of occurancies
maxthe maximum number of occurancies, or -1 for infinite
override bool PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.Equals ( object  obj)
inline

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
objthe object to compare with
Returns
true if the object is identical to this one, or false otherwise
bool PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.Equals ( ProductionPatternAlternative  alt)
inline

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
altthe alternative to compare with
Returns
true if the object is identical to this one, or false otherwise
ProductionPatternElement PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetElement ( int  pos)
inline

Returns an element in this alternative.

Parameters
posthe element position, 0 <= pos < count
Returns
the element found
Deprecated:
Use the class indexer instead.
int PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetElementCount ( )
inline

Returns the number of elements in this alternative.

Returns
the number of elements in this alternative
See also
Count
Deprecated:
Use the Count property instead.
override int PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetHashCode ( )
inline

Returns a hash code for this object.

Returns
a hash code for this object
int PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetMaxElementCount ( )
inline

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
int PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetMinElementCount ( )
inline

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
ProductionPattern PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.GetPattern ( )
inline

Returns the production pattern containing this alternative.

Returns
the production pattern for this alternative
See also
Pattern
Deprecated:
Use the Pattern property instead.
bool PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.IsLeftRecursive ( )
inline

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
bool PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.IsMatchingEmpty ( )
inline

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
bool PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.IsRightRecursive ( )
inline

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
override string PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.ToString ( )
inline

Returns a string representation of this object.

Returns
a token string representation

Property Documentation

int PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.Count
get

The production pattern element count property (read-only).

Since
1.5
ProductionPattern PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.Pattern
get

The production pattern property (read-only).

This property contains the pattern having this alternative.

Since
1.5
ProductionPatternElement PerCederberg.Grammatica.Runtime.ProductionPatternAlternative.this[int index]
get

The production pattern element index (read-only).

Parameters
indexthe element index, 0 <= pos < Count
Returns
the element found
Since
1.5

The documentation for this class was generated from the following file: