grammar
Class Production

java.lang.Object
  extended by grammar.Production
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MyProduction

public class Production
extends java.lang.Object
implements java.io.Serializable

Production rules of context-free grammars

Author:
XZW
See Also:
Serialized Form

Constructor Summary
Production()
          Creates an empty instance of production
Production(java.lang.String lhs, java.lang.String rhs)
          Creates an instance of production Tokens on the right hand side are delimited by blanks.
Production(java.lang.String lhs, java.lang.String[] rhs)
          Creates an instance of production
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getLHS()
          Returns the left hand side of the production rule.
 java.lang.String getRHS()
          Returns the right hand side of the production rule.
 java.lang.String[] getRHSTerminals()
          Returns all terminals at the right hand side of the production.
 int getRHSTokenNumber()
          Returns the number of tokens at the right hand side
 java.lang.String[] getRHSTokens()
          Returns all tokens at the right hand side of the production.
 java.lang.String[] getRHSVariables()
          Returns all variables at the right hand side of the production.
 java.lang.String[] getTerminals()
          Returns all terminals at the production.
 java.lang.String[] getVariables()
          Returns all variables at the production.
 int hashCode()
           
 void setLHS(java.lang.String lhs)
          Sets the left hand side
 void setRHS(java.lang.String rhs)
          Sets the right hand side (in string format)
 void setRHSTokens(java.lang.String[] rhs)
          Sets the right hand tokens of a production.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Production

public Production()
Creates an empty instance of production


Production

public Production(java.lang.String lhs,
                  java.lang.String[] rhs)
Creates an instance of production

Parameters:
lhs - the left hand side of the production rule, in string format.
rhs - the right hand side of the production rule, in tokens(string[]) format.

Production

public Production(java.lang.String lhs,
                  java.lang.String rhs)
Creates an instance of production Tokens on the right hand side are delimited by blanks.

Parameters:
lhs - the left hand side of the production rule, in string format.
rhs - the right hand side of the production rule, in string format.
Method Detail

getLHS

public java.lang.String getLHS()
Returns the left hand side of the production rule.

Returns:
the left hand side.

setLHS

public void setLHS(java.lang.String lhs)
Sets the left hand side

Parameters:
lhs - the left hand side to set
Throws:
java.lang.IllegalArgumentException - if lhs is not variable

getRHS

public java.lang.String getRHS()
Returns the right hand side of the production rule.

Returns:
the right hand side.

setRHS

public void setRHS(java.lang.String rhs)
Sets the right hand side (in string format)

Parameters:
rhs - the right hand side to set

getRHSTokenNumber

public int getRHSTokenNumber()
Returns the number of tokens at the right hand side

Returns:
the number of tokens

getRHSTokens

public java.lang.String[] getRHSTokens()
Returns all tokens at the right hand side of the production.

Returns:
all tokens at the right hand side

setRHSTokens

public void setRHSTokens(java.lang.String[] rhs)
Sets the right hand tokens of a production.

Parameters:
rhs - the right hand tokens to set

getRHSVariables

public java.lang.String[] getRHSVariables()
Returns all variables at the right hand side of the production.

Returns:
all variables at the right hand side of the production.

getRHSTerminals

public java.lang.String[] getRHSTerminals()
Returns all terminals at the right hand side of the production.

Returns:
all terminals at the right hand side of the production.

getVariables

public java.lang.String[] getVariables()
Returns all variables at the production.

Returns:
all variables at the production.

getTerminals

public java.lang.String[] getTerminals()
Returns all terminals at the production.

Returns:
all terminals at the production.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object