antlr
Class Tool

java.lang.Object
  |
  +--antlr.Tool

public class Tool
extends java.lang.Object


Field Summary
private static BitSet cmdLineArgValid
           
(package private)  ToolErrorHandler errorHandler
          Object that handles analysis errors
(package private)  java.io.Reader f
           
(package private)  boolean genDiagnostics
          Generate diagnostics? (vs code)
protected static boolean genHashLines
           
(package private)  boolean genHTML
          Generate HTML vs code?
(package private)  java.lang.String grammarFile
           
protected  boolean hasError
          Was there an error during parsing or analysis?
protected static java.lang.String literalsPrefix
           
protected static NameSpace nameSpace
          C++ file level options
protected static java.lang.String namespaceAntlr
           
protected static java.lang.String namespaceStd
           
protected static java.lang.String outputDir
          Current output directory for generated files
protected static boolean upperCaseMangledLiterals
           
static java.lang.String version
           
 
Constructor Summary
Tool()
          Construct a new Tool.
 
Method Summary
private static void checkForInvalidArguments(java.lang.String[] args, BitSet cmdLineArgValid)
           
static void copyFile(java.lang.String source_name, java.lang.String dest_name)
          This example is from the book _Java in a Nutshell_ by David Flanagan.
protected  void doEverything(java.lang.String[] args)
          Perform processing on the grammar file.
 void error(java.lang.String s)
          Issue an error
 void error(java.lang.String s, java.lang.String file, int line)
          Issue an error with line number information
static java.lang.Object factory(java.lang.String p)
          When we are 1.1 compatible...
static java.lang.String fileMinusPath(java.lang.String f)
           
 java.io.Reader getGrammarReader()
           
 java.lang.String getLanguage(MakeGrammar behavior)
          Determine the language used for this run of ANTLR This was made a method so the subclass can override it
static java.lang.String getOutputDirectory()
           
private static void help()
           
static void main(java.lang.String[] args)
           
static java.io.PrintWriter openOutputFile(java.lang.String f)
           
static void panic()
          Issue an unknown fatal error
static void panic(java.lang.String s)
          Issue a fatal error message
static java.io.File parent(java.io.File f)
           
static Vector parseSeparatedList(java.lang.String list, char separator)
          Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements.
static java.lang.String pathToFile(java.lang.String f)
          given a filename, strip off the directory prefix (if any) and return it.
private  void processArguments(java.lang.String[] args)
          Process the command-line arguments.
static void setArgOK(int i)
           
static void setFileLineFormatter(FileLineFormatter formatter)
           
 void setNameSpace(java.lang.String name)
          Support C++ namespaces (for now).
static void setOutputDirectory(java.lang.String o)
           
static java.lang.String stripBack(java.lang.String s, char c)
          General-purpose utility function for removing characters from back of string
static java.lang.String stripBack(java.lang.String s, java.lang.String remove)
          General-purpose utility function for removing characters from back of string
static java.lang.String stripFront(java.lang.String s, char c)
          General-purpose utility function for removing characters from front of string
static java.lang.String stripFront(java.lang.String s, java.lang.String remove)
          General-purpose utility function for removing characters from front of string
static java.lang.String stripFrontBack(java.lang.String src, java.lang.String head, java.lang.String tail)
          General-purpose utility function for removing characters from the front and back of string
static void toolError(java.lang.String s)
          Issue an error; used for general tool errors not for grammar stuff
static void warning(java.lang.String s)
          Issue a warning
static void warning(java.lang.String[] s, java.lang.String file, int line)
          Issue a warning with line number information
static void warning(java.lang.String s, java.lang.String file, int line)
          Issue a warning with line number information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values

errorHandler

ToolErrorHandler errorHandler
Object that handles analysis errors


hasError

protected boolean hasError
Was there an error during parsing or analysis?


genDiagnostics

boolean genDiagnostics
Generate diagnostics? (vs code)


genHTML

boolean genHTML
Generate HTML vs code?


outputDir

protected static java.lang.String outputDir
Current output directory for generated files


grammarFile

java.lang.String grammarFile

f

transient java.io.Reader f

literalsPrefix

protected static java.lang.String literalsPrefix

upperCaseMangledLiterals

protected static boolean upperCaseMangledLiterals

nameSpace

protected static NameSpace nameSpace
C++ file level options


namespaceAntlr

protected static java.lang.String namespaceAntlr

namespaceStd

protected static java.lang.String namespaceStd

genHashLines

protected static boolean genHashLines

cmdLineArgValid

private static BitSet cmdLineArgValid
Constructor Detail

Tool

public Tool()
Construct a new Tool.

Method Detail

setFileLineFormatter

public static void setFileLineFormatter(FileLineFormatter formatter)

checkForInvalidArguments

private static void checkForInvalidArguments(java.lang.String[] args,
                                             BitSet cmdLineArgValid)

copyFile

public static void copyFile(java.lang.String source_name,
                            java.lang.String dest_name)
                     throws java.io.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.

java.io.IOException

doEverything

protected void doEverything(java.lang.String[] args)
Perform processing on the grammar file. Can only be called from main() @param args The command-line arguments passed to main()


error

public void error(java.lang.String s)
Issue an error

Parameters:
s - The message

error

public void error(java.lang.String s,
                  java.lang.String file,
                  int line)
Issue an error with line number information

Parameters:
s - The message
file - The file that has the error
line - The grammar file line number on which the error occured

factory

public static java.lang.Object factory(java.lang.String p)
When we are 1.1 compatible... public static Object factory2 (String p, Object[] initargs) { Class c; Object o = null; try { int argslen = initargs.length; Class cl[] = new Class[argslen]; for (int i=0;i<argslen;i++) { cl[i] = Class.forName(initargs[i].getClass().getName()); } c = Class.forName (p); Constructor con = c.getConstructor (cl); o = con.newInstance (initargs); } catch (Exception e) { System.err.println ("Can't make a " + p); } return o; }


fileMinusPath

public static java.lang.String fileMinusPath(java.lang.String f)

getLanguage

public java.lang.String getLanguage(MakeGrammar behavior)
Determine the language used for this run of ANTLR This was made a method so the subclass can override it


getOutputDirectory

public static java.lang.String getOutputDirectory()

help

private static void help()

main

public static void main(java.lang.String[] args)

openOutputFile

public static java.io.PrintWriter openOutputFile(java.lang.String f)
                                          throws java.io.IOException
java.io.IOException

getGrammarReader

public java.io.Reader getGrammarReader()

panic

public static void panic()
Issue an unknown fatal error


panic

public static void panic(java.lang.String s)
Issue a fatal error message

Parameters:
s - The message

parent

public static java.io.File parent(java.io.File f)

parseSeparatedList

public static Vector parseSeparatedList(java.lang.String list,
                                        char separator)
Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements.


pathToFile

public static java.lang.String pathToFile(java.lang.String f)
given a filename, strip off the directory prefix (if any) and return it. Return "./" if f has no dir prefix.


processArguments

private void processArguments(java.lang.String[] args)
Process the command-line arguments. Can only be called by Tool.

Parameters:
args - The command-line arguments passed to main()

setArgOK

public static void setArgOK(int i)

setOutputDirectory

public static void setOutputDirectory(java.lang.String o)

stripBack

public static java.lang.String stripBack(java.lang.String s,
                                         char c)
General-purpose utility function for removing characters from back of string

Parameters:
s - The string to process
c - The character to remove
Returns:
The resulting string

stripBack

public static java.lang.String stripBack(java.lang.String s,
                                         java.lang.String remove)
General-purpose utility function for removing characters from back of string

Parameters:
s - The string to process
remove - A string containing the set of characters to remove
Returns:
The resulting string

stripFront

public static java.lang.String stripFront(java.lang.String s,
                                          char c)
General-purpose utility function for removing characters from front of string

Parameters:
s - The string to process
c - The character to remove
Returns:
The resulting string

stripFront

public static java.lang.String stripFront(java.lang.String s,
                                          java.lang.String remove)
General-purpose utility function for removing characters from front of string

Parameters:
s - The string to process
remove - A string containing the set of characters to remove
Returns:
The resulting string

stripFrontBack

public static java.lang.String stripFrontBack(java.lang.String src,
                                              java.lang.String head,
                                              java.lang.String tail)
General-purpose utility function for removing characters from the front and back of string

Parameters:
head - exact string to strip from head
tail - exact string to strip from tail
Returns:
The resulting string

toolError

public static void toolError(java.lang.String s)
Issue an error; used for general tool errors not for grammar stuff

Parameters:
s - The message

warning

public static void warning(java.lang.String s)
Issue a warning

Parameters:
s - the message

warning

public static void warning(java.lang.String s,
                           java.lang.String file,
                           int line)
Issue a warning with line number information

Parameters:
s - The message
file - The file that has the warning
line - The grammar file line number on which the warning occured

warning

public static void warning(java.lang.String[] s,
                           java.lang.String file,
                           int line)
Issue a warning with line number information

Parameters:
s - The lines of the message
file - The file that has the warning
line - The grammar file line number on which the warning occured

setNameSpace

public void setNameSpace(java.lang.String name)
Support C++ namespaces (for now). Add a nested namespace name to the current namespace. DAW: David Wagner