dk.brics.servletvalidator.grammar
Class Production

java.lang.Object
  extended by dk.brics.servletvalidator.grammar.Production
All Implemented Interfaces:
GrammarEntity, Cloneable

public class Production
extends Object
implements GrammarEntity, Cloneable

A single production is a list of AlphabetSymbols that a NonTerminal can derive. A production contains a list of AlphabetSymbol that the production produces. A production belongs to at most one NonTerminal.


Constructor Summary
Production(AlphabetSymbol... symbols)
           
Production(LinkedList<AlphabetSymbol> us)
           
Production(List<AlphabetSymbol> us)
           
Production(Production p)
          Clones the production p to the constructed object
 
Method Summary
 void accept(GrammarEntityVisitor visitor)
          Accepts the given grammar entity visitor in a visitor pattern
 boolean equals(Object o)
           
 NonTerminal getNonTerminal()
          Gets the non terminal that this production belongs to
 NonTerminal getSingleProduction()
          Returns A if this productions is of the type -> A, else returns null
 LinkedList<AlphabetSymbol> getUs()
          Gets the list of AlphabetSymbol in this production of type U* in the Grammar
 int hashCode()
           
 boolean isEpsilonProduction()
          Returns true iff the production only contains a single node that is an ε terminal, See Terminal.isEpsilon()
 void remove()
          Removes this production from the NonTerminal that it belongs to.
 void replace(NonTerminal symbol, Production symbolP)
          Replaces the given nonTerminal by the list of AlphabetSymbol that the given production produces.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Production

public Production(AlphabetSymbol... symbols)

Production

public Production(LinkedList<AlphabetSymbol> us)

Production

public Production(List<AlphabetSymbol> us)

Production

public Production(Production p)
Clones the production p to the constructed object

Parameters:
p -
Method Detail

accept

public void accept(GrammarEntityVisitor visitor)
Description copied from interface: GrammarEntity
Accepts the given grammar entity visitor in a visitor pattern

Specified by:
accept in interface GrammarEntity

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getNonTerminal

public NonTerminal getNonTerminal()
Gets the non terminal that this production belongs to

Returns:

getSingleProduction

public NonTerminal getSingleProduction()
Returns A if this productions is of the type -> A, else returns null

Returns:

getUs

public LinkedList<AlphabetSymbol> getUs()
Gets the list of AlphabetSymbol in this production of type U* in the Grammar

Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEpsilonProduction

public boolean isEpsilonProduction()
Returns true iff the production only contains a single node that is an ε terminal, See Terminal.isEpsilon()

Returns:

remove

public void remove()
Removes this production from the NonTerminal that it belongs to.


replace

public void replace(NonTerminal symbol,
                    Production symbolP)
Replaces the given nonTerminal by the list of AlphabetSymbol that the given production produces.

Parameters:
symbol -
symbolP -

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008 Mathias Schwarz.