net.percederberg.grammatica.parser
Class Production

java.lang.Object
  |
  +--net.percederberg.grammatica.parser.Node
        |
        +--net.percederberg.grammatica.parser.Production

public class Production
extends Node

A production node. This class represents a grammar production (i.e. a list of child nodes) in a parse tree. The productions are created by a parser, that adds children a according to a set of production patterns (i.e. grammar rules).

Version:
1.0
Author:
Per Cederberg,

Constructor Summary
Production(ProductionPattern pattern)
          Creates a new production node.
 
Method Summary
 void addChild(Node child)
          Adds a child node.
 Node getChildAt(int index)
          Returns the child node with the specified index.
 int getChildCount()
          Returns the number of child nodes.
 int getId()
          Returns the production (pattern) id.
 ProductionPattern getPattern()
          Returns the production pattern for this production.
 java.lang.String toString()
          Returns a string representation of this production.
 
Methods inherited from class net.percederberg.grammatica.parser.Node
addValue, addValues, getAllValues, getParent, getValue, getValueCount, printTo, printTo, removeAllValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Production

public Production(ProductionPattern pattern)
Creates a new production node.

Parameters:
pattern - the production pattern
Method Detail

getPattern

public ProductionPattern getPattern()
Returns the production pattern for this production.

Returns:
the production pattern

getId

public int getId()
Returns the production (pattern) id. This value is set as a unique identifier when creating the production pattern to simplify later identification.

Specified by:
getId in class Node
Returns:
the production id

getChildCount

public int getChildCount()
Returns the number of child nodes.

Overrides:
getChildCount in class Node
Returns:
the number of child nodes

getChildAt

public Node getChildAt(int index)
Returns the child node with the specified index.

Overrides:
getChildAt in class Node
Parameters:
index - the child index, 0 <= index < count
Returns:
the child node found, or null if index out of bounds

addChild

public void addChild(Node child)
Adds a child node. The node will be added last in the list of children.

Parameters:
child - the child node to add

toString

public java.lang.String toString()
Returns a string representation of this production.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this production