public class Tool extends Object
Modifier and Type | Field | Description |
---|---|---|
Properties |
antlrSettings |
|
protected boolean |
deleteTempLexer |
|
String |
forcedLanguageOption |
|
static boolean |
internalOption_PrintDFA |
|
static boolean |
internalOption_PrintGrammarTree |
|
static boolean |
internalOption_ShowNFAConfigsInDFA |
|
static boolean |
internalOption_watchNFAConversion |
|
static String |
UNINITIALIZED_DIR |
|
String |
VERSION |
Modifier and Type | Method | Description |
---|---|---|
void |
addGrammarFile(String grammarFileName) |
|
boolean |
buildRequired(String grammarFileName) |
Checks to see if the list of outputFiles all exist, and have
last-modified timestamps which are later than the last-modified
timestamp of all the grammar files involved in build the output
(imports must be checked).
|
void |
generateDFAs(Grammar g) |
|
protected void |
generateNFAs(Grammar g) |
|
protected void |
generateRecognizer(Grammar grammar) |
Create NFA, DFA and generate code for grammar.
|
int |
getConversionTimeout() |
Provide the current setting of the conversion timeout on DFA creation.
|
static String |
getCurrentTimeStamp() |
Return a time stamp string accurate to sec: yyyy-mm-dd hh:mm:ss
|
String |
getFileDirectory(String fileName) |
Return the directory containing the grammar file for this grammar.
|
List<String> |
getGrammarFileNames() |
Provide the List of all grammar file names that the ANTLR tool will
process or has processed.
|
File |
getImportedVocabFile(String vocabName) |
Return a File descriptor for vocab file.
|
String |
getLibraryDirectory() |
Return the Path to the directory in which ANTLR will search for ancillary
files such as .tokens vocab files and imported grammar files.
|
String |
getLibraryFile(String fileName) |
Name a file from the -lib dir.
|
boolean |
getMake() |
Indicate whether the tool will analyze the dependencies of the provided grammar
file list and ensure that grammars with dependencies are built
after any of the other gramamrs in the list that they are dependent on.
|
String |
getMessageFormat() |
Returns the current setting of the message format descriptor
|
int |
getNumErrors() |
Returns the number of errors that the analysis/processing threw up.
|
String |
getOutputDirectory() |
Return the Path to the base output directory, where ANTLR
will generate all the output files for the current language target as
well as any ancillary files such as .tokens vocab files.
|
File |
getOutputDirectory(String fileNameWithPath) |
Return the location where ANTLR will generate output files for a given file.
|
Writer |
getOutputFile(Grammar g,
String fileName) |
This method is used by all code generators to create new output
files.
|
Grammar |
getRootGrammar(String grammarFileName) |
Get a grammar mentioned on the command-line and any delegates
|
boolean |
isDebug() |
Indicate if ANTLR has generated, or will generate a debug version of the
recognizer.
|
boolean |
isDepend() |
Indicates whether ANTLR has supplied, or will supply, a list of all the things
that the input grammar depends upon and all the things that will be generated
when that grammar is successfully analyzed.
|
boolean |
isForceAllFilesToOutputDir() |
Indicates whether ANTLR will force all files to the output directory, even
if the input files have relative paths from the input directory.
|
boolean |
isGenerate_DFA_dot() |
Indicates whether ANTLR has generated or will generate a description of
all the NFAs in Dot format
|
boolean |
isGenerate_NFA_dot() |
Indicates whether ANTLR has gnerated or will generate a description of
all the NFAs in Dot format
|
boolean |
isPrintGrammar() |
Indicates whether ANTLR has printed, or will print, a version of the input grammar
file(s) that is stripped of any action code embedded within.
|
boolean |
isProfile() |
Indicates whether ANTLR has generated or will generate a version of the
recognizer that gathers statistics about its execution, which it prints when
it terminates.
|
boolean |
isReport() |
Indicates whether ANTLR has generated or will generate a report of various
elements of the grammar analysis, once it it has finished analyzing a grammar
file.
|
boolean |
isTrace() |
Indicate whether ANTLR has generated, or will generate a version of the
recognizer that prints trace messages on entry and exit of each rule.
|
boolean |
isVerbose() |
Indicates whether ANTLR will be verbose when analyzing grammar files, such as
displaying the names of the files it is generating and similar information.
|
static void |
main(String[] args) |
A list of dependency generators that are accumulated aaaas (and if) the
tool is required to sort the provided grammars into build dependency order.
|
void |
panic() |
If the tool needs to panic/exit, how do we do that?
|
void |
process() |
|
void |
processArgs(String[] args) |
|
void |
setDebug(boolean debug) |
Indicate whether ANTLR should generate a debug version of the
recognizer.
|
void |
setDepend(boolean depend) |
Indicate whether ANTLR should supply a list of all the things
that the input grammar depends upon and all the things that will be generated
when that gramamr is successfully analyzed.
|
void |
setForceAllFilesToOutputDir(boolean forceAllFilesToOutputDir) |
Indicates whether ANTLR will force all files to the output directory, even
if the input files have relative paths from the input directory.
|
void |
setForceRelativeOutput(boolean forceRelativeOutput) |
Used by build tools to force the output files to always be
relative to the base output directory, even though the tool
had to set the output directory to an absolute path as it
cannot rely on the workign directory like command line invocation
can.
|
void |
setGenerate_DFA_dot(boolean generate_DFA_dot) |
Indicates whether ANTLR should generate a description of
all the NFAs in Dot format
|
void |
setGenerate_NFA_dot(boolean generate_NFA_dot) |
Indicate whether ANTLR should generate a description of
all the NFAs in Dot format
|
void |
setGrammarFileNames(List<String> grammarFileNames) |
Provide the List of all grammar file names that the ANTLR tool should process.
|
void |
setInputDirectory(String inputDirectory) |
Set the base location of input files.
|
void |
setLibDirectory(String libDirectory) |
Set the Path to the directory in which ANTLR will search for ancillary
files such as .tokens vocab files and imported grammar files.
|
void |
setMake(boolean make) |
Indicate whether the tool should analyze the dependencies of the provided grammar
file list and ensure that the grammars with dependencies are built
after any of the other gramamrs in the list that they are dependent on.
|
void |
setMaxSwitchCaseLabels(int maxSwitchCaseLabels) |
Set the threshold of case labels beyond which ANTLR will not instruct the target template
to generate switch() { case xxx: ...
|
void |
setMessageFormat(String format) |
Set the message format to one of ANTLR, gnu, vs2005
|
void |
setMinSwitchAlts(int minSwitchAlts) |
Set the threshold of the number alts, below which ANTLR will not instruct the target
template to use a switch statement.
|
void |
setOutputDirectory(String outputDirectory) |
Set the location (base directory) where output files should be produced
by the ANTLR tool.
|
void |
setPrintGrammar(boolean printGrammar) |
Indicate whether ANTLR should print a version of the input grammar
file(s) that is stripped of any action code embedded within.
|
void |
setProfile(boolean profile) |
Indicate whether ANTLR should generate a version of the
recognizer that gathers statistics about its execution, which it prints when
it terminates.
|
void |
setReport(boolean report) |
Indicate whether ANTLR should generate a report of various
elements of the grammar analysis, once it it has finished analyzing a grammar
file.
|
void |
setTrace(boolean trace) |
Indicate whether ANTLR should generate a version of the
recognizer that prints trace messages on entry and exit of each rule
|
void |
setVerbose(boolean verbose) |
Indicate whether ANTLR should be verbose when analyzing grammar files, such as
displaying the names of the files it is generating and similar information.
|
void |
sortGrammarFiles() |
|
protected void |
writeDOTFile(Grammar g,
String name,
String dot) |
|
protected void |
writeDOTFile(Grammar g,
Rule r,
String dot) |
public final Properties antlrSettings
public final String VERSION
public static final String UNINITIALIZED_DIR
protected boolean deleteTempLexer
public String forcedLanguageOption
public static boolean internalOption_PrintGrammarTree
public static boolean internalOption_PrintDFA
public static boolean internalOption_ShowNFAConfigsInDFA
public static boolean internalOption_watchNFAConversion
public Tool()
public Tool(String[] args)
public static void main(String[] args)
public void processArgs(String[] args)
public boolean buildRequired(String grammarFileName) throws IOException
grammarFileName
- The grammar file we are checkingIOException
public void process()
public void sortGrammarFiles() throws IOException
IOException
public Grammar getRootGrammar(String grammarFileName) throws IOException
IOException
protected void generateRecognizer(Grammar grammar)
public void generateDFAs(Grammar g)
protected void generateNFAs(Grammar g)
protected void writeDOTFile(Grammar g, Rule r, String dot) throws IOException
IOException
protected void writeDOTFile(Grammar g, String name, String dot) throws IOException
IOException
public void setMaxSwitchCaseLabels(int maxSwitchCaseLabels)
maxSwitchCaseLabels
- Maximum number of case lables that ANTLR should allow the target codepublic void setMinSwitchAlts(int minSwitchAlts)
minSwitchAlts
- the minimum number of alts required to use a switch staementpublic void setOutputDirectory(String outputDirectory)
outputDirectory
- public void setForceRelativeOutput(boolean forceRelativeOutput)
forceRelativeOutput
- true if output files hould always be relative to base output directorypublic void setInputDirectory(String inputDirectory)
inputDirectory
- Input source base directorypublic Writer getOutputFile(Grammar g, String fileName) throws IOException
IOException
public File getOutputDirectory(String fileNameWithPath)
fileNameWithPath
- path to input sourcepublic String getLibraryFile(String fileName) throws IOException
fileName
- input name we are looking forIOException
public String getFileDirectory(String fileName)
public File getImportedVocabFile(String vocabName)
public void panic()
public static String getCurrentTimeStamp()
public List<String> getGrammarFileNames()
public boolean isGenerate_NFA_dot()
public boolean isGenerate_DFA_dot()
public String getOutputDirectory()
public String getLibraryDirectory()
public boolean isDebug()
public boolean isTrace()
public boolean isProfile()
public boolean isReport()
public boolean isPrintGrammar()
public boolean isDepend()
public boolean isForceAllFilesToOutputDir()
public boolean isVerbose()
public int getConversionTimeout()
public String getMessageFormat()
public int getNumErrors()
public boolean getMake()
public void setMessageFormat(String format)
format
- public void setGrammarFileNames(List<String> grammarFileNames)
grammarFileNames
- The list of grammar files to processpublic void addGrammarFile(String grammarFileName)
public void setGenerate_NFA_dot(boolean generate_NFA_dot)
generate_NFA_dot
- True to generate dot descriptionspublic void setGenerate_DFA_dot(boolean generate_DFA_dot)
generate_DFA_dot
- True to generate dot descriptionspublic void setLibDirectory(String libDirectory)
libDirectory
- the libDirectory to setpublic void setDebug(boolean debug)
debug
- true to generate a debug mode parserpublic void setTrace(boolean trace)
trace
- true to generate a tracing parserpublic void setProfile(boolean profile)
profile
- true to generate a profiling parserpublic void setReport(boolean report)
report
- true to generate the analysis reportpublic void setPrintGrammar(boolean printGrammar)
printGrammar
- true to generate a stripped filepublic void setDepend(boolean depend)
depend
- true to get depends set rather than process the grammarpublic void setForceAllFilesToOutputDir(boolean forceAllFilesToOutputDir)
forceAllFilesToOutputDir
- true to force files to output directorypublic void setVerbose(boolean verbose)
verbose
- true to be verbosepublic void setMake(boolean make)
make
- Copyright © 1992–2019 ANTLR. All rights reserved.