antlr
Class Tool

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

public class Tool
extends Object

Untamed:


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


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 String outputDir
Current output directory for generated files


grammarFile

String grammarFile

f

transient Reader f

literalsPrefix

protected static String literalsPrefix

upperCaseMangledLiterals

protected static boolean upperCaseMangledLiterals

nameSpace

protected static NameSpace nameSpace
C++ file level options


namespaceAntlr

protected static String namespaceAntlr

namespaceStd

protected static String namespaceStd

genHashLines

protected static boolean genHashLines

cmdLineArgValid

private static BitSet cmdLineArgValid
Constructor Detail

Tool

public Tool()
Enabled: Construct a new Tool.

Method Detail

setFileLineFormatter

public static void setFileLineFormatter(FileLineFormatter formatter)
Enabled:


checkForInvalidArguments

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

copyFile

public static void copyFile(String source_name,
                            String dest_name)
                     throws IOException
Enabled: 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.

IOException

doEverything

protected void doEverything(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(String s)
Enabled: Issue an error

Parameters:
s - The message

error

public void error(String s,
                  String file,
                  int line)
Enabled: 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 Object factory(String p)
Enabled: When we are 1.1 compatible... static public 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 String fileMinusPath(String f)
Enabled:


getLanguage

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


getOutputDirectory

public static String getOutputDirectory()
Enabled:


help

private static void help()

main

public static void main(String[] args)
Enabled:


openOutputFile

public static PrintWriter openOutputFile(String f)
                                  throws IOException
Enabled:

IOException

getGrammarReader

public Reader getGrammarReader()
Enabled:


panic

public static void panic()
Enabled: Issue an unknown fatal error


panic

public static void panic(String s)
Enabled: Issue a fatal error message

Parameters:
s - The message

parent

public static File parent(File f)
Enabled:


parseSeparatedList

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


pathToFile

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


processArguments

private void processArguments(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)
Enabled:


setOutputDirectory

public static void setOutputDirectory(String o)
Enabled:


stripBack

public static String stripBack(String s,
                               char c)
Enabled: 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 String stripBack(String s,
                               String remove)
Enabled: 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 String stripFront(String s,
                                char c)
Enabled: 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 String stripFront(String s,
                                String remove)
Enabled: 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 String stripFrontBack(String src,
                                    String head,
                                    String tail)
Enabled: 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(String s)
Enabled: Issue an error; used for general tool errors not for grammar stuff

Parameters:
s - The message

warning

public static void warning(String s)
Enabled: Issue a warning

Parameters:
s - the message

warning

public static void warning(String s,
                           String file,
                           int line)
Enabled: 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(String[] s,
                           String file,
                           int line)
Enabled: 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(String name)
Enabled: Support C++ namespaces (for now). Add a nested namespace name to the current namespace. DAW: David Wagner



comments?