antlr
Class Grammar

java.lang.Object
  extended byantlr.Grammar

public abstract class Grammar
extends java.lang.Object

A Grammar holds a set of rules (which are stored in a symbol table). Most of the time a grammar needs a code generator and an LLkAnalyzer too.


Constructor Summary
Grammar(java.lang.String className_, Tool tool_, java.lang.String superClass)
           
 
Method Summary
 void define(antlr.RuleSymbol rs)
          Define a rule
abstract  void generate()
          Top-level call to generate the code for this grammar
 boolean getDefaultErrorHandler()
           
 java.lang.String getFilename()
           
 int getIntegerOption(java.lang.String key)
          Get an integer option.
 Token getOption(java.lang.String key)
          Get an option.
 antlr.GrammarSymbol getSymbol(java.lang.String s)
           
 java.util.Enumeration getSymbols()
           
 boolean hasOption(java.lang.String key)
          Check the existence of an option in the table
 boolean isDefined(java.lang.String s)
          Is a rule symbol defined? (not used for tokens)
abstract  void processArguments(java.lang.String[] args)
          Process command line arguments.
 void setCodeGenerator(CodeGenerator gen)
           
 void setFilename(java.lang.String s)
           
 void setGrammarAnalyzer(LLkGrammarAnalyzer a)
           
 boolean setOption(java.lang.String key, Token value)
          Set a generic option.
 void setTokenManager(antlr.TokenManager tokenManager_)
           
 java.lang.String toString()
          Print out the grammar without actions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Grammar

public Grammar(java.lang.String className_,
               Tool tool_,
               java.lang.String superClass)
Method Detail

define

public void define(antlr.RuleSymbol rs)
Define a rule


generate

public abstract void generate()
                       throws java.io.IOException
Top-level call to generate the code for this grammar

Throws:
java.io.IOException

getDefaultErrorHandler

public boolean getDefaultErrorHandler()

getFilename

public java.lang.String getFilename()

getIntegerOption

public int getIntegerOption(java.lang.String key)
                     throws java.lang.NumberFormatException
Get an integer option. Given the name of the option find its associated integer value. If the associated value is not an integer or is not in the table, then throw an exception of type NumberFormatException.

Parameters:
key - The name of the option
Returns:
The value associated with the key.
Throws:
java.lang.NumberFormatException

getOption

public Token getOption(java.lang.String key)
Get an option. Given the name of the option find its associated value.

Parameters:
key - The name of the option
Returns:
The value associated with the key, or null if the key has not been set.

getSymbol

public antlr.GrammarSymbol getSymbol(java.lang.String s)

getSymbols

public java.util.Enumeration getSymbols()

hasOption

public boolean hasOption(java.lang.String key)
Check the existence of an option in the table

Parameters:
key - The name of the option
Returns:
true if the option is in the table

isDefined

public boolean isDefined(java.lang.String s)
Is a rule symbol defined? (not used for tokens)


processArguments

public abstract void processArguments(java.lang.String[] args)
Process command line arguments. Implemented in subclasses


setCodeGenerator

public void setCodeGenerator(CodeGenerator gen)

setFilename

public void setFilename(java.lang.String s)

setGrammarAnalyzer

public void setGrammarAnalyzer(LLkGrammarAnalyzer a)

setOption

public boolean setOption(java.lang.String key,
                         Token value)
Set a generic option. This associates a generic option key with a Token value. No validation is performed by this method, although users of the value (code generation and/or analysis) may require certain formats. The value is stored as a token so that the location of an error can be reported.

Parameters:
key - The name of the option.
value - The value to associate with the key.
Returns:
true if the option was a valid generic grammar option, false o/w

setTokenManager

public void setTokenManager(antlr.TokenManager tokenManager_)

toString

public java.lang.String toString()
Print out the grammar without actions