Public Member Functions | |
Tool () | |
String | getGrammarFile () |
boolean | hasError () |
NameSpace | getNameSpace () |
String | getNamespaceStd () |
String | getNamespaceAntlr () |
boolean | getGenHashLines () |
String | getLiteralsPrefix () |
boolean | getUpperCaseMangledLiterals () |
void | setFileLineFormatter (FileLineFormatter formatter) |
void | copyFile (String source_name, String dest_name) throws IOException |
void | doEverythingWrapper (String[] args) |
int | doEverything (String[] args) |
void | error (String s) |
void | error (String s, String file, int line, int column) |
String | fileMinusPath (String f) |
String | getLanguage (MakeGrammar behavior) |
String | getOutputDirectory () |
PrintWriter | openOutputFile (String f) throws IOException |
Reader | getGrammarReader () |
void | reportException (Exception e, String message) |
void | reportProgress (String message) |
void | fatalError (String message) |
void | panic () |
void | panic (String s) |
File | parent (File f) |
String | pathToFile (String f) |
void | setArgOK (int i) |
void | setOutputDirectory (String o) |
void | toolError (String s) |
void | warning (String s) |
void | warning (String s, String file, int line, int column) |
void | warning (String[] s, String file, int line, int column) |
void | setNameSpace (String name) |
Static Public Member Functions | |
static void | main (String[] args) |
static Vector | parseSeparatedList (String list, char separator) |
Static Public Attributes | |
static String | version = "" |
Protected Member Functions | |
void | checkForInvalidArguments (String[] args, BitSet cmdLineArgValid) |
void | processArguments (String[] args) |
Protected Attributes | |
boolean | hasError = false |
String | outputDir = "." |
String | grammarFile |
String | literalsPrefix = "LITERAL_" |
boolean | upperCaseMangledLiterals = false |
NameSpace | nameSpace = null |
String | namespaceAntlr = null |
String | namespaceStd = null |
boolean | genHashLines = true |
boolean | noConstructors = false |
Package Attributes | |
ToolErrorHandler | errorHandler |
boolean | genDiagnostics = false |
boolean | genDocBook = false |
boolean | genHTML = false |
transient Reader | f = new InputStreamReader(System.in) |
antlr.Tool.Tool | ( | ) |
void antlr.Tool.checkForInvalidArguments | ( | String[] | args, | |
BitSet | cmdLineArgValid | |||
) | [protected] |
References antlr.collections.impl.BitSet.member(), and antlr.Tool.warning().
Referenced by antlr.Tool.doEverything().
void antlr.Tool.copyFile | ( | String | source_name, | |
String | dest_name | |||
) | throws IOException |
This example is from the book _Java in a Nutshell_ by David Flanagan. Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied.
References antlr.Tool.parent().
int antlr.Tool.doEverything | ( | String[] | args | ) |
Process args and have ANTLR do it's stuff without calling System.exit. Just return the result code. Makes it easy for ANT build tool.
References antlr.Tool.checkForInvalidArguments(), antlr.Tool.f, antlr.Tool.fatalError(), antlr.CodeGenerator.gen(), antlr.Tool.getGrammarReader(), antlr.Tool.getLanguage(), antlr.ANTLRParser.grammar(), antlr.Tool.grammarFile, antlr.Tool.hasError(), antlr.Tool.panic(), antlr.Tool.processArguments(), antlr.CodeGenerator.setAnalyzer(), antlr.CodeGenerator.setBehavior(), antlr.Parser.setFilename(), and antlr.CodeGenerator.setTool().
Referenced by antlr.Tool.doEverythingWrapper(), and antlr.Tool.main().
void antlr.Tool.doEverythingWrapper | ( | String[] | args | ) |
Perform processing on the grammar file. Can only be called from main()
args | The command-line arguments passed to main(). This wrapper does the System.exit for use with command-line. |
References antlr.Tool.doEverything().
void antlr.Tool.error | ( | String | s | ) |
Issue an error
s | The message |
References antlr.Tool.hasError().
Referenced by antlr.MakeGrammar.abortGrammar(), antlr.RuleBlock.addExceptionSpec(), antlr.MakeGrammar.beginTree(), antlr.MakeGrammar.createNextTokenRule(), antlr.MakeGrammar.defineRuleName(), antlr.DefineGrammarSymbols.defineRuleName(), antlr.MakeGrammar.endExceptionSpec(), antlr.DefineGrammarSymbols.endOptions(), antlr.MakeGrammar.endSubRule(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.PythonCodeGenerator.genMatch(), antlr.JavaCodeGenerator.genMatch(), antlr.CSharpCodeGenerator.genMatch(), antlr.CppCodeGenerator.genMatch(), antlr.PythonCodeGenerator.genNextToken(), antlr.JavaCodeGenerator.genNextToken(), antlr.CSharpCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genNextToken(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genRuleHeader(), antlr.LLkAnalyzer.look(), antlr.PythonCodeGenerator.mapTreeId(), antlr.JavaCodeGenerator.mapTreeId(), antlr.CSharpCodeGenerator.mapTreeId(), antlr.CppCodeGenerator.mapTreeId(), antlr.MakeGrammar.oneOrMoreSubRule(), antlr.MakeGrammar.optionalSubRule(), antlr.Tool.processArguments(), antlr.MakeGrammar.refCharLiteral(), antlr.MakeGrammar.refCharRange(), antlr.MakeGrammar.refElementOption(), antlr.DefineGrammarSymbols.refHeaderAction(), antlr.MakeGrammar.refRule(), antlr.MakeGrammar.refStringLiteral(), antlr.MakeGrammar.refToken(), antlr.MakeGrammar.refTokenRange(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.AlternativeBlock.removeTrackingOfRuleRefs(), antlr.actions.python.CodeLexer.reportError(), antlr.ANTLRTokdefParser.reportError(), antlr.ANTLRParser.reportError(), antlr.actions.python.ActionLexer.reportError(), antlr.actions.java.ActionLexer.reportError(), antlr.actions.csharp.ActionLexer.reportError(), antlr.actions.cpp.ActionLexer.reportError(), antlr.ANTLRParser.setBlockElement(), antlr.DefineGrammarSymbols.setFileOption(), antlr.CodeGenerator.setGrammar(), 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(), and antlr.MakeGrammar.zeroOrMoreSubRule().
void antlr.Tool.error | ( | String | s, | |
String | file, | |||
int | line, | |||
int | column | |||
) |
Issue an error with line number information
s | The message | |
file | The file that has the error (or null) | |
line | The grammar file line number on which the error occured (or -1) | |
column | The grammar file column number on which the error occured (or -1) |
References antlr.Tool.hasError().
void antlr.Tool.fatalError | ( | String | message | ) |
An error occured that should stop the Tool from doing any work. The default implementation currently exits (via java.lang.System.exit(int) after printing an error message to stderr. However, the tools should expect that a subclass will override this to throw an unchecked exception such as java.lang.IllegalStateException or another subclass of java.lang.RuntimeException. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.
s | The message |
Referenced by antlr.Tool.doEverything(), antlr.PythonCodeGenerator.exitIfError(), antlr.JavaCodeGenerator.exitIfError(), antlr.CSharpCodeGenerator.exitIfError(), antlr.CppCodeGenerator.exitIfError(), antlr.HTMLCodeGenerator.gen(), antlr.DocBookCodeGenerator.gen(), antlr.Tool.getGrammarReader(), and antlr.Tool.panic().
String antlr.Tool.fileMinusPath | ( | String | f | ) |
boolean antlr.Tool.getGenHashLines | ( | ) |
References antlr.Tool.genHashLines.
String antlr.Tool.getGrammarFile | ( | ) |
References antlr.Tool.grammarFile.
Reader antlr.Tool.getGrammarReader | ( | ) |
References antlr.Tool.f, antlr.Tool.fatalError(), and antlr.Tool.grammarFile.
Referenced by antlr.Tool.doEverything().
String antlr.Tool.getLanguage | ( | MakeGrammar | behavior | ) |
Determine the language used for this run of ANTLR This was made a method so the subclass can override it
References antlr.Tool.genDiagnostics, antlr.Tool.genDocBook, antlr.Tool.genHTML, and antlr.DefineGrammarSymbols.language.
Referenced by antlr.Tool.doEverything().
String antlr.Tool.getLiteralsPrefix | ( | ) |
References antlr.Tool.literalsPrefix.
NameSpace antlr.Tool.getNameSpace | ( | ) |
References antlr.Tool.nameSpace.
String antlr.Tool.getNamespaceAntlr | ( | ) |
References antlr.Tool.namespaceAntlr.
String antlr.Tool.getNamespaceStd | ( | ) |
References antlr.Tool.namespaceStd.
String antlr.Tool.getOutputDirectory | ( | ) |
References antlr.Tool.outputDir.
Referenced by antlr.ImportVocabTokenManager.ImportVocabTokenManager().
boolean antlr.Tool.getUpperCaseMangledLiterals | ( | ) |
References antlr.Tool.upperCaseMangledLiterals.
boolean antlr.Tool.hasError | ( | ) |
References antlr.Tool.hasError.
Referenced by antlr.Tool.doEverything(), and antlr.Tool.error().
static void antlr.Tool.main | ( | String[] | args | ) | [static] |
References antlr.Tool.doEverything(), antlr.Tool.Tool(), and antlr.Tool.version.
PrintWriter antlr.Tool.openOutputFile | ( | String | f | ) | throws IOException |
This method is used by all code generators to create new output files. If the outputDir set by -o is not present it will be created here.
References antlr.Tool.f, and antlr.Tool.outputDir.
Referenced by antlr.DefaultJavaCodeGeneratorPrintWriterManager.finishOutput(), antlr.HTMLCodeGenerator.gen(), antlr.DocBookCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.gen(), antlr.CppCodeGenerator.genBody(), antlr.CppCodeGenerator.genInclude(), antlr.CodeGenerator.genTokenInterchange(), antlr.HTMLCodeGenerator.genTokenTypes(), antlr.DocBookCodeGenerator.genTokenTypes(), antlr.DiagnosticCodeGenerator.genTokenTypes(), antlr.CppCodeGenerator.genTokenTypes(), antlr.PythonCodeGenerator.setupOutput(), antlr.DefaultJavaCodeGeneratorPrintWriterManager.setupOutput(), and antlr.CSharpCodeGenerator.setupOutput().
void antlr.Tool.panic | ( | ) |
Issue an unknown fatal error. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.
fatalError("panic");
. References antlr.Tool.fatalError().
Referenced by antlr.MakeGrammar.beginExceptionGroup(), antlr.SimpleTokenManager.clone(), antlr.Tool.doEverything(), antlr.MakeGrammar.endExceptionSpec(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.CSharpCodeGenerator.genTokenDefinitions(), antlr.PythonCodeGenerator.genTokenTypes(), antlr.JavaCodeGenerator.genTokenTypes(), antlr.CppCodeGenerator.genTokenTypes(), antlr.PythonCodeGenerator.getRangeExpression(), antlr.JavaCodeGenerator.getRangeExpression(), antlr.CSharpCodeGenerator.getRangeExpression(), antlr.CppCodeGenerator.getRangeExpression(), antlr.ImportVocabTokenManager.ImportVocabTokenManager(), antlr.LLkAnalyzer.look(), antlr.PythonCodeGenerator.processActionCode(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), antlr.JavaCodeGenerator.processActionForSpecialSymbols(), antlr.CSharpCodeGenerator.processActionForSpecialSymbols(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.MakeGrammar.refExceptionHandler(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.RuleBlock.setOption(), antlr.DefineGrammarSymbols.startLexer(), antlr.DefineGrammarSymbols.startParser(), antlr.DefineGrammarSymbols.startTreeWalker(), and antlr.Tool.warning().
void antlr.Tool.panic | ( | String | s | ) |
Issue a fatal error message. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.
fatalError("panic: " + s);
. s | The message |
References antlr.Tool.fatalError().
File antlr.Tool.parent | ( | File | f | ) |
Referenced by antlr.Tool.copyFile().
static Vector antlr.Tool.parseSeparatedList | ( | String | list, | |
char | separator | |||
) | [static] |
Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements.
References antlr.collections.impl.Vector.appendElement(), and antlr.collections.impl.Vector.size().
String antlr.Tool.pathToFile | ( | String | f | ) |
given a filename, strip off the directory prefix (if any) and return it. Return "./" if f has no dir prefix.
void antlr.Tool.processArguments | ( | String[] | args | ) | [protected] |
Process the command-line arguments. Can only be called by Tool. A bitset is collected of all correct arguments via setArgOk.
args | The command-line arguments passed to main() |
References antlr.Tool.error(), antlr.Tool.genDiagnostics, antlr.Tool.genDocBook, antlr.Tool.genHTML, antlr.Tool.grammarFile, antlr.Tool.setArgOK(), and antlr.Tool.setOutputDirectory().
Referenced by antlr.Tool.doEverything().
void antlr.Tool.reportException | ( | Exception | e, | |
String | message | |||
) |
void antlr.Tool.reportProgress | ( | String | message | ) |
void antlr.Tool.setArgOK | ( | int | i | ) |
void antlr.Tool.setFileLineFormatter | ( | FileLineFormatter | formatter | ) |
void antlr.Tool.setNameSpace | ( | String | name | ) |
Support C++ & C# namespaces (for now). C++: Add a nested namespace name to the current namespace. C# : Specify an enclosing namespace for the generated code. DAW: David Wagner -- C# support by kunle odutola
References antlr.Tool.nameSpace.
Referenced by antlr.DefineGrammarSymbols.setFileOption().
void antlr.Tool.setOutputDirectory | ( | String | o | ) |
References antlr.Tool.outputDir.
Referenced by antlr.Tool.processArguments().
void antlr.Tool.toolError | ( | String | s | ) |
Issue an error; used for general tool errors not for grammar stuff
s | The message |
void antlr.Tool.warning | ( | String | s | ) |
Issue a warning
s | the message |
Referenced by antlr.Tool.checkForInvalidArguments(), antlr.DefineGrammarSymbols.defineToken(), antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), antlr.DefineGrammarSymbols.endOptions(), antlr.CodeGenerator.extractIdOfAction(), antlr.CodeGenerator.extractTypeOfAction(), 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.genNextToken(), antlr.JavaCodeGenerator.genNextToken(), antlr.CSharpCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genNextToken(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CodeGenerator.genTokenInterchange(), antlr.CppCodeGenerator.getASTCreateString(), antlr.ANTLRParser.lexerSpec(), antlr.ANTLRParser.parserSpec(), antlr.MakeGrammar.refCharLiteral(), antlr.MakeGrammar.refCharRange(), antlr.MakeGrammar.refReturnAction(), antlr.MakeGrammar.refStringLiteral(), antlr.actions.python.CodeLexer.reportWarning(), antlr.ANTLRTokdefParser.reportWarning(), antlr.ANTLRParser.reportWarning(), antlr.actions.python.ActionLexer.reportWarning(), antlr.actions.java.ActionLexer.reportWarning(), antlr.actions.csharp.ActionLexer.reportWarning(), antlr.actions.cpp.ActionLexer.reportWarning(), antlr.LexerGrammar.setOption(), antlr.DefaultToolErrorHandler.warnAltAmbiguity(), and antlr.DefaultToolErrorHandler.warnAltExitAmbiguity().
void antlr.Tool.warning | ( | String[] | s, | |
String | file, | |||
int | line, | |||
int | column | |||
) |
Issue a warning with line number information
s | The lines of the message | |
file | The file that has the warning | |
line | The grammar file line number on which the warning occured |
References antlr.Tool.panic().
void antlr.Tool.warning | ( | String | s, | |
String | file, | |||
int | line, | |||
int | column | |||
) |
Issue a warning with line number information
s | The message | |
file | The file that has the warning (or null) | |
line | The grammar file line number on which the warning occured (or -1) | |
column | The grammar file line number on which the warning occured (or -1) |
ToolErrorHandler antlr.Tool.errorHandler [package] |
Object that handles analysis errors
Referenced by antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), and antlr.Tool.Tool().
transient Reader antlr.Tool.f = new InputStreamReader(System.in) [package] |
Referenced by antlr.Tool.doEverything(), antlr.Tool.getGrammarReader(), and antlr.Tool.openOutputFile().
boolean antlr.Tool.genDiagnostics = false [package] |
Generate diagnostics? (vs code)
Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().
boolean antlr.Tool.genDocBook = false [package] |
Generate DocBook vs code?
Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().
boolean antlr.Tool.genHashLines = true [protected] |
Referenced by antlr.Tool.getGenHashLines(), and antlr.DefineGrammarSymbols.setFileOption().
boolean antlr.Tool.genHTML = false [package] |
Generate HTML vs code?
Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().
String antlr.Tool.grammarFile [protected] |
Referenced by antlr.Tool.doEverything(), antlr.PythonCodeGenerator.genHeader(), antlr.JavaCodeGenerator.genHeader(), antlr.HTMLCodeGenerator.genHeader(), antlr.DocBookCodeGenerator.genHeader(), antlr.DiagnosticCodeGenerator.genHeader(), antlr.CSharpCodeGenerator.genHeader(), antlr.CppCodeGenerator.genHeader(), antlr.CppCodeGenerator.genLineNo(), antlr.CodeGenerator.genTokenInterchange(), antlr.Tool.getGrammarFile(), antlr.Tool.getGrammarReader(), and antlr.Tool.processArguments().
boolean antlr.Tool.hasError = false [protected] |
Was there an error during parsing or analysis?
Referenced by antlr.PythonCodeGenerator.exitIfError(), antlr.JavaCodeGenerator.exitIfError(), antlr.CSharpCodeGenerator.exitIfError(), antlr.CppCodeGenerator.exitIfError(), antlr.HTMLCodeGenerator.gen(), antlr.DocBookCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.gen(), and antlr.Tool.hasError().
String antlr.Tool.literalsPrefix = "LITERAL_" [protected] |
Referenced by antlr.Tool.getLiteralsPrefix(), and antlr.DefineGrammarSymbols.setFileOption().
NameSpace antlr.Tool.nameSpace = null [protected] |
C++ file level options
Referenced by antlr.Tool.getNameSpace(), and antlr.Tool.setNameSpace().
String antlr.Tool.namespaceAntlr = null [protected] |
Referenced by antlr.Tool.getNamespaceAntlr(), and antlr.DefineGrammarSymbols.setFileOption().
String antlr.Tool.namespaceStd = null [protected] |
Referenced by antlr.Tool.getNamespaceStd(), and antlr.DefineGrammarSymbols.setFileOption().
boolean antlr.Tool.noConstructors = false [protected] |
Referenced by antlr.DefineGrammarSymbols.setFileOption().
String antlr.Tool.outputDir = "." [protected] |
Current output directory for generated files
Referenced by antlr.Tool.getOutputDirectory(), antlr.Tool.openOutputFile(), and antlr.Tool.setOutputDirectory().
boolean antlr.Tool.upperCaseMangledLiterals = false [protected] |
Referenced by antlr.Tool.getUpperCaseMangledLiterals(), and antlr.DefineGrammarSymbols.setFileOption().
String antlr.Tool.version = "" [static] |