Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Package Attributes

antlr.Tool Class Reference

List of all members.

Public Member Functions

 Tool ()
String getGrammarFile ()
boolean hasError ()
NameSpace getNameSpace ()
String getNamespaceStd ()
String getNamespaceAntlr ()
boolean getGenHashLines ()
String getLiteralsPrefix ()
boolean getUpperCaseMangledLiterals ()
void setFileLineFormatter (FileLineFormatter formatter)
void copyFile (String source_name, String dest_name) throws IOException
void doEverythingWrapper (String[] args)
int doEverything (String[] args)
void error (String s)
void error (String s, String file, int line, int column)
String fileMinusPath (String f)
String getLanguage (MakeGrammar behavior)
String getOutputDirectory ()
PrintWriter openOutputFile (String f) throws IOException
Reader getGrammarReader ()
void reportException (Exception e, String message)
void reportProgress (String message)
void fatalError (String message)
void panic ()
void panic (String s)
File parent (File f)
String pathToFile (String f)
void setArgOK (int i)
void setOutputDirectory (String o)
void toolError (String s)
void warning (String s)
void warning (String s, String file, int line, int column)
void warning (String[] s, String file, int line, int column)
void setNameSpace (String name)

Static Public Member Functions

static void main (String[] args)
static Vector parseSeparatedList (String list, char separator)

Static Public Attributes

static String version = ""

Protected Member Functions

void checkForInvalidArguments (String[] args, BitSet cmdLineArgValid)
void processArguments (String[] args)

Protected Attributes

boolean hasError = false
String outputDir = "."
String grammarFile
String literalsPrefix = "LITERAL_"
boolean upperCaseMangledLiterals = false
NameSpace nameSpace = null
String namespaceAntlr = null
String namespaceStd = null
boolean genHashLines = true
boolean noConstructors = false

Package Attributes

ToolErrorHandler errorHandler
boolean genDiagnostics = false
boolean genDocBook = false
boolean genHTML = false
transient Reader f = new InputStreamReader(System.in)

Constructor & Destructor Documentation

antlr.Tool.Tool (  ) 

Construct a new Tool.

References antlr.Tool.errorHandler.

Referenced by antlr.Tool.main().


Member Function Documentation

void antlr.Tool.checkForInvalidArguments ( String[]  args,
BitSet  cmdLineArgValid 
) [protected]
void antlr.Tool.copyFile ( String  source_name,
String  dest_name 
) throws 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.

References antlr.Tool.parent().

int antlr.Tool.doEverything ( String[]  args  ) 
void antlr.Tool.doEverythingWrapper ( String[]  args  ) 

Perform processing on the grammar file. Can only be called from main()

Parameters:
args The command-line arguments passed to main(). This wrapper does the System.exit for use with command-line.

References antlr.Tool.doEverything().

void antlr.Tool.error ( String  s  ) 

Issue an error

Parameters:
s The message

References antlr.Tool.hasError().

Referenced by antlr.MakeGrammar.abortGrammar(), antlr.RuleBlock.addExceptionSpec(), antlr.MakeGrammar.beginTree(), antlr.MakeGrammar.createNextTokenRule(), antlr.MakeGrammar.defineRuleName(), antlr.DefineGrammarSymbols.defineRuleName(), antlr.MakeGrammar.endExceptionSpec(), antlr.DefineGrammarSymbols.endOptions(), antlr.MakeGrammar.endSubRule(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.PythonCodeGenerator.genMatch(), antlr.JavaCodeGenerator.genMatch(), antlr.CSharpCodeGenerator.genMatch(), antlr.CppCodeGenerator.genMatch(), antlr.PythonCodeGenerator.genNextToken(), antlr.JavaCodeGenerator.genNextToken(), antlr.CSharpCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genNextToken(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CppCodeGenerator.genRuleHeader(), antlr.LLkAnalyzer.look(), antlr.PythonCodeGenerator.mapTreeId(), antlr.JavaCodeGenerator.mapTreeId(), antlr.CSharpCodeGenerator.mapTreeId(), antlr.CppCodeGenerator.mapTreeId(), antlr.MakeGrammar.oneOrMoreSubRule(), antlr.MakeGrammar.optionalSubRule(), antlr.Tool.processArguments(), antlr.MakeGrammar.refCharLiteral(), antlr.MakeGrammar.refCharRange(), antlr.MakeGrammar.refElementOption(), antlr.DefineGrammarSymbols.refHeaderAction(), antlr.MakeGrammar.refRule(), antlr.MakeGrammar.refStringLiteral(), antlr.MakeGrammar.refToken(), antlr.MakeGrammar.refTokenRange(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.AlternativeBlock.removeTrackingOfRuleRefs(), antlr.actions.python.CodeLexer.reportError(), antlr.ANTLRTokdefParser.reportError(), antlr.ANTLRParser.reportError(), antlr.actions.python.ActionLexer.reportError(), antlr.actions.java.ActionLexer.reportError(), antlr.actions.csharp.ActionLexer.reportError(), antlr.actions.cpp.ActionLexer.reportError(), antlr.ANTLRParser.setBlockElement(), antlr.DefineGrammarSymbols.setFileOption(), antlr.CodeGenerator.setGrammar(), antlr.DefineGrammarSymbols.setGrammarOption(), antlr.TreeWalkerGrammar.setOption(), antlr.RuleBlock.setOption(), antlr.ParserGrammar.setOption(), antlr.LexerGrammar.setOption(), antlr.GrammarAtom.setOption(), antlr.Grammar.setOption(), antlr.AlternativeBlock.setOption(), antlr.StringLiteralElement.StringLiteralElement(), antlr.MakeGrammar.synPred(), antlr.TokenRefElement.TokenRefElement(), and antlr.MakeGrammar.zeroOrMoreSubRule().

void antlr.Tool.error ( String  s,
String  file,
int  line,
int  column 
)

Issue an error with line number information

Parameters:
s The message
file The file that has the error (or null)
line The grammar file line number on which the error occured (or -1)
column The grammar file column number on which the error occured (or -1)

References antlr.Tool.hasError().

void antlr.Tool.fatalError ( String  message  ) 

An error occured that should stop the Tool from doing any work. The default implementation currently exits (via java.lang.System.exit(int) after printing an error message to stderr. However, the tools should expect that a subclass will override this to throw an unchecked exception such as java.lang.IllegalStateException or another subclass of java.lang.RuntimeException. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.

Since:
2.7.2
Parameters:
s The message

Referenced by antlr.Tool.doEverything(), antlr.PythonCodeGenerator.exitIfError(), antlr.JavaCodeGenerator.exitIfError(), antlr.CSharpCodeGenerator.exitIfError(), antlr.CppCodeGenerator.exitIfError(), antlr.HTMLCodeGenerator.gen(), antlr.DocBookCodeGenerator.gen(), antlr.Tool.getGrammarReader(), and antlr.Tool.panic().

String antlr.Tool.fileMinusPath ( String  f  ) 
boolean antlr.Tool.getGenHashLines (  ) 
String antlr.Tool.getGrammarFile (  ) 
Reader antlr.Tool.getGrammarReader (  ) 
String antlr.Tool.getLanguage ( MakeGrammar  behavior  ) 

Determine the language used for this run of ANTLR This was made a method so the subclass can override it

References antlr.Tool.genDiagnostics, antlr.Tool.genDocBook, antlr.Tool.genHTML, and antlr.DefineGrammarSymbols.language.

Referenced by antlr.Tool.doEverything().

String antlr.Tool.getLiteralsPrefix (  ) 
NameSpace antlr.Tool.getNameSpace (  ) 

References antlr.Tool.nameSpace.

String antlr.Tool.getNamespaceAntlr (  ) 
String antlr.Tool.getNamespaceStd (  ) 
String antlr.Tool.getOutputDirectory (  ) 
boolean antlr.Tool.getUpperCaseMangledLiterals (  ) 
boolean antlr.Tool.hasError (  ) 
static void antlr.Tool.main ( String[]  args  )  [static]
PrintWriter antlr.Tool.openOutputFile ( String  f  )  throws IOException
void antlr.Tool.panic (  ) 

Issue an unknown fatal error. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.

Deprecated:
as of 2.7.2 use fatalError(String). By default this method executes fatalError("panic");.

References antlr.Tool.fatalError().

Referenced by antlr.MakeGrammar.beginExceptionGroup(), antlr.SimpleTokenManager.clone(), antlr.Tool.doEverything(), antlr.MakeGrammar.endExceptionSpec(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.DiagnosticCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.CSharpCodeGenerator.genTokenDefinitions(), antlr.PythonCodeGenerator.genTokenTypes(), antlr.JavaCodeGenerator.genTokenTypes(), antlr.CppCodeGenerator.genTokenTypes(), antlr.PythonCodeGenerator.getRangeExpression(), antlr.JavaCodeGenerator.getRangeExpression(), antlr.CSharpCodeGenerator.getRangeExpression(), antlr.CppCodeGenerator.getRangeExpression(), antlr.ImportVocabTokenManager.ImportVocabTokenManager(), antlr.LLkAnalyzer.look(), antlr.PythonCodeGenerator.processActionCode(), antlr.PythonCodeGenerator.processActionForSpecialSymbols(), antlr.JavaCodeGenerator.processActionForSpecialSymbols(), antlr.CSharpCodeGenerator.processActionForSpecialSymbols(), antlr.CppCodeGenerator.processActionForSpecialSymbols(), antlr.MakeGrammar.refExceptionHandler(), antlr.MakeGrammar.refTokensSpecElementOption(), antlr.RuleBlock.setOption(), antlr.DefineGrammarSymbols.startLexer(), antlr.DefineGrammarSymbols.startParser(), antlr.DefineGrammarSymbols.startTreeWalker(), and antlr.Tool.warning().

void antlr.Tool.panic ( String  s  ) 

Issue a fatal error message. If this method is overriden, it must never return normally; i.e. it must always throw an exception or call System.exit.

Deprecated:
as of 2.7.2 use fatalError(String). By defaykt this method executes fatalError("panic: " + s);.
Parameters:
s The message

References antlr.Tool.fatalError().

File antlr.Tool.parent ( File  f  ) 

Referenced by antlr.Tool.copyFile().

static Vector antlr.Tool.parseSeparatedList ( String  list,
char  separator 
) [static]

Parse a list such as "f1.g;f2.g;..." and return a Vector of the elements.

References antlr.collections.impl.Vector.appendElement(), and antlr.collections.impl.Vector.size().

String antlr.Tool.pathToFile ( String  f  ) 

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

void antlr.Tool.processArguments ( String[]  args  )  [protected]

Process the command-line arguments. Can only be called by Tool. A bitset is collected of all correct arguments via setArgOk.

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

References antlr.Tool.error(), antlr.Tool.genDiagnostics, antlr.Tool.genDocBook, antlr.Tool.genHTML, antlr.Tool.grammarFile, antlr.Tool.setArgOK(), and antlr.Tool.setOutputDirectory().

Referenced by antlr.Tool.doEverything().

void antlr.Tool.reportException ( Exception  e,
String  message 
)
void antlr.Tool.reportProgress ( String  message  ) 
void antlr.Tool.setArgOK ( int  i  ) 
void antlr.Tool.setFileLineFormatter ( FileLineFormatter  formatter  ) 
void antlr.Tool.setNameSpace ( String  name  ) 

Support C++ & C# namespaces (for now). C++: Add a nested namespace name to the current namespace. C# : Specify an enclosing namespace for the generated code. DAW: David Wagner -- C# support by kunle odutola

References antlr.Tool.nameSpace.

Referenced by antlr.DefineGrammarSymbols.setFileOption().

void antlr.Tool.setOutputDirectory ( String  o  ) 
void antlr.Tool.toolError ( String  s  ) 

Issue an error; used for general tool errors not for grammar stuff

Parameters:
s The message
void antlr.Tool.warning ( String  s  ) 

Issue a warning

Parameters:
s the message

Referenced by antlr.Tool.checkForInvalidArguments(), antlr.DefineGrammarSymbols.defineToken(), antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), antlr.DefineGrammarSymbols.endOptions(), antlr.CodeGenerator.extractIdOfAction(), antlr.CodeGenerator.extractTypeOfAction(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.PythonCodeGenerator.genAlt(), antlr.JavaCodeGenerator.genAlt(), antlr.CSharpCodeGenerator.genAlt(), antlr.CppCodeGenerator.genAlt(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.JavaCodeGenerator.genCommonBlock(), antlr.CSharpCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genInitFactory(), antlr.PythonCodeGenerator.genNextToken(), antlr.JavaCodeGenerator.genNextToken(), antlr.CSharpCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genNextToken(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CodeGenerator.genTokenInterchange(), antlr.CppCodeGenerator.getASTCreateString(), antlr.ANTLRParser.lexerSpec(), antlr.ANTLRParser.parserSpec(), antlr.MakeGrammar.refCharLiteral(), antlr.MakeGrammar.refCharRange(), antlr.MakeGrammar.refReturnAction(), antlr.MakeGrammar.refStringLiteral(), antlr.actions.python.CodeLexer.reportWarning(), antlr.ANTLRTokdefParser.reportWarning(), antlr.ANTLRParser.reportWarning(), antlr.actions.python.ActionLexer.reportWarning(), antlr.actions.java.ActionLexer.reportWarning(), antlr.actions.csharp.ActionLexer.reportWarning(), antlr.actions.cpp.ActionLexer.reportWarning(), antlr.LexerGrammar.setOption(), antlr.DefaultToolErrorHandler.warnAltAmbiguity(), and antlr.DefaultToolErrorHandler.warnAltExitAmbiguity().

void antlr.Tool.warning ( String[]  s,
String  file,
int  line,
int  column 
)

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

References antlr.Tool.panic().

void antlr.Tool.warning ( String  s,
String  file,
int  line,
int  column 
)

Issue a warning with line number information

Parameters:
s The message
file The file that has the warning (or null)
line The grammar file line number on which the warning occured (or -1)
column The grammar file line number on which the warning occured (or -1)

Member Data Documentation

transient Reader antlr.Tool.f = new InputStreamReader(System.in) [package]
boolean antlr.Tool.genDiagnostics = false [package]

Generate diagnostics? (vs code)

Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().

boolean antlr.Tool.genDocBook = false [package]

Generate DocBook vs code?

Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().

boolean antlr.Tool.genHashLines = true [protected]
boolean antlr.Tool.genHTML = false [package]

Generate HTML vs code?

Referenced by antlr.Tool.getLanguage(), and antlr.Tool.processArguments().

String antlr.Tool.grammarFile [protected]
boolean antlr.Tool.hasError = false [protected]
String antlr.Tool.literalsPrefix = "LITERAL_" [protected]
NameSpace antlr.Tool.nameSpace = null [protected]

C++ file level options

Referenced by antlr.Tool.getNameSpace(), and antlr.Tool.setNameSpace().

String antlr.Tool.namespaceAntlr = null [protected]
String antlr.Tool.namespaceStd = null [protected]
boolean antlr.Tool.noConstructors = false [protected]
String antlr.Tool.outputDir = "." [protected]

Current output directory for generated files

Referenced by antlr.Tool.getOutputDirectory(), antlr.Tool.openOutputFile(), and antlr.Tool.setOutputDirectory().

boolean antlr.Tool.upperCaseMangledLiterals = false [protected]
String antlr.Tool.version = "" [static]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties