xtc.parser
Class Rats

java.lang.Object
  extended by xtc.util.Tool
      extended by xtc.parser.Rats

public class Rats
extends Tool

The command line interface to Rats!, the packrat parser generator for Java.

Version:
$Revision: 1.189 $

Field Summary
 
Fields inherited from class xtc.util.Tool
runtime
 
Constructor Summary
Rats()
          Create a new instance of Rats!.
 
Method Summary
 String getCopy()
          Get this tool's copyright.
 String getExplanation()
          Get this tool's explanation.
 String getName()
          Get this tool's name.
 void init()
          Initialize this tool.
static void main(String[] args)
          Run the packrat parser generator with the specified arguments.
 Node parse(Reader in, File file)
          Parse the specified file.
 void prepare()
          Prepare for processing.
 void process(Node node)
          Process the specified AST node.
 
Methods inherited from class xtc.util.Tool
diagnose, getVersion, locate, printHeader, process, run, wrapUp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rats

public Rats()
Create a new instance of Rats!.

Method Detail

getName

public String getName()
Description copied from class: Tool
Get this tool's name.

Specified by:
getName in class Tool
Returns:
The name.

getCopy

public String getCopy()
Description copied from class: Tool
Get this tool's copyright. The default implementation returns Constants.FULL_COPY.

Overrides:
getCopy in class Tool
Returns:
The copyright.

getExplanation

public String getExplanation()
Description copied from class: Tool
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.

Overrides:
getExplanation in class Tool
Returns:
The explanation.

init

public void init()
Description copied from class: Tool
Initialize this tool. This method declares this tool's command line options. The default implementation declares

Overrides:
init in class Tool

prepare

public void prepare()
Description copied from class: Tool
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.

Overrides:
prepare in class Tool
See Also:
Tool.wrapUp()

parse

public Node parse(Reader in,
                  File file)
           throws IOException,
                  ParseException
Description copied from class: Tool
Parse the specified file.

Specified by:
parse in class Tool
Parameters:
in - The input stream for the file.
file - The corresponding file.
Returns:
The AST corresponding to the file's contents, or null if no tree has been generated.
Throws:
IOException - Signals an I/O error.
ParseException - Signals a parse error.

process

public void process(Node node)
Description copied from class: Tool
Process the specified AST node. This method is only invoked if Tool.parse(Reader,File) has completed successfuly, has returned a node (and not null), and no errors have been reported through Runtime.error(), Runtime.error(String), or Runtime.error(String,Node) while parsing. The default implementation of this method does nothing.

Overrides:
process in class Tool
Parameters:
node - The node.

main

public static void main(String[] args)
Run the packrat parser generator with the specified arguments. Invoking Rats! without arguments will print information about its usage.

Parameters:
args - The command line arguments.


(C) Copyright 2004-2007 Robert Grimm, New York University, IBM, and Princeton