Class Grammar

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byGrammar
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
AugmentedGrammar

public class Grammar
extends java.util.HashMap

A grammar is a set of GrammarRules.

Implementation note: Since the main use of a Grammar is looking up rules whose first constituent matches a newly-added entry, we maintain the grammar rules indexed by category of their first first rhs constituent.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
(package private)  java.lang.String description
          The text description of this Grammar.
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
Grammar()
          Returns a new (empty) Grammar.
 
Method Summary
 void add(GrammarRule rule)
          Adds the given GrammarRule to this Grammar.
 void dump()
          Dump the contents of this Grammar to System.out.
 void dump(java.io.PrintStream stream)
          Dump the contents of this Grammar to the given PrintStream.
 java.lang.String getDescription()
          Returns the text description of this Grammar.
 java.util.List getRulesForConstituent(Constituent constit)
          Retrieve the List of GrammarRules whose first rhs constituent matches the given Constituent.
 void readFile(java.lang.String filename)
          Read the given filename and augment this Grammar.
 void setDescription(java.lang.String description)
          Sets the text description of this Grammar.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

description

java.lang.String description
The text description of this Grammar. This may be useful in displays, tools, or just as a comment in the files.

Constructor Detail

Grammar

public Grammar()
Returns a new (empty) Grammar.

Method Detail

add

public void add(GrammarRule rule)
Adds the given GrammarRule to this Grammar. The Grammar is indexed by syntactic catgeory of the first rhs constituent to help in matching.


getRulesForConstituent

public java.util.List getRulesForConstituent(Constituent constit)
Retrieve the List of GrammarRules whose first rhs constituent matches the given Constituent.


dump

public void dump()
Dump the contents of this Grammar to System.out.


dump

public void dump(java.io.PrintStream stream)
Dump the contents of this Grammar to the given PrintStream.


getDescription

public java.lang.String getDescription()
Returns the text description of this Grammar.


setDescription

public void setDescription(java.lang.String description)
Sets the text description of this Grammar.


readFile

public void readFile(java.lang.String filename)
              throws java.io.IOException
Read the given filename and augment this Grammar.

Throws:
java.io.IOException
See Also:
GrammarFileHandler