edu.isi.powerloom.gui.parser
Class Grammar

java.lang.Object
  |
  +--edu.isi.powerloom.gui.parser.Grammar

public class Grammar
extends java.lang.Object

Data Structure for representing a grammar.

Since:
Mon May 06 13:22:16 2002
Author:
Eric Melz

Constructor Summary
Grammar()
           
 
Method Summary
 void computeFirsts()
          Compute first(X) for all nonterminals in grammar.
 boolean computeFollowForProduction(Production production)
           
 void computeFollows()
          Compute follow (X) for all nonterminals in grammar.
 java.util.Set first(java.util.List symbols)
          From page 189 of Dragon Book.
 java.util.Set first(Symbol symbol)
          From page 189 of Dragon Book.
 java.util.Set follow(NonTerminal nonTerminal)
          From page 189 of Dragon Book.
 java.util.Collection getNonTerminals()
           
 ParseTable getParseTable()
           
 java.util.Collection getProductions()
           
 java.util.Collection getProductionsForNonTerminal(NonTerminal nonTerminal)
           
 NonTerminal getStartSymbol()
           
 java.util.Collection getTerminals()
           
 void setNonTerminals(java.util.Collection nonTerminals)
           
 void setProductions(java.util.Collection productions)
           
 void setStartSymbol(NonTerminal startSymbol)
           
 void setTerminals(java.util.Collection terminals)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Grammar

public Grammar()
Method Detail

setStartSymbol

public void setStartSymbol(NonTerminal startSymbol)

getStartSymbol

public NonTerminal getStartSymbol()

setNonTerminals

public void setNonTerminals(java.util.Collection nonTerminals)

setTerminals

public void setTerminals(java.util.Collection terminals)

setProductions

public void setProductions(java.util.Collection productions)

getNonTerminals

public java.util.Collection getNonTerminals()

getTerminals

public java.util.Collection getTerminals()

getProductions

public java.util.Collection getProductions()

getProductionsForNonTerminal

public java.util.Collection getProductionsForNonTerminal(NonTerminal nonTerminal)

computeFirsts

public void computeFirsts()
Compute first(X) for all nonterminals in grammar.


first

public java.util.Set first(Symbol symbol)
From page 189 of Dragon Book. Input: a symbol Ouput: A set of terminals, which represent all possible first terminals in strings that are derivable from the symbol.


first

public java.util.Set first(java.util.List symbols)
From page 189 of Dragon Book. Input: a list of symbols, representing a string of terminals and nonterminals. Ouput: A set of terminals, which represent all possible first terminals in strings that are derivable from the string.


computeFollows

public void computeFollows()
Compute follow (X) for all nonterminals in grammar.


computeFollowForProduction

public boolean computeFollowForProduction(Production production)
Returns:
boolean indicating whether new members were added to some Follow(x)

follow

public java.util.Set follow(NonTerminal nonTerminal)
From page 189 of Dragon Book. Input: a nonterminal Ouput: A set of terminals, representing all the terminals which can legally immediately follow this nonterminal.


getParseTable

public ParseTable getParseTable()

toString

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


Copyright © 2002 University of Southern California Information Sciences Institute. All Rights Reserved.