se.chalmers.cs.gf.parse.chart
Class CFGrammar

java.lang.Object
  extended by se.chalmers.cs.gf.parse.chart.CFGrammar

public class CFGrammar
extends java.lang.Object

A context-free grammar.


Constructor Summary
CFGrammar(java.lang.String name, Category start)
           
 
Method Summary
 void addRule(Category cat, java.util.List<Symbol> rhs, java.lang.String fun, java.util.List<Profile> profile)
          Add a rule to the grammar.
 java.util.Collection<NonTerminalRule> getEmptyRules()
          Get the empty rules.
 java.util.Set<java.lang.String> getKnownWords()
          Get the set of words for which there are terminal rules in the grammar.
 java.lang.String getName()
           
 java.util.Collection<NonTerminalRule> getNonTerminalRules()
          Get the rules with only non-terminals in the RHS.
 Category getStart()
           
 boolean matchesIntLiteralRule(Token token)
           
 java.util.Collection<TerminalRule> matchingTerminalRules(Token t)
          Get the terminal rules which match a given token.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CFGrammar

public CFGrammar(java.lang.String name,
                 Category start)
Method Detail

getName

public java.lang.String getName()

getStart

public Category getStart()

getNonTerminalRules

public java.util.Collection<NonTerminalRule> getNonTerminalRules()
Get the rules with only non-terminals in the RHS.


matchingTerminalRules

public java.util.Collection<TerminalRule> matchingTerminalRules(Token t)
Get the terminal rules which match a given token.


getKnownWords

public java.util.Set<java.lang.String> getKnownWords()
Get the set of words for which there are terminal rules in the grammar. This does not include integer or string literals.


matchesIntLiteralRule

public boolean matchesIntLiteralRule(Token token)

getEmptyRules

public java.util.Collection<NonTerminalRule> getEmptyRules()
Get the empty rules.


addRule

public void addRule(Category cat,
                    java.util.List<Symbol> rhs,
                    java.lang.String fun,
                    java.util.List<Profile> profile)
Add a rule to the grammar.


toString

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