org.inxar.syntacs.grammar.context_free
Interface GrammarSymbol

All Known Subinterfaces:
Epsilon, NonTerminal, Terminal

public interface GrammarSymbol

GrammarSymbol is the base interface for Terminals and NonTerminals. Each GrammarSymbol has a name and is capable of determining its first set and its nullable status. The isTerminal() method is provided as an alternative for the instanceof operator. This is syntactically more readable (my opinion) and empirically faster.


Method Summary
 IntSet getFirstSet()
          Computes the IntSet Of terminals that is the first set for this GrammarSymbol.
 int getID()
          The globally assigned integer identifier for this GrammarSymbol.
 String getName()
          The common name of the GrammarSymbol.
 boolean isNullable()
          Returns true if this item either is Epsilon (case of Terminal) or derives it (case of NonTerminal).
 boolean isTerminal()
          Returns true if this GrammarSymbol is an instanceof Terminal and may safely be cast to a Terminal (or vice versa).
 

Method Detail

getID

public int getID()
The globally assigned integer identifier for this GrammarSymbol.

getName

public String getName()
The common name of the GrammarSymbol.

isNullable

public boolean isNullable()
Returns true if this item either is Epsilon (case of Terminal) or derives it (case of NonTerminal).

isTerminal

public boolean isTerminal()
Returns true if this GrammarSymbol is an instanceof Terminal and may safely be cast to a Terminal (or vice versa).

getFirstSet

public IntSet getFirstSet()
Computes the IntSet Of terminals that is the first set for this GrammarSymbol.