org.inxar.syntacs.grammar.context_free
Interface ContextFreeSet

All Known Implementing Classes:
CFGrammar

public interface ContextFreeSet

The ContextFreeSet interface is an optimized version of the ContextFreeGrammar object used by DPA construction algorithms. The absolute number of each type of element is available via the named method like 'terminals()'. The start Production is available via the method of the same name. Although the name 'ContextFreeSet' is not a term that is used often (or at all, for that matter) in theoretical books about these kinds of things, it makes a nice parallel to RegularSet, which is a relatively common term.


Method Summary
 ContextFreeGrammar getContextFreeGrammar()
          Returns the parent ContextFreeGrammar.
 GrammarSymbol getGrammarSymbol(int id)
          Returns the GrammarSymbol with the given id.
 Item getItem(int id)
          Returns the Item with the given id.
 NonTerminal getNonTerminal(int id)
          Returns the NonTerminal with the given id.
 Production getProduction(int id)
          Returns the Production with the given id.
 Production getStart()
          Returns the Production designated as the start.
 Terminal getTerminal(int id)
          Returns the Terminal with the given id.
 int items()
          Returns the number of Items in the grammar.
 int nonTerminals()
          Returns the number of NonTerminals in the grammar.
 int productions()
          Returns the number of Productions in the grammar.
 int terminals()
          Returns the number of Terminals in the grammar.
 

Method Detail

getContextFreeGrammar

public ContextFreeGrammar getContextFreeGrammar()
Returns the parent ContextFreeGrammar.

terminals

public int terminals()
Returns the number of Terminals in the grammar.

nonTerminals

public int nonTerminals()
Returns the number of NonTerminals in the grammar.

productions

public int productions()
Returns the number of Productions in the grammar.

items

public int items()
Returns the number of Items in the grammar.

getTerminal

public Terminal getTerminal(int id)
Returns the Terminal with the given id. If the id is not known, implementations may either return null or throw a RuntimeException.

getNonTerminal

public NonTerminal getNonTerminal(int id)
Returns the NonTerminal with the given id. If the id is not known, implementations may either return null or throw a RuntimeException.

getProduction

public Production getProduction(int id)
Returns the Production with the given id. If the id is not known, implementations may either return null or throw a RuntimeException.

getGrammarSymbol

public GrammarSymbol getGrammarSymbol(int id)
Returns the GrammarSymbol with the given id. If the id is not known, implementations may either return null or throw a RuntimeException.

getItem

public Item getItem(int id)
Returns the Item with the given id. If the id is not known, implementations may either return null or throw a RuntimeException.

getStart

public Production getStart()
Returns the Production designated as the start. Note that this production is generally not the same as the one given in ContextFreeLanguage.toGrammar(Production), as the start Production is typically 'augmented'.