marf.nlp.Parsing.GrammarCompiler
Class Rule

java.lang.Object
  extended by marf.nlp.Parsing.GrammarCompiler.Rule
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ProbabilisticRule

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

Language Grammar Rule.

$Id: Rule.java,v 1.11 2006/01/01 01:28:17 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.11 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  int iID
          ID for reference and debugging.
protected  NonTerminal oLHS
          Left-hand side of this rule.
protected  java.util.Vector oRHS
          A vector of grammar elements on the right-hand-side of a production.
private static long serialVersionUID
          For serialization versioning.
 
Constructor Summary
Rule(NonTerminal poLHS)
          Constructor with LHS.
 
Method Summary
 void addRHSElement(GrammarElement poGrammarElement)
          Allows adding grammar elements on the RHS of this rule.
 int getID()
          Allows getting this rule's ID.
 NonTerminal getLHS()
          Allows getting current LHS non-terminal of this rule.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 java.util.Vector getRHS()
          Allows getting the RHS part of this rule.
 java.util.Vector getRHSFirstSet(GrammarElement poEpsilon)
          Function that computes the first set of the right hand side of the current grammar rule.
 void setID(int piID)
          Allows setting this rule's ID.
 void setLHS(NonTerminal poNewLHS)
          Allows setting a new LHS from the outside.
 void setRHS(java.util.Vector poNewRHS)
          Allows setting a new RHS from the outside.
 java.lang.String toAbbrString()
          Just returns rule's ID prefixed with "R" as a string.
 java.lang.String toString()
          Overrides Object's toString() to human-readable production rule.
 java.lang.String toStringNumeric()
          Returns analogous representation of a rule to that of toString() except numeric IDs are used on the LHS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iID

protected int iID
ID for reference and debugging.


oLHS

protected NonTerminal oLHS
Left-hand side of this rule. Must be a non-terminal.


oRHS

protected java.util.Vector oRHS
A vector of grammar elements on the right-hand-side of a production.


serialVersionUID

private static final long serialVersionUID
For serialization versioning. When adding new members or make other structural changes regenerate this number with the serialver tool that comes with JDK.

Since:
0.3.0.4
See Also:
Constant Field Values
Constructor Detail

Rule

public Rule(NonTerminal poLHS)
Constructor with LHS.

Parameters:
poLHS - the default LHS non-terminal
Method Detail

addRHSElement

public void addRHSElement(GrammarElement poGrammarElement)
Allows adding grammar elements on the RHS of this rule.

Parameters:
poGrammarElement - RHS grammar element to add

getRHSFirstSet

public java.util.Vector getRHSFirstSet(GrammarElement poEpsilon)
Function that computes the first set of the right hand side of the current grammar rule.

Parameters:
poEpsilon - what to consider a termination element
Returns:
a collection of the elements in the first set

toString

public java.lang.String toString()
Overrides Object's toString() to human-readable production rule.

Overrides:
toString in class java.lang.Object
Returns:
rule dump in the textual form
See Also:
Object.toString()

toStringNumeric

public java.lang.String toStringNumeric()
Returns analogous representation of a rule to that of toString() except numeric IDs are used on the LHS.

Returns:
textual rule dump with numeric IDs on the LHS
See Also:
toString()

toAbbrString

public java.lang.String toAbbrString()
Just returns rule's ID prefixed with "R" as a string.

Returns:
rule's ID in string form

setLHS

public void setLHS(NonTerminal poNewLHS)
Allows setting a new LHS from the outside.

Parameters:
poNewLHS - new LHS non-terminal

setRHS

public void setRHS(java.util.Vector poNewRHS)
Allows setting a new RHS from the outside.

Parameters:
poNewRHS - new collection of the RHS elements

getLHS

public NonTerminal getLHS()
Allows getting current LHS non-terminal of this rule.

Returns:
the LHS non-terminal

getRHS

public java.util.Vector getRHS()
Allows getting the RHS part of this rule.

Returns:
current collection of the RHS elements

getID

public int getID()
Allows getting this rule's ID.

Returns:
the ID

setID

public void setID(int piID)
Allows setting this rule's ID.

Parameters:
piID - new ID of the rule.

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Returns:
revision string


SourceForge Logo