marf.nlp.Parsing.GrammarCompiler
Class NonTerminal

java.lang.Object
  extended by marf.nlp.Parsing.GrammarCompiler.GrammarElement
      extended by marf.nlp.Parsing.GrammarCompiler.NonTerminal
All Implemented Interfaces:
java.io.Serializable

public class NonTerminal
extends GrammarElement

Non-terminal grammar element. E.g.: <prog>.

$Id: NonTerminal.java,v 1.11 2007/12/18 21:37:57 mokhov Exp $

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

Field Summary
protected  boolean bDefined
          Flag indicating whether this non-terminal is defined or not.
protected  java.util.Vector oFollowSet
          Follow set of this non-terminal.
private static long serialVersionUID
          For serialization versioning.
 
Fields inherited from class marf.nlp.Parsing.GrammarCompiler.GrammarElement
iID, oFirstSet, oToken, strName
 
Constructor Summary
NonTerminal(java.lang.String pstrName, int piID)
          Creates a non-terminal by a name and ID.
NonTerminal(Token poToken, int piID)
          Creates a non-terminal from a token and the ID.
 
Method Summary
 boolean addToFollowSet(NonTerminal poNonTerminal)
          Adds a single non-terminal to the follow set.
 boolean addToFollowSet(Terminal poTerminal)
          Adds a single terminal to the follow set if it's not already there.
 boolean addToFollowSet(java.util.Vector poSet)
          Appends elements from the passed set to its current follow set.
 java.util.Vector getFollowSet()
          Allows to query for the collection of the follow set elements of this non-terminal.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 boolean isDefined()
          Tests whether this non-terminal was defined at some point in the grammar.
 boolean isNonTerminal()
          Allows querying this grammar element for non-terminality.
 boolean isTerminal()
          Allows querying this grammar element for terminality.
 void setDefined()
          Marks this non-terminal as defined.
 
Methods inherited from class marf.nlp.Parsing.GrammarCompiler.GrammarElement
addToFirstSet, addToFirstSet, addToFirstSet, getFirstSet, getID, getName, getToken, isEqualByName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bDefined

protected boolean bDefined
Flag indicating whether this non-terminal is defined or not.


oFollowSet

protected java.util.Vector oFollowSet
Follow set of this non-terminal.


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

NonTerminal

public NonTerminal(java.lang.String pstrName,
                   int piID)
Creates a non-terminal by a name and ID.

Parameters:
pstrName - the name
piID - the ID

NonTerminal

public NonTerminal(Token poToken,
                   int piID)
Creates a non-terminal from a token and the ID.

Parameters:
poToken - the token
piID - the ID.
Method Detail

isDefined

public boolean isDefined()
Tests whether this non-terminal was defined at some point in the grammar.

Returns:
true if the non-terminal defined as a rule; false otherwise

setDefined

public void setDefined()
Marks this non-terminal as defined. Only allow to set it, but not unset.


getFollowSet

public java.util.Vector getFollowSet()
Allows to query for the collection of the follow set elements of this non-terminal.

Returns:
the follow set collection

addToFollowSet

public boolean addToFollowSet(java.util.Vector poSet)
Appends elements from the passed set to its current follow set.

Parameters:
poSet - the collection of elements to append
Returns:
true if the current follow set has changed as a result of addition; false otherwise

addToFollowSet

public boolean addToFollowSet(Terminal poTerminal)
Adds a single terminal to the follow set if it's not already there.

Parameters:
poTerminal - the terminal to add
Returns:
true if the current follow set has changed as a result of addition; false otherwise

addToFollowSet

public boolean addToFollowSet(NonTerminal poNonTerminal)
Adds a single non-terminal to the follow set.

Parameters:
poNonTerminal - the non-terminal to add
Returns:
true if the current follow set has changed as a result of addition; false otherwise

isTerminal

public boolean isTerminal()
Description copied from class: GrammarElement
Allows querying this grammar element for terminality.

Specified by:
isTerminal in class GrammarElement
Returns:
false
See Also:
GrammarElement.isTerminal()

isNonTerminal

public boolean isNonTerminal()
Description copied from class: GrammarElement
Allows querying this grammar element for non-terminality.

Specified by:
isNonTerminal in class GrammarElement
Returns:
true
See Also:
GrammarElement.isNonTerminal()

getMARFSourceCodeRevision

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

Returns:
revision string


SourceForge Logo