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

A production pattern. More...

Public Member Functions

 ProductionPattern (int id, string name)
 Creates a new production pattern. More...
 
int GetId ()
 Returns the unique production pattern identity value. More...
 
string GetName ()
 Returns the production pattern name. More...
 
bool IsSyntetic ()
 Checks if the synthetic production flag is set. More...
 
void SetSyntetic (bool synthetic)
 Sets the synthetic production pattern flag. More...
 
int GetAlternativeCount ()
 Returns the number of alternatives in this pattern. More...
 
ProductionPatternAlternative GetAlternative (int pos)
 Returns an alternative in this pattern. More...
 
bool IsLeftRecursive ()
 Checks if this pattern is recursive on the left-hand side. More...
 
bool IsRightRecursive ()
 Checks if this pattern is recursive on the right-hand side. More...
 
bool IsMatchingEmpty ()
 Checks if this pattern would match an empty stream of tokens. More...
 
void AddAlternative (ProductionPatternAlternative alt)
 Adds a production pattern alternative. More...
 
override string ToString ()
 Returns a string representation of this object. More...
 

Properties

int Id [get]
 The production pattern identity property (read-only). More...
 
string Name [get]
 The production pattern name property (read-only). More...
 
bool Synthetic [get, set]
 The synthetic production pattern property. More...
 
int Count [get]
 The production pattern alternative count property (read-only). More...
 
ProductionPatternAlternative this[int index] [get]
 The production pattern alternative index (read-only). More...
 

Detailed Description

A production pattern.

This class represents a set of production alternatives that together forms a single production. A production pattern is identified by an integer id and a name, both provided upon creation. The pattern id is used for referencing the production pattern from production pattern elements.

Author
Per Cederberg
Version
1.5

Constructor & Destructor Documentation

PerCederberg.Grammatica.Runtime.ProductionPattern.ProductionPattern ( int  id,
string  name 
)
inline

Creates a new production pattern.

Parameters
idthe production pattern id
namethe production pattern name

Member Function Documentation

void PerCederberg.Grammatica.Runtime.ProductionPattern.AddAlternative ( ProductionPatternAlternative  alt)
inline

Adds a production pattern alternative.

Parameters
altthe production pattern alternative to add
Exceptions
ParserCreationExceptionif an identical alternative has already been added
ProductionPatternAlternative PerCederberg.Grammatica.Runtime.ProductionPattern.GetAlternative ( int  pos)
inline

Returns an alternative in this pattern.

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

Returns the number of alternatives in this pattern.

Returns
the number of alternatives in this pattern
See also
Count
Deprecated:
Use the Count property instead.
int PerCederberg.Grammatica.Runtime.ProductionPattern.GetId ( )
inline

Returns the unique production pattern identity value.

Returns
the production pattern id
See also
Id
Deprecated:
Use the Id property instead.
string PerCederberg.Grammatica.Runtime.ProductionPattern.GetName ( )
inline

Returns the production pattern name.

Returns
the production pattern name
See also
Name
Deprecated:
Use the Name property instead.
bool PerCederberg.Grammatica.Runtime.ProductionPattern.IsLeftRecursive ( )
inline

Checks if this pattern is recursive on the left-hand side.

This method checks if any of the production pattern alternatives is left-recursive.

Returns
true if at least one alternative is left recursive, or false otherwise
bool PerCederberg.Grammatica.Runtime.ProductionPattern.IsMatchingEmpty ( )
inline

Checks if this pattern would match an empty stream of tokens.

This method checks if any one of the production pattern alternatives would match the empty token stream.

Returns
true if at least one alternative match no tokens, or false otherwise
bool PerCederberg.Grammatica.Runtime.ProductionPattern.IsRightRecursive ( )
inline

Checks if this pattern is recursive on the right-hand side.

This method checks if any of the production pattern alternatives is right-recursive.

Returns
true if at least one alternative is right recursive, or false otherwise
bool PerCederberg.Grammatica.Runtime.ProductionPattern.IsSyntetic ( )
inline

Checks if the synthetic production flag is set.

If this flag is set, the production identified by this pattern has been artificially inserted into the grammar. No parse tree nodes will be created for such nodes, instead the child nodes will be added directly to the parent node.

Returns
true if this production pattern is synthetic, or false otherwise
See also
Synthetic
Deprecated:
Use the Synthetic property instead.
void PerCederberg.Grammatica.Runtime.ProductionPattern.SetSyntetic ( bool  synthetic)
inline

Sets the synthetic production pattern flag.

If this flag is set, the production identified by this pattern has been artificially inserted into the grammar. By default this flag is set to false.

Parameters
synteticthe new value of the synthetic flag
See also
Synthetic
Deprecated:
Use the Synthetic property instead.
override string PerCederberg.Grammatica.Runtime.ProductionPattern.ToString ( )
inline

Returns a string representation of this object.

Returns
a token string representation

Property Documentation

int PerCederberg.Grammatica.Runtime.ProductionPattern.Count
get

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

Since
1.5
int PerCederberg.Grammatica.Runtime.ProductionPattern.Id
get

The production pattern identity property (read-only).

This property contains the unique identity value.

Since
1.5
string PerCederberg.Grammatica.Runtime.ProductionPattern.Name
get

The production pattern name property (read-only).

Since
1.5
bool PerCederberg.Grammatica.Runtime.ProductionPattern.Synthetic
getset

The synthetic production pattern property.

If this property is set, the production identified by this pattern has been artificially inserted into the grammar. No parse tree nodes will be created for such nodes, instead the child nodes will be added directly to the parent node. By default this property is set to false.

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

The production pattern alternative index (read-only).

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

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