antlr
Class Grammar

java.lang.Object
  |
  +--antlr.Grammar
Direct Known Subclasses:
LexerGrammar, ParserGrammar, TreeWalkerGrammar

public abstract class Grammar
extends Object

Untamed:


Field Summary
protected  boolean analyzerDebug
           
protected  boolean buildAST
           
protected  Token classMemberAction
           
protected  String className
           
protected  String comment
           
protected  boolean debuggingOutput
           
protected  boolean defaultErrorHandler
           
protected  String exportVocab
          The name of the export vocabulary...used to generate the output token types interchange file.
protected  String fileName
           
protected  CodeGenerator generator
           
protected  boolean hasSyntacticPredicate
           
protected  boolean hasUserErrorHandling
           
protected  String importVocab
          The name of the import vocabulary.
protected  boolean interactive
           
protected  int maxk
           
protected  Hashtable options
           
protected  Token preambleAction
           
protected  Vector rules
           
protected  String superClass
           
protected  Hashtable symbols
           
protected  LLkGrammarAnalyzer theLLkAnalyzer
           
protected  TokenManager tokenManager
          The token manager associated with the grammar, if any.
protected  Tool tool
           
protected  boolean traceRules
           
 
Constructor Summary
Grammar(String className_, Tool tool_, String superClass)
          Enabled:
 
Method Summary
 void define(RuleSymbol rs)
          Enabled: Define a rule
abstract  void generate()
          Enabled: Top-level call to generate the code for this grammar
protected  String getClassName()
           
 boolean getDefaultErrorHandler()
          Enabled:
 String getFilename()
          Enabled:
 int getIntegerOption(String key)
          Enabled: Get an integer option.
 Token getOption(String key)
          Enabled: Get an option.
protected abstract  String getSuperClass()
           
 GrammarSymbol getSymbol(String s)
          Enabled:
 Enumeration getSymbols()
          Enabled:
 boolean hasOption(String key)
          Enabled: Check the existence of an option in the table
 boolean isDefined(String s)
          Enabled: Is a rule symbol defined? (not used for tokens)
abstract  void processArguments(String[] args)
          Enabled: Process command line arguments.
 void setCodeGenerator(CodeGenerator gen)
          Enabled:
 void setFilename(String s)
          Enabled:
 void setGrammarAnalyzer(LLkGrammarAnalyzer a)
          Enabled:
 boolean setOption(String key, Token value)
          Enabled: Set a generic option.
 void setTokenManager(TokenManager tokenManager_)
          Enabled:
 String toString()
          Suppressed: Print out the grammar without actions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tool

protected Tool tool

generator

protected CodeGenerator generator

theLLkAnalyzer

protected LLkGrammarAnalyzer theLLkAnalyzer

symbols

protected Hashtable symbols

buildAST

protected boolean buildAST

analyzerDebug

protected boolean analyzerDebug

interactive

protected boolean interactive

superClass

protected String superClass

tokenManager

protected TokenManager tokenManager
The token manager associated with the grammar, if any. // The token manager is responsible for maintaining the set of valid tokens, and // is conceptually shared between the lexer and parser. This may be either a // LexerGrammar or a ImportVocabTokenManager.


exportVocab

protected String exportVocab
The name of the export vocabulary...used to generate the output token types interchange file.


importVocab

protected String importVocab
The name of the import vocabulary. "Initial conditions"


options

protected Hashtable options

rules

protected Vector rules

preambleAction

protected Token preambleAction

className

protected String className

fileName

protected String fileName

classMemberAction

protected Token classMemberAction

hasSyntacticPredicate

protected boolean hasSyntacticPredicate

hasUserErrorHandling

protected boolean hasUserErrorHandling

maxk

protected int maxk

traceRules

protected boolean traceRules

debuggingOutput

protected boolean debuggingOutput

defaultErrorHandler

protected boolean defaultErrorHandler

comment

protected String comment
Constructor Detail

Grammar

public Grammar(String className_,
               Tool tool_,
               String superClass)
Enabled:

Method Detail

define

public void define(RuleSymbol rs)
Enabled: Define a rule


generate

public abstract void generate()
                       throws IOException
Enabled: Top-level call to generate the code for this grammar

IOException

getClassName

protected String getClassName()

getDefaultErrorHandler

public boolean getDefaultErrorHandler()
Enabled:


getFilename

public String getFilename()
Enabled:


getIntegerOption

public int getIntegerOption(String key)
                     throws NumberFormatException
Enabled: 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.
NumberFormatException

getOption

public Token getOption(String key)
Enabled: 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.

getSuperClass

protected abstract String getSuperClass()

getSymbol

public GrammarSymbol getSymbol(String s)
Enabled:


getSymbols

public Enumeration getSymbols()
Enabled:


hasOption

public boolean hasOption(String key)
Enabled: 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(String s)
Enabled: Is a rule symbol defined? (not used for tokens)


processArguments

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


setCodeGenerator

public void setCodeGenerator(CodeGenerator gen)
Enabled:


setFilename

public void setFilename(String s)
Enabled:


setGrammarAnalyzer

public void setGrammarAnalyzer(LLkGrammarAnalyzer a)
Enabled:


setOption

public boolean setOption(String key,
                         Token value)
Enabled: 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(TokenManager tokenManager_)
Enabled:


toString

public String toString()
Suppressed: Print out the grammar without actions

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?