torero.model
Class Production

java.lang.Object
  |
  +--torero.model.Production
All Implemented Interfaces:
Comparable, Serializable

public class Production
extends Object
implements Comparable, Serializable

The Production Class composits a production in terms of a grammar by just refering to unique Instances of Tokens, Nonterms, Traversals. This means that its free of any redandancy and therefore very fexible and robust regarding underlying modifications (of Tokens, Nonterms, Traversals). A Production can define AttributeAssignments for it`s scope and Traversals can be associated to a Production.

See Also:
Token, Nonterm, AttributeAssingnment, Attribute, Traversal, Serialized Form

Inner Class Summary
 class Production.ListElement
          Inner Class for representing the unique Position of a Symbol inside a Production.
 class Production.ProductionRHS
          Class for internal representation of the Right Hand Side (RHS) of the production.
 
Constructor Summary
Production(Nonterm LHS, Iterator RHSSymbols)
          Creating new Productions can be done by using this constructor.
 
Method Summary
 boolean addTraversal(Traversal t)
          Adds a Traversal to the Production.
 int compareTo(Object o)
          Sort order via LHS Symbol sort order.
 boolean containsTrav(Traversal t)
          Does the Production contain the given Traversal ?
 boolean equals(Object o)
          Equality defined as structural equality.
 Iterator getAllAssignments()
          Returns all AttibuteAssignments this Production has as Iterator of AttibuteAssignments.
 Iterator getAssignmentsHavingDest(Production.ListElement dest)
           
 Iterator getCompatibleAssignments(AttributeAssingnment.AttribKey ak)
           
 Production.ListElement getLHS()
          Returns the LHS of this Production encapsulated as ListElement.
 Production.ProductionRHS getRHS()
          Returns the RHS of this Production.
 Iterator getTraversals()
          Returns all Traversals that are associated to this Production.
 AttributeAssingnment hasAssignment(Production.ListElement destle, Attribute destAttr)
           
 AttributeAssingnment hasAssignmentWithSource(Production.ListElement destle, Attribute destAttr, Production.ListElement sourcele, Attribute sourceAttr)
           
 AttributeAssingnment hasIncompatibleAssignment(Production.ListElement destle, Attribute destAttr)
           
 AttributeAssingnment obtainAssignment(Production.ListElement destle, Attribute destAttr)
           
 AttributeAssingnment obtainAssignment(Production.ListElement destle, Attribute destAttr, Production.ListElement srcle, Attribute srcAttr)
           
 void removeAssignment(AttributeAssingnment ass)
           
 void removeTraversal(Traversal t)
          Removes a Traversal from the Production.
 void setLHS(Production.ListElement LHS)
          Set a ListElement as new LHS.
 void setPrecedence(Token precToken)
          Support for Yacc specific extensions.
 String toDot(Derivat der, String offset, boolean withattribs)
          Support for Dot File generation.
 StringBuffer toOx(StringBuffer sb, boolean firstline)
          Support for Ox File generation.
 String toString()
           
 String toString2()
           
 String toString3()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Production

public Production(Nonterm LHS,
                  Iterator RHSSymbols)
Creating new Productions can be done by using this constructor.
Parameters:
LHS - takes a Nonterminal Symbol used as LHS for the new Production
RHSSymbols - takes an Iterator of Symbols used as RHS for the new Production
Method Detail

getLHS

public Production.ListElement getLHS()
Returns the LHS of this Production encapsulated as ListElement.
Returns:
returns the LHS of this Production encapsulated as ListElement

compareTo

public int compareTo(Object o)
Sort order via LHS Symbol sort order.
Specified by:
compareTo in interface Comparable

setLHS

public void setLHS(Production.ListElement LHS)
Set a ListElement as new LHS.
Parameters:
LHS - takes a ListElement that as new LHS

getRHS

public Production.ProductionRHS getRHS()
Returns the RHS of this Production.
Returns:
returns the RHS of this Production

equals

public boolean equals(Object o)
Equality defined as structural equality.
Overrides:
equals in class Object

setPrecedence

public void setPrecedence(Token precToken)
Support for Yacc specific extensions.

toString

public String toString()
Overrides:
toString in class Object

toString2

public String toString2()

toString3

public String toString3()

toDot

public String toDot(Derivat der,
                    String offset,
                    boolean withattribs)
Support for Dot File generation.

toOx

public StringBuffer toOx(StringBuffer sb,
                         boolean firstline)
Support for Ox File generation.

obtainAssignment

public AttributeAssingnment obtainAssignment(Production.ListElement destle,
                                             Attribute destAttr)
                                      throws AssignmentIncompatibleException

obtainAssignment

public AttributeAssingnment obtainAssignment(Production.ListElement destle,
                                             Attribute destAttr,
                                             Production.ListElement srcle,
                                             Attribute srcAttr)
                                      throws AssignmentIncompatibleException,
                                             AssignLoopException,
                                             AssignException

hasAssignment

public AttributeAssingnment hasAssignment(Production.ListElement destle,
                                          Attribute destAttr)

hasIncompatibleAssignment

public AttributeAssingnment hasIncompatibleAssignment(Production.ListElement destle,
                                                      Attribute destAttr)

removeAssignment

public void removeAssignment(AttributeAssingnment ass)

hasAssignmentWithSource

public AttributeAssingnment hasAssignmentWithSource(Production.ListElement destle,
                                                    Attribute destAttr,
                                                    Production.ListElement sourcele,
                                                    Attribute sourceAttr)

getAssignmentsHavingDest

public Iterator getAssignmentsHavingDest(Production.ListElement dest)

getCompatibleAssignments

public Iterator getCompatibleAssignments(AttributeAssingnment.AttribKey ak)

getAllAssignments

public Iterator getAllAssignments()
Returns all AttibuteAssignments this Production has as Iterator of AttibuteAssignments.
Returns:
returns all AttibuteAssignments this Production has as Iterator of AttibuteAssignments.

addTraversal

public boolean addTraversal(Traversal t)
Adds a Traversal to the Production.

removeTraversal

public void removeTraversal(Traversal t)
Removes a Traversal from the Production.

containsTrav

public boolean containsTrav(Traversal t)
Does the Production contain the given Traversal ?

getTraversals

public Iterator getTraversals()
Returns all Traversals that are associated to this Production.
Returns:
returns all Traversals that are associated to this Production.