public class Tool extends Object
Modifier and Type | Field and Description |
---|---|
(package private) ToolErrorHandler |
errorHandler
Object that handles analysis errors
|
(package private) Reader |
f |
(package private) boolean |
genDiagnostics
Generate diagnostics? (vs code)
|
(package private) boolean |
genDocBook
Generate DocBook vs code?
|
protected boolean |
genHashLines |
(package private) boolean |
genHTML
Generate HTML vs code?
|
protected String |
grammarFile |
protected boolean |
hasError
Was there an error during parsing or analysis?
|
protected String |
literalsPrefix |
protected NameSpace |
nameSpace
C++ file level options
|
protected String |
namespaceAntlr |
protected String |
namespaceStd |
protected boolean |
noConstructors |
protected String |
outputDir
Current output directory for generated files
|
protected boolean |
upperCaseMangledLiterals |
static String |
version |
Constructor and Description |
---|
Tool()
Construct a new Tool.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkForInvalidArguments(String[] args,
BitSet cmdLineArgValid) |
void |
copyFile(String source_name,
String dest_name)
This example is from the book _Java in a Nutshell_ by David
Flanagan.
|
int |
doEverything(String[] args)
Process args and have ANTLR do it's stuff without calling System.exit.
|
void |
doEverythingWrapper(String[] args)
Perform processing on the grammar file.
|
void |
error(String s)
Issue an error
|
void |
error(String s,
String file,
int line,
int column)
Issue an error with line number information
|
void |
fatalError(String message)
An error occured that should stop the Tool from doing any work.
|
String |
fileMinusPath(String f) |
boolean |
getGenHashLines() |
String |
getGrammarFile() |
Reader |
getGrammarReader() |
String |
getLanguage(MakeGrammar behavior)
Determine the language used for this run of ANTLR
This was made a method so the subclass can override it
|
String |
getLiteralsPrefix() |
NameSpace |
getNameSpace() |
String |
getNamespaceAntlr() |
String |
getNamespaceStd() |
String |
getOutputDirectory() |
boolean |
getUpperCaseMangledLiterals() |
boolean |
hasError() |
static void |
main(String[] args) |
PrintWriter |
openOutputFile(String f)
This method is used by all code generators to create new output
files.
|
void |
panic()
Deprecated.
as of 2.7.2 use
fatalError(String) . By default
this method executes fatalError("panic"); . |
void |
panic(String s)
Deprecated.
as of 2.7.2 use
fatalError(String) . By defaykt
this method executes fatalError("panic: " + s); . |
File |
parent(File f) |
static Vector |
parseSeparatedList(String list,
char separator)
Parse a list such as "f1.g;f2.g;..." and return a Vector
of the elements.
|
String |
pathToFile(String f)
given a filename, strip off the directory prefix (if any)
and return it.
|
protected void |
processArguments(String[] args)
Process the command-line arguments.
|
void |
reportException(Exception e,
String message) |
void |
reportProgress(String message) |
void |
setArgOK(int i) |
void |
setFileLineFormatter(FileLineFormatter formatter) |
void |
setNameSpace(String name)
Support C++ & C# namespaces (for now).
|
void |
setOutputDirectory(String o) |
void |
toolError(String s)
Issue an error; used for general tool errors not for grammar stuff
|
void |
warning(String s)
Issue a warning
|
void |
warning(String[] s,
String file,
int line,
int column)
Issue a warning with line number information
|
void |
warning(String s,
String file,
int line,
int column)
Issue a warning with line number information
|
public static String version
ToolErrorHandler errorHandler
protected boolean hasError
boolean genDiagnostics
boolean genDocBook
boolean genHTML
protected String outputDir
protected String grammarFile
transient Reader f
protected String literalsPrefix
protected boolean upperCaseMangledLiterals
protected NameSpace nameSpace
protected String namespaceAntlr
protected String namespaceStd
protected boolean genHashLines
protected boolean noConstructors
public String getGrammarFile()
public boolean hasError()
public NameSpace getNameSpace()
public String getNamespaceStd()
public String getNamespaceAntlr()
public boolean getGenHashLines()
public String getLiteralsPrefix()
public boolean getUpperCaseMangledLiterals()
public void setFileLineFormatter(FileLineFormatter formatter)
protected void checkForInvalidArguments(String[] args, BitSet cmdLineArgValid)
public void copyFile(String source_name, String dest_name) throws IOException
IOException
public void doEverythingWrapper(String[] args)
public int doEverything(String[] args)
public void error(String s)
s
- The messagepublic void error(String s, String file, int line, int column)
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)public String getLanguage(MakeGrammar behavior)
public String getOutputDirectory()
public static void main(String[] args)
public PrintWriter openOutputFile(String f) throws IOException
IOException
public Reader getGrammarReader()
public void reportProgress(String message)
public void fatalError(String message)
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
IllegalStateException
or another subclass of
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 messagepublic void panic()
fatalError(String)
. By default
this method executes fatalError("panic");
.public void panic(String s)
fatalError(String)
. By defaykt
this method executes fatalError("panic: " + s);
.s
- The messagepublic static Vector parseSeparatedList(String list, char separator)
public String pathToFile(String f)
protected void processArguments(String[] args)
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()public void setArgOK(int i)
public void setOutputDirectory(String o)
public void toolError(String s)
s
- The messagepublic void warning(String s)
s
- the messagepublic void warning(String s, String file, int line, int column)
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)public void warning(String[] s, String file, int line, int column)
s
- The lines of the messagefile
- The file that has the warningline
- The grammar file line number on which the warning occuredpublic void setNameSpace(String name)