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

PerCederberg.Grammatica.Parser
Class ProductionPattern

System.Object
   |
   +--ProductionPattern

   in ProductionPattern.cs

class ProductionPattern
extends System.Object

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.


Constructor Summary
ProductionPattern( int id, string name )
          Creates a new production pattern.
 
Method Summary
 void AddAlternative( ProductionPatternAlternative alt )
          Adds a production pattern alternative.
 ProductionPatternAlternative GetAlternative( int pos )
          Returns an alternative in this pattern.
 int GetAlternativeCount()
          Returns the number of alternatives in this pattern.
 internal ProductionPatternAlternative GetDefaultAlternative()
          Returns the default pattern alternative.
 int GetId()
          Returns the unique production pattern identity value.
 internal LookAheadSet GetLookAhead()
          Returns the look-ahead set associated with this alternative.
 string GetName()
          Returns the production pattern name.
 bool IsLeftRecursive()
          Checks if this pattern is recursive on the left-hand side.
 bool IsMatchingEmpty()
          Checks if this pattern would match an empty stream of tokens.
 bool IsRightRecursive()
          Checks if this pattern is recursive on the right-hand side.
 bool IsSyntetic()
          Checks if the syntetic production flag is set.
 internal void SetDefaultAlternative( int pos )
          Sets the default pattern alternative.
 internal void SetLookAhead( LookAheadSet lookAhead )
          Sets the look-ahead set for this alternative.
 void SetSyntetic( bool syntetic )
          Sets the syntetic production pattern flag.
 override string ToString()
          Returns a string representation of this object.
 

Constructor Detail

ProductionPattern

public ProductionPattern( int id, string name );
Creates a new production pattern.
Parameters:
id - the production pattern id
name - the production pattern name


Method Detail

AddAlternative

public void AddAlternative( ProductionPatternAlternative alt );
Adds a production pattern alternative.
Parameters:
alt - the production pattern alternative to add
Throws:
ParserCreationException - if an identical alternative has already been added

GetAlternative

public ProductionPatternAlternative GetAlternative( int pos );
Returns an alternative in this pattern.
Parameters:
pos - the alternative position, 0 <= pos < count
Returns:
the alternative found

GetAlternativeCount

public int GetAlternativeCount();
Returns the number of alternatives in this pattern.
Returns:
the number of alternatives in this pattern

GetDefaultAlternative

 internal ProductionPatternAlternative GetDefaultAlternative();
Returns the default pattern alternative. The default alternative is used when no other alternative matches.
Returns:
the default pattern alternative, or null if none has been set

GetId

public int GetId();
Returns the unique production pattern identity value.
Returns:
the production pattern id

GetLookAhead

 internal LookAheadSet GetLookAhead();
Returns the look-ahead set associated with this alternative.
Returns:
the look-ahead set associated with this alternative

GetName

public string GetName();
Returns the production pattern name.
Returns:
the production pattern name

IsLeftRecursive

public bool IsLeftRecursive();
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

IsMatchingEmpty

public bool IsMatchingEmpty();
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

IsRightRecursive

public bool IsRightRecursive();
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

IsSyntetic

public bool IsSyntetic();
Checks if the syntetic 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 syntetic, or false otherwise

SetDefaultAlternative

 internal void SetDefaultAlternative( int pos );
Sets the default pattern alternative. The default alternative is used when no other alternative matches.
Parameters:
pos - the position of the default alternative

SetLookAhead

 internal void SetLookAhead( LookAheadSet lookAhead );
Sets the look-ahead set for this alternative.
Parameters:
lookAhead - the new look-ahead set

SetSyntetic

public void SetSyntetic( bool syntetic );
Sets the syntetic 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:
syntetic - the new value of the syntetic flag

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.4 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD