| java.lang.Object xtc.util.Tool
All known Subclasses: xtc.lang.FactoryFactory, xtc.lang.jeannie.Jeannie, xtc.typical.Typical, xtc.lang.jeannie.Preprocessor, xtc.lang.TypedLambda, xtc.lang.p2.Overlog, xtc.xform.Driver, xtc.lang.Java, xtc.parser.Rats, xtc.lang.C,
Tool | abstract public class Tool (Code) | | The superclass of all tools.
author: Robert Grimm version: $Revision: 1.26 $ |
Constructor Summary | |
public | Tool() Create a new tool. |
Method Summary | |
public void | diagnose() Print tool diagnostics. | public String | getCopy() Get this tool's copyright. | public String | getExplanation() Get this tool's explanation. | abstract public String | getName() Get this tool's name. | public String | getVersion() Get this tool's version. | public void | init() Initialize this tool. | public File | locate(String name) Locate the file with the specified name. | abstract public Node | parse(Reader in, File file) Parse the specified file.
Parameters: in - The input stream for the file. Parameters: file - The corresponding file. | public void | prepare() Prepare for processing. | public void | printHeader(Printer printer) Print a tool header to the specified printer. | public void | process(Node node) Process the specified AST node. | public void | process(String name) Recursively process the file with the specified name. | public void | run(String[] args) Run this tool with the specified command line arguments. | public void | wrapUp() Wrap up this tool. |
Tool | public Tool()(Code) | | Create a new tool.
|
diagnose | public void diagnose()(Code) | | Print tool diagnostics. The default implementation of this
method does nothing.
|
getExplanation | public String getExplanation()(Code) | | Get this tool's explanation. This method should return any text
to print after this tool's description of options. The text is
automatically line-wrapped. The default implementation returns
null to indicate that there is no explanation.
The explanation. |
getName | abstract public String getName()(Code) | | Get this tool's name.
The name. |
init | public void init()(Code) | | Initialize this tool. This method declares this tool's command
line options. The default implementation declares
- a boolean option
optionSilent for silent
operation,
- a boolean option
optionVerbose for verbose
operation,
- a boolean option
optionNoExit for not exiting
the Java virtual machine,
- a multiple directory option
Runtime.INPUT_DIRECTORY for the file search path,
- a directory option
Runtime.OUTPUT_DIRECTORY for the
output directory,
- a word option
Runtime.INPUT_ENCODING for the
character encoding when reading files,
- a word option
Runtime.OUTPUT_ENCODING for the
character encoding when writing files,
-
- a boolean option
optionDiagnostics for printing
tool diagnostics,
- a boolean option
optionPerformance for
collecting performance statistics,
- a boolean option
optionMeasureParser for
measuring parser performance only.
- a boolean option
optionMeasureProcessing for
measuring processing performance only.
- a boolean option
optionGC for performing
GC,
- an integer option
runsWarmUp with a default of 2
for the number of warm-up runs,
- and an integer option
runsTotal with a default
of 12 for the total number of runs.
|
locate | public File locate(String name) throws IOException(Code) | | Locate the file with the specified name. The default
implementation simply looks in the current directory, ignoring
any directories in the tool's search path.
See Also: Runtime.locate(String) Parameters: name - The file name. The corresponding file. throws: IllegalArgumentException - Signals an inappropriate file(e.g., one that is too large). throws: IOException - Signals an I/O error. |
parse | abstract public Node parse(Reader in, File file) throws IOException, ParseException(Code) | | Parse the specified file.
Parameters: in - The input stream for the file. Parameters: file - The corresponding file. The AST corresponding to the file's contents, ornull if no tree has been generated. throws: IllegalArgumentException - Signals an inappropriate file(e.g., one that is too large). throws: IOException - Signals an I/O error. throws: ParseException - Signals a parse error. |
prepare | public void prepare()(Code) | | Prepare for processing. This method prepares for actually
processing files, for example, by performing consistency checks
between command line arguments and by initializing all default
values not specified on the command line. The default
implementation invokes
Runtime.initDefaultValues . It
also checks that the optionSilent and
optionVerbose flags are not both set at the same
time.
See Also: Tool.wrapUp() |
printHeader | public void printHeader(Printer printer)(Code) | | Print a tool header to the specified printer. This method prints
a header documenting the tool name, version, copyright, and
current time. It also prints a warning not to edit the result.
Parameters: printer - The printer. |
run | public void run(String[] args)(Code) | | Run this tool with the specified command line arguments. This
method works as following:
- It calls
Tool.init() to initialize this tool.
- It prints the
Tool.getName() name ,
Tool.getVersion()version , and
Tool.getCopy() copyright to the
Runtime.console console .
- If this tool has been invoked without arguments, it prints a
description of all command line
Runtime.printOptionsoptions and, optionally, an
Tool.getExplanation()explanation . It then exits.
- It
Runtime.process(String[]) processes the specified
command line arguments and
Tool.prepare() prepares for
processing the files. If any errors have been
Runtime.seenError reported during the two method calls, it
exits.
- For each file name specified on the command line, it
Tool.locate(String) locates the file,
Tool.parse(Reader,File)parses the contents, and
Tool.process(Node) processes the
resulting AST. If the
-performance command line
option has been specified, it repeatedly parses and processes
each file, measuring both latency and heap utilization. It then
exits.
Parameters: args - The command line arguments. |
wrapUp | public void wrapUp()(Code) | | Wrap up this tool. This method is invoked after all files have
been processed. The default implementation does nothing.
|
|
|