java.lang.Objectantlr.CodeGenerator
antlr.JavaCodeGenerator
Generate MyParser.java, MyLexer.java and MyParserTokenTypes.java
| Field Summary | |
static int |
caseSizeThreshold
|
| Fields inherited from class antlr.CodeGenerator |
TokenTypesFileExt, TokenTypesFileSuffix |
| Constructor Summary | |
JavaCodeGenerator()
Create a Java code-generator using the given Grammar. |
|
| Method Summary | |
void |
exitIfError()
|
void |
gen()
Generate the parser, lexer, treeparser, and token types in Java |
void |
gen(antlr.ActionElement action)
Generate code for the given grammar element. |
void |
gen(antlr.AlternativeBlock blk)
Generate code for the given grammar element. |
void |
gen(antlr.BlockEndElement end)
Generate code for the given grammar element. |
void |
gen(antlr.CharLiteralElement atom)
Generate code for the given grammar element. |
void |
gen(antlr.CharRangeElement r)
Generate code for the given grammar element. |
void |
gen(antlr.LexerGrammar g)
Generate the lexer Java file |
void |
gen(antlr.OneOrMoreBlock blk)
Generate code for the given grammar element. |
void |
gen(antlr.ParserGrammar g)
Generate the parser Java file |
void |
gen(antlr.RuleRefElement rr)
Generate code for the given grammar element. |
void |
gen(antlr.StringLiteralElement atom)
Generate code for the given grammar element. |
void |
gen(antlr.TokenRangeElement r)
Generate code for the given grammar element. |
void |
gen(antlr.TokenRefElement atom)
Generate code for the given grammar element. |
void |
gen(antlr.TreeElement t)
Generate code for the given grammar element. |
void |
gen(antlr.TreeWalkerGrammar g)
Generate the tree-parser Java file |
void |
gen(antlr.WildcardElement wc)
Generate code for the given grammar element. |
void |
gen(antlr.ZeroOrMoreBlock blk)
Generate code for the given grammar element. |
antlr.JavaBlockFinishingInfo |
genCommonBlock(antlr.AlternativeBlock blk,
boolean noTestForSingle)
Generate common code for a block of alternatives; return a postscript that needs to be generated at the end of the block. |
void |
genNextToken()
Generate the nextToken() rule. |
void |
genRule(antlr.RuleSymbol s,
boolean startSymbol,
int ruleNum)
Gen a named rule block. |
void |
genTokenStrings()
Generate a static array containing the names of the tokens, indexed by the token type values. |
java.lang.String |
getASTCreateString(antlr.GrammarAtom atom,
java.lang.String astCtorArgs)
Get a string for an expression to generate creating of an AST node |
java.lang.String |
getASTCreateString(java.lang.String astCtorArgs)
Get a string for an expression to generate creating of an AST node. |
java.lang.String |
getASTCreateString(Vector v)
Get a string for an expression to generate creation of an AST subtree. |
java.lang.String |
getRangeExpression(int k,
int[] elems)
Return an expression for testing a contiguous renage of elements |
java.lang.String |
mapTreeId(java.lang.String idParam,
ActionTransInfo transInfo)
Map an identifier to it's corresponding tree-node variable. |
void |
setupOutput(java.lang.String className)
This method exists so a subclass, namely VAJCodeGenerator, can open the file in its own evil way. |
| Methods inherited from class antlr.CodeGenerator |
decodeLexerRuleName, elementsAreRange, encodeLexerRuleName, getFIRSTBitSet, getFOLLOWBitSet, processStringForASTConstructor, reverseLexerRuleName, setAnalyzer, setBehavior, setTool |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int caseSizeThreshold
| Constructor Detail |
public JavaCodeGenerator()
| Method Detail |
public void exitIfError()
public void gen()
gen in class CodeGeneratorpublic void gen(antlr.ActionElement action)
gen in class CodeGeneratoraction - The {...} action to generatepublic void gen(antlr.AlternativeBlock blk)
gen in class CodeGeneratorblk - The "x|y|z|..." block to generatepublic void gen(antlr.BlockEndElement end)
gen in class CodeGeneratorend - The block-end element to generate. Block-end
elements are synthesized by the grammar parser to represent
the end of a block.public void gen(antlr.CharLiteralElement atom)
gen in class CodeGeneratoratom - The character literal reference to generatepublic void gen(antlr.CharRangeElement r)
gen in class CodeGeneratorr - The character-range reference to generate
public void gen(antlr.LexerGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(antlr.OneOrMoreBlock blk)
gen in class CodeGeneratorblk - The (...)+ block to generate
public void gen(antlr.ParserGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(antlr.RuleRefElement rr)
gen in class CodeGeneratorrr - The rule-reference to generatepublic void gen(antlr.StringLiteralElement atom)
gen in class CodeGeneratoratom - The string-literal reference to generatepublic void gen(antlr.TokenRangeElement r)
gen in class CodeGeneratorr - The token-range reference to generatepublic void gen(antlr.TokenRefElement atom)
gen in class CodeGeneratoratom - The token-reference to generatepublic void gen(antlr.TreeElement t)
CodeGenerator
gen in class CodeGenerator
public void gen(antlr.TreeWalkerGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(antlr.WildcardElement wc)
gen in class CodeGeneratorwc - The wildcard element to generatepublic void gen(antlr.ZeroOrMoreBlock blk)
gen in class CodeGeneratorblk - The (...)* block to generate
public antlr.JavaBlockFinishingInfo genCommonBlock(antlr.AlternativeBlock blk,
boolean noTestForSingle)
public void genNextToken()
public void genRule(antlr.RuleSymbol s,
boolean startSymbol,
int ruleNum)
startSymbol - true if the rule is a start symbol (i.e., not referenced elsewhere)public void genTokenStrings()
public java.lang.String getASTCreateString(Vector v)
getASTCreateString in class CodeGeneratorv - A Vector of String, where each element is an expression in the target language yielding an AST node.
public java.lang.String getASTCreateString(antlr.GrammarAtom atom,
java.lang.String astCtorArgs)
getASTCreateString in class CodeGeneratoratom - The grammar node for which you are creating the nodeastCtorArgs - The text of the arguments to the AST constructionpublic java.lang.String getASTCreateString(java.lang.String astCtorArgs)
public java.lang.String getRangeExpression(int k,
int[] elems)
k - The lookahead levelelems - The elements representing the set, usually from BitSet.toArray().
public java.lang.String mapTreeId(java.lang.String idParam,
ActionTransInfo transInfo)
mapTreeId in class CodeGeneratoridParam - The identifier name to map
public void setupOutput(java.lang.String className)
throws java.io.IOException
java.io.IOException