Package antlr
Class Tool
java.lang.Object
antlr.Tool
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ToolErrorHandlerObject that handles analysis errors(package private) Reader(package private) booleanGenerate diagnostics? (vs code)(package private) booleanGenerate DocBook vs code?protected boolean(package private) booleanGenerate HTML vs code?protected Stringprotected booleanWas there an error during parsing or analysis?protected Stringprotected NameSpaceC++ file level optionsprotected Stringprotected Stringprotected booleanprotected StringCurrent output directory for generated filesprotected booleanstatic String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckForInvalidArguments(String[] args, BitSet cmdLineArgValid) voidThis example is from the book _Java in a Nutshell_ by David Flanagan.intdoEverything(String[] args) Process args and have ANTLR do it's stuff without calling System.exit.voiddoEverythingWrapper(String[] args) Perform processing on the grammar file.voidIssue an errorvoidIssue an error with line number informationvoidfatalError(String message) An error occured that should stop the Tool from doing any work.booleangetLanguage(MakeGrammar behavior) Determine the language used for this run of ANTLR This was made a method so the subclass can override itbooleanbooleanhasError()static voidThis method is used by all code generators to create new output files.voidpanic()Deprecated.voidDeprecated.as of 2.7.2 usefatalError(String).static VectorparseSeparatedList(String list, char separator) Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements.pathToFile(String f) given a filename, strip off the directory prefix (if any) and return it.protected voidprocessArguments(String[] args) Process the command-line arguments.voidreportException(Exception e, String message) voidreportProgress(String message) voidsetArgOK(int i) voidsetFileLineFormatter(FileLineFormatter formatter) voidsetNameSpace(String name) Support C++ invalid input: '&' C# namespaces (for now).voidvoidIssue an error; used for general tool errors not for grammar stuffvoidIssue a warningvoidIssue a warning with line number informationvoidIssue a warning with line number information
-
Field Details
-
version
-
errorHandler
ToolErrorHandler errorHandlerObject that handles analysis errors -
hasError
protected boolean hasErrorWas there an error during parsing or analysis? -
genDiagnostics
boolean genDiagnosticsGenerate diagnostics? (vs code) -
genDocBook
boolean genDocBookGenerate DocBook vs code? -
genHTML
boolean genHTMLGenerate HTML vs code? -
outputDir
Current output directory for generated files -
grammarFile
-
f
-
literalsPrefix
-
upperCaseMangledLiterals
protected boolean upperCaseMangledLiterals -
nameSpace
C++ file level options -
namespaceAntlr
-
namespaceStd
-
genHashLines
protected boolean genHashLines -
noConstructors
protected boolean noConstructors
-
-
Constructor Details
-
Tool
public Tool()Construct a new Tool.
-
-
Method Details
-
getGrammarFile
-
hasError
public boolean hasError() -
getNameSpace
-
getNamespaceStd
-
getNamespaceAntlr
-
getGenHashLines
public boolean getGenHashLines() -
getLiteralsPrefix
-
getUpperCaseMangledLiterals
public boolean getUpperCaseMangledLiterals() -
setFileLineFormatter
-
checkForInvalidArguments
-
copyFile
This example is from the book _Java in a Nutshell_ by David Flanagan. Written by David Flanagan. Copyright (c) 1996 O'Reilly invalid input: '&' Associates. You may study, use, modify, and distribute this example for any purpose. This example is provided WITHOUT WARRANTY either expressed or implied.- Throws:
IOException
-
doEverythingWrapper
Perform processing on the grammar file. Can only be called from main() @param args The command-line arguments passed to main(). This wrapper does the System.exit for use with command-line. -
doEverything
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. -
error
Issue an error- Parameters:
s- The message
-
error
Issue an error with line number information- Parameters:
s- The messagefile- 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)
-
fileMinusPath
-
getLanguage
Determine the language used for this run of ANTLR This was made a method so the subclass can override it -
getOutputDirectory
-
main
-
openOutputFile
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.- Throws:
IOException
-
getGrammarReader
-
reportException
- Since:
- 2.7.2
-
reportProgress
- Since:
- 2.7.2
-
fatalError
An error occured that should stop the Tool from doing any work. The default implementation currently exits (via} after printing an error message to stderr. However, the tools should expect that a subclass will override this to throw an unchecked exception such asinvalid @link
{@link java.lang.System.exit(int)IllegalStateExceptionor another subclass ofRuntimeException. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.- Parameters:
s- The message- Since:
- 2.7.2
-
panic
public void panic()Deprecated.as of 2.7.2 usefatalError(String). By default this method executesfatalError("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. -
panic
Deprecated.as of 2.7.2 usefatalError(String). By defaykt this method executesfatalError("panic: " + 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.- Parameters:
s- The message
-
parent
-
parseSeparatedList
Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements. -
pathToFile
given a filename, strip off the directory prefix (if any) and return it. Return "./" if f has no dir prefix. -
processArguments
Process the command-line arguments. Can only be called by Tool. A bitset is collected of all correct arguments via setArgOk.
- Parameters:
args- The command-line arguments passed to main()
-
setArgOK
public void setArgOK(int i) -
setOutputDirectory
-
toolError
Issue an error; used for general tool errors not for grammar stuff- Parameters:
s- The message
-
warning
Issue a warning- Parameters:
s- the message
-
warning
Issue a warning with line number information- Parameters:
s- The messagefile- 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)
-
warning
Issue a warning with line number information- Parameters:
s- The lines of the messagefile- The file that has the warningline- The grammar file line number on which the warning occured
-
setNameSpace
Support C++ invalid input: '&' 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
-
fatalError(String).