Public Member Functions | Protected Member Functions | Protected Attributes

antlr.Grammar Class Reference

Inheritance diagram for antlr.Grammar:
antlr.LexerGrammar antlr.ParserGrammar antlr.TreeWalkerGrammar

List of all members.

Public Member Functions

 Grammar (String className_, Tool tool_, String superClass)
void define (RuleSymbol rs)
abstract void generate () throws IOException
boolean getDefaultErrorHandler ()
String getFilename ()
int getIntegerOption (String key) throws NumberFormatException
Token getOption (String key)
GrammarSymbol getSymbol (String s)
Enumeration getSymbols ()
boolean hasOption (String key)
boolean isDefined (String s)
abstract void processArguments (String[] args)
void setCodeGenerator (CodeGenerator gen)
void setFilename (String s)
void setGrammarAnalyzer (LLkGrammarAnalyzer a)
boolean setOption (String key, Token value)
void setTokenManager (TokenManager tokenManager_)
String toString ()

Protected Member Functions

String getClassName ()
abstract String getSuperClass ()

Protected Attributes

Tool antlrTool
CodeGenerator generator
LLkGrammarAnalyzer theLLkAnalyzer
Hashtable symbols
boolean buildAST = false
boolean analyzerDebug = false
boolean interactive = false
String superClass = null
TokenManager tokenManager
String exportVocab = null
String importVocab = null
Hashtable options
Vector rules
Token preambleAction = new CommonToken(Token.INVALID_TYPE, "")
String className = null
String fileName = null
Token classMemberAction = new CommonToken(Token.INVALID_TYPE, "")
boolean hasSyntacticPredicate = false
boolean hasUserErrorHandling = false
int maxk = 1
boolean traceRules = false
boolean debuggingOutput = false
boolean defaultErrorHandler = true
String comment = null

Detailed Description

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 & Destructor Documentation

antlr.Grammar.Grammar ( String  className_,
Tool  tool_,
String  superClass 
)

Member Function Documentation

abstract void antlr.Grammar.generate (  )  throws IOException [pure virtual]
boolean antlr.Grammar.getDefaultErrorHandler (  ) 
String antlr.Grammar.getFilename (  ) 

References antlr.Grammar.fileName.

Referenced by antlr.MakeGrammar.beginTree(), antlr.MakeGrammar.defineRuleName(), antlr.DefineGrammarSymbols.defineRuleName(), antlr.DefineGrammarSymbols.defineToken(), antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), antlr.MakeGrammar.endExceptionSpec(), antlr.MakeGrammar.endSubRule(), antlr.CodeGenerator.extractIdOfAction(), antlr.CodeGenerator.extractTypeOfAction(), antlr.DefaultJavaCodeGeneratorPrintWriterManager.finishOutput(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.PythonCodeGenerator.genAlt(), antlr.JavaCodeGenerator.genAlt(), antlr.CSharpCodeGenerator.genAlt(), antlr.CppCodeGenerator.genAlt(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.JavaCodeGenerator.genCommonBlock(), antlr.CSharpCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInitFactory(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.getASTCreateString(), antlr.LLkAnalyzer.look(), antlr.MakeGrammar.oneOrMoreSubRule(), antlr.MakeGrammar.optionalSubRule(), antlr.PythonCodeGenerator.processActionCode(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), antlr.JavaCodeGenerator.processActionForSpecialSymbols(), antlr.CSharpCodeGenerator.processActionForSpecialSymbols(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.MakeGrammar.refCharLiteral(), antlr.MakeGrammar.refCharRange(), antlr.MakeGrammar.refElementOption(), antlr.MakeGrammar.refReturnAction(), antlr.MakeGrammar.refRule(), antlr.MakeGrammar.refStringLiteral(), antlr.MakeGrammar.refToken(), antlr.MakeGrammar.refTokenRange(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.DefineGrammarSymbols.setGrammarOption(), antlr.TreeWalkerGrammar.setOption(), antlr.RuleBlock.setOption(), antlr.ParserGrammar.setOption(), antlr.LexerGrammar.setOption(), antlr.GrammarAtom.setOption(), antlr.Grammar.setOption(), antlr.AlternativeBlock.setOption(), antlr.StringLiteralElement.StringLiteralElement(), antlr.MakeGrammar.synPred(), antlr.TokenRefElement.TokenRefElement(), antlr.DefaultToolErrorHandler.warnAltAmbiguity(), antlr.DefaultToolErrorHandler.warnAltExitAmbiguity(), and antlr.MakeGrammar.zeroOrMoreSubRule().

int antlr.Grammar.getIntegerOption ( String  key  )  throws 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.

References antlr.Token.getText(), antlr.Token.getType(), and antlr.Grammar.options.

Referenced by antlr.CodeGenerator.setGrammar(), and antlr.Grammar.setOption().

Token antlr.Grammar.getOption ( 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.

References antlr.Grammar.options.

Referenced by antlr.CodeGenerator.setGrammar().

Enumeration antlr.Grammar.getSymbols (  ) 
boolean antlr.Grammar.hasOption ( 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

References antlr.Grammar.options.

Referenced by antlr.CodeGenerator.setGrammar().

abstract void antlr.Grammar.processArguments ( String[]  args  )  [pure virtual]

Process command line arguments. Implemented in subclasses

Implemented in antlr.LexerGrammar, antlr.ParserGrammar, and antlr.TreeWalkerGrammar.

Referenced by antlr.DefineGrammarSymbols.startParser(), and antlr.DefineGrammarSymbols.startTreeWalker().

boolean antlr.Grammar.setOption ( 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

Reimplemented in antlr.LexerGrammar, antlr.ParserGrammar, and antlr.TreeWalkerGrammar.

References antlr.Grammar.analyzerDebug, antlr.Grammar.antlrTool, antlr.Grammar.defaultErrorHandler, antlr.Tool.error(), antlr.Token.getColumn(), antlr.Grammar.getFilename(), antlr.Grammar.getIntegerOption(), antlr.Token.getLine(), antlr.Token.getText(), antlr.Grammar.maxk, and antlr.Grammar.options.

Referenced by antlr.DefineGrammarSymbols.setGrammarOption().

void antlr.Grammar.setTokenManager ( TokenManager  tokenManager_  ) 
String antlr.Grammar.toString (  ) 

Member Data Documentation

String antlr.Grammar.className = null [protected]
String antlr.Grammar.exportVocab = null [protected]

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

Referenced by antlr.DefineGrammarSymbols.endOptions(), and antlr.DefineGrammarSymbols.setGrammarOption().

boolean antlr.Grammar.hasUserErrorHandling = false [protected]
String antlr.Grammar.importVocab = null [protected]

The name of the import vocabulary. "Initial conditions"

Referenced by antlr.DefineGrammarSymbols.endOptions(), and antlr.DefineGrammarSymbols.setGrammarOption().

int antlr.Grammar.maxk = 1 [protected]

Referenced by antlr.BlockEndElement.BlockEndElement(), antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.CSharpCodeGenerator.genBody(), antlr.CppCodeGenerator.genBody(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.JavaCodeGenerator.genCommonBlock(), antlr.CSharpCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genCommonBlock(), antlr.HTMLCodeGenerator.genFollowSetForRuleBlock(), antlr.DocBookCodeGenerator.genFollowSetForRuleBlock(), antlr.DiagnosticCodeGenerator.genFollowSetForRuleBlock(), antlr.HTMLCodeGenerator.genLookaheadSetForAlt(), antlr.DocBookCodeGenerator.genLookaheadSetForAlt(), antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt(), antlr.HTMLCodeGenerator.genLookaheadSetForBlock(), antlr.DocBookCodeGenerator.genLookaheadSetForBlock(), antlr.DiagnosticCodeGenerator.genLookaheadSetForBlock(), antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.JavaCodeGenerator.getLookaheadTestExpression(), antlr.CSharpCodeGenerator.getLookaheadTestExpression(), antlr.CppCodeGenerator.getLookaheadTestExpression(), antlr.PythonCodeGenerator.lookaheadIsEmpty(), antlr.JavaCodeGenerator.lookaheadIsEmpty(), antlr.CSharpCodeGenerator.lookaheadIsEmpty(), antlr.CppCodeGenerator.lookaheadIsEmpty(), antlr.RuleBlock.prepareForAnalysis(), antlr.AlternativeBlock.prepareForAnalysis(), antlr.RuleBlock.RuleBlock(), antlr.RuleEndElement.RuleEndElement(), antlr.Grammar.setOption(), and antlr.RuleBlock.toString().

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.

Referenced by antlr.DefineGrammarSymbols._refStringLiteral(), antlr.DefineGrammarSymbols._refToken(), antlr.DefineGrammarSymbols.defineRuleName(), antlr.DefineGrammarSymbols.defineToken(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CppCodeGenerator.genBitsets(), antlr.CSharpCodeGenerator.genBody(), antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CSharpCodeGenerator.genInitFactory(), antlr.CppCodeGenerator.genInitFactory(), antlr.PythonCodeGenerator.genTokenASTNodeMap(), antlr.JavaCodeGenerator.genTokenASTNodeMap(), antlr.PythonCodeGenerator.genTokenStrings(), antlr.JavaCodeGenerator.genTokenStrings(), antlr.CSharpCodeGenerator.genTokenStrings(), antlr.CppCodeGenerator.genTokenStrings(), antlr.PythonCodeGenerator.getASTCreateString(), antlr.JavaCodeGenerator.getASTCreateString(), antlr.CSharpCodeGenerator.getASTCreateString(), antlr.CppCodeGenerator.getASTCreateString(), antlr.CSharpCodeGenerator.getTokenTypesClassName(), antlr.LLkAnalyzer.look(), antlr.HTMLCodeGenerator.printSet(), antlr.DocBookCodeGenerator.printSet(), antlr.DiagnosticCodeGenerator.printSet(), antlr.CSharpCodeGenerator.processStringForASTConstructor(), antlr.CppCodeGenerator.processStringForASTConstructor(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.RuleBlock.setOption(), antlr.Grammar.setTokenManager(), antlr.StringLiteralElement.StringLiteralElement(), antlr.TokenRangeElement.TokenRangeElement(), antlr.TokenRefElement.TokenRefElement(), antlr.RuleBlock.toString(), antlr.Lookahead.toString(), and antlr.AlternativeBlock.toString().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties