org.antlr
Class Tool

java.lang.Object
  extended by org.antlr.Tool

public class Tool
extends java.lang.Object

The main ANTLR entry point. Read a grammar and generate a parser.


Field Summary
protected  boolean debug
           
protected  boolean depend
           
protected  boolean forceAllFilesToOutputDir
           
protected  boolean generate_DFA_dot
           
protected  boolean generate_NFA_dot
           
protected  java.util.List grammarFileNames
           
static boolean internalOption_PrintDFA
           
static boolean internalOption_PrintGrammarTree
           
static boolean internalOption_ShowNFConfigsInDFA
           
static boolean internalOption_watchNFAConversion
           
protected  java.lang.String libDirectory
           
protected  java.lang.String outputDirectory
           
protected  boolean printGrammar
           
protected  boolean profile
           
protected  boolean report
           
protected  boolean trace
           
static java.lang.String UNINITIALIZED_DIR
           
static java.lang.String VERSION
           
 
Constructor Summary
Tool()
           
Tool(java.lang.String[] args)
           
 
Method Summary
protected  void generateDFAs(Grammar g)
           
protected  void generateNFAs(Grammar g)
           
static java.lang.String getCurrentTimeStamp()
          Return a time stamp string accurate to sec: yyyy-mm-dd hh:mm:ss
 java.lang.String getFileDirectory(java.lang.String fileName)
          Return the directory containing the grammar file for this grammar.
 Grammar getGrammar(java.lang.String grammarFileName)
           
 java.lang.String getLibraryDirectory()
           
 java.io.BufferedReader getLibraryFile(java.lang.String fileName)
          Open a file in the -lib dir.
 java.io.File getOutputDirectory(java.lang.String fileNameWithPath)
           
 java.io.Writer getOutputFile(Grammar g, java.lang.String fileName)
          This method is used by all code generators to create new output files.
static void main(java.lang.String[] args)
           
 void panic()
          If the tool needs to panic/exit, how do we do that?
 void process()
           
 void processArgs(java.lang.String[] args)
           
protected  void processGrammar(Grammar grammar)
           
 void setOutputDirectory(java.lang.String outputDirectory)
           
protected  void writeDOTFile(Grammar g, java.lang.String name, java.lang.String dot)
           
 
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

UNINITIALIZED_DIR

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

grammarFileNames

protected java.util.List grammarFileNames

generate_NFA_dot

protected boolean generate_NFA_dot

generate_DFA_dot

protected boolean generate_DFA_dot

outputDirectory

protected java.lang.String outputDirectory

libDirectory

protected java.lang.String libDirectory

debug

protected boolean debug

trace

protected boolean trace

profile

protected boolean profile

report

protected boolean report

printGrammar

protected boolean printGrammar

depend

protected boolean depend

forceAllFilesToOutputDir

protected boolean forceAllFilesToOutputDir

internalOption_PrintGrammarTree

public static boolean internalOption_PrintGrammarTree

internalOption_PrintDFA

public static boolean internalOption_PrintDFA

internalOption_ShowNFConfigsInDFA

public static boolean internalOption_ShowNFConfigsInDFA

internalOption_watchNFAConversion

public static boolean internalOption_watchNFAConversion
Constructor Detail

Tool

public Tool()

Tool

public Tool(java.lang.String[] args)
Method Detail

main

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

processArgs

public void processArgs(java.lang.String[] args)

process

public void process()

getGrammar

public Grammar getGrammar(java.lang.String grammarFileName)
                   throws java.io.IOException,
                          antlr.TokenStreamException,
                          antlr.RecognitionException
Throws:
java.io.IOException
antlr.TokenStreamException
antlr.RecognitionException

processGrammar

protected void processGrammar(Grammar grammar)

generateDFAs

protected void generateDFAs(Grammar g)

generateNFAs

protected void generateNFAs(Grammar g)

writeDOTFile

protected void writeDOTFile(Grammar g,
                            java.lang.String name,
                            java.lang.String dot)
                     throws java.io.IOException
Throws:
java.io.IOException

setOutputDirectory

public void setOutputDirectory(java.lang.String outputDirectory)

getOutputFile

public java.io.Writer getOutputFile(Grammar g,
                                    java.lang.String fileName)
                             throws java.io.IOException
This method is used by all code generators to create new output files. If the outputDir set by -o is not present it will be created. The final filename is sensitive to the output directory and the directory where the grammar file was found. If -o is /tmp and the original grammar file was foo/t.g then output files go in /tmp/foo. The output dir -o spec takes precedence if it's absolute. E.g., if the grammar file dir is absolute the output dir is given precendence. "-o /tmp /usr/lib/t.g" results in "/tmp/T.java" as output (assuming t.g holds T.java). If no -o is specified, then just write to the directory where the grammar file was found. If outputDirectory==null then write a String.

Throws:
java.io.IOException

getOutputDirectory

public java.io.File getOutputDirectory(java.lang.String fileNameWithPath)

getLibraryFile

public java.io.BufferedReader getLibraryFile(java.lang.String fileName)
                                      throws java.io.IOException
Open a file in the -lib dir. For now, it's just .tokens files

Throws:
java.io.IOException

getLibraryDirectory

public java.lang.String getLibraryDirectory()

getFileDirectory

public java.lang.String getFileDirectory(java.lang.String fileName)
Return the directory containing the grammar file for this grammar. normally this is a relative path from current directory. People will often do "java org.antlr.Tool grammars/*.g3" So the file will be "grammars/foo.g3" etc... This method returns "grammars".


panic

public void panic()
If the tool needs to panic/exit, how do we do that?


getCurrentTimeStamp

public static java.lang.String getCurrentTimeStamp()
Return a time stamp string accurate to sec: yyyy-mm-dd hh:mm:ss