|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlr.CodeGenerator | +--antlr.DiagnosticCodeGenerator
Untamed: Generate MyParser.txt, MyLexer.txt and MyParserTokenTypes.txt
Field Summary | |
protected boolean |
doingLexRules
true during lexer generation, false during parser generation |
protected int |
syntacticPredLevel
non-zero if inside syntactic predicate generation |
Fields inherited from class antlr.CodeGenerator |
analyzer, behavior, bitsetsUsed, bitsetTestThreshold, charFormatter, currentOutput, DEBUG_CODE_GENERATOR, DEFAULT_BITSET_TEST_THRESHOLD, DEFAULT_MAKE_SWITCH_THRESHOLD, grammar, makeSwitchThreshold, tabs, TokenTypesFileExt, TokenTypesFileSuffix, tool |
Constructor Summary | |
DiagnosticCodeGenerator()
Enabled: Create a Diagnostic code-generator using the given Grammar The caller must still call setTool, setBehavior, and setAnalyzer before generating code. |
Method Summary | |
void |
gen()
Enabled: Generate the parser, lexer, and token types documentation |
void |
gen(ActionElement action)
Enabled: Generate code for the given grammar element. |
void |
gen(AlternativeBlock blk)
Enabled: Generate code for the given grammar element. |
void |
gen(BlockEndElement end)
Enabled: Generate code for the given grammar element. |
void |
gen(CharLiteralElement atom)
Enabled: Generate code for the given grammar element. |
void |
gen(CharRangeElement r)
Enabled: Generate code for the given grammar element. |
void |
gen(LexerGrammar g)
Enabled: Generate the lexer TXT file |
void |
gen(OneOrMoreBlock blk)
Enabled: Generate code for the given grammar element. |
void |
gen(ParserGrammar g)
Enabled: Generate the parser TXT file |
void |
gen(RuleRefElement rr)
Enabled: Generate code for the given grammar element. |
void |
gen(StringLiteralElement atom)
Enabled: Generate code for the given grammar element. |
void |
gen(TokenRangeElement r)
Enabled: Generate code for the given grammar element. |
void |
gen(TokenRefElement atom)
Enabled: Generate code for the given grammar element. |
void |
gen(TreeElement t)
Enabled: |
void |
gen(TreeWalkerGrammar g)
Enabled: Generate the tree-walker TXT file |
void |
gen(WildcardElement wc)
Enabled: Generate a wildcard element |
void |
gen(ZeroOrMoreBlock blk)
Enabled: Generate code for the given grammar element. |
protected void |
genAlt(Alternative alt)
|
protected void |
genBlockPreamble(AlternativeBlock blk)
Generate the header for a block, which may be a RuleBlock or a plain AlternativeBLock. |
void |
genCommonBlock(AlternativeBlock blk)
Enabled: Generate common code for a block of alternatives; return a postscript that needs to be generated at the end of the block. |
void |
genFollowSetForRuleBlock(RuleBlock blk)
Enabled: Generate a textual representation of the follow set for a block. |
protected void |
genHeader()
Generate a header that is common to all TXT files |
protected void |
genLookaheadSetForAlt(Alternative alt)
Generate the lookahead set for an alternate. |
void |
genLookaheadSetForBlock(AlternativeBlock blk)
Enabled: Generate a textual representation of the lookahead set for a block. |
void |
genNextToken()
Enabled: Generate the nextToken rule. |
void |
genRule(RuleSymbol s)
Enabled: Generate code for a named rule block |
protected void |
genSynPred(SynPredBlock blk)
Generate the syntactic predicate. |
protected void |
genTokenTypes(TokenManager tm)
Generate the token types TXT file |
String |
getASTCreateString(GrammarAtom atom,
String str)
Enabled: Get a string for an expression to generate creating of an AST node |
String |
getASTCreateString(Vector v)
Enabled: Get a string for an expression to generate creation of an AST subtree. |
String |
mapTreeId(String id,
ActionTransInfo tInfo)
Enabled: Map an identifier to it's corresponding tree-node variable. |
void |
printSet(int depth,
int k,
Lookahead lookahead)
Enabled: Format a lookahead or follow set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int syntacticPredLevel
protected boolean doingLexRules
Constructor Detail |
public DiagnosticCodeGenerator()
Method Detail |
public void gen()
gen
in class CodeGenerator
public void gen(ActionElement action)
gen
in class CodeGenerator
action
- The {...} action to generatepublic void gen(AlternativeBlock blk)
gen
in class CodeGenerator
blk
- The "x|y|z|..." block to generatepublic void gen(BlockEndElement end)
gen
in class CodeGenerator
end
- 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(CharLiteralElement atom)
gen
in class CodeGenerator
atom
- The character literal reference to generatepublic void gen(CharRangeElement r)
gen
in class CodeGenerator
r
- The character-range reference to generatepublic void gen(LexerGrammar g) throws IOException
gen
in class CodeGenerator
IOException
public void gen(OneOrMoreBlock blk)
gen
in class CodeGenerator
blk
- The (...)+ block to generatepublic void gen(ParserGrammar g) throws IOException
gen
in class CodeGenerator
IOException
public void gen(RuleRefElement rr)
gen
in class CodeGenerator
rr
- The rule-reference to generatepublic void gen(StringLiteralElement atom)
gen
in class CodeGenerator
atom
- The string-literal reference to generatepublic void gen(TokenRangeElement r)
gen
in class CodeGenerator
r
- The token-range reference to generatepublic void gen(TokenRefElement atom)
gen
in class CodeGenerator
atom
- The token-reference to generatepublic void gen(TreeElement t)
gen
in class CodeGenerator
public void gen(TreeWalkerGrammar g) throws IOException
gen
in class CodeGenerator
IOException
public void gen(WildcardElement wc)
gen
in class CodeGenerator
wc
- The wildcard element to generatepublic void gen(ZeroOrMoreBlock blk)
gen
in class CodeGenerator
blk
- The (...)* block to generateprotected void genAlt(Alternative alt)
protected void genBlockPreamble(AlternativeBlock blk)
public void genCommonBlock(AlternativeBlock blk)
public void genFollowSetForRuleBlock(RuleBlock blk)
blk
- The rule block of interestprotected void genHeader()
protected void genLookaheadSetForAlt(Alternative alt)
public void genLookaheadSetForBlock(AlternativeBlock blk)
blk
- The block of interestpublic void genNextToken()
public void genRule(RuleSymbol s)
s
- The RuleSymbol describing the rule to generateprotected void genSynPred(SynPredBlock blk)
blk
- The syntactic predicate blockprotected void genTokenTypes(TokenManager tm) throws IOException
IOException
public String getASTCreateString(Vector v)
getASTCreateString
in class CodeGenerator
v
- A Vector of String, where each element is an expression in the target language yielding an AST node.public String getASTCreateString(GrammarAtom atom, String str)
getASTCreateString
in class CodeGenerator
str
- The arguments to the AST constructorpublic String mapTreeId(String id, ActionTransInfo tInfo)
mapTreeId
in class CodeGenerator
id
- The identifier name to map
public void printSet(int depth, int k, Lookahead lookahead)
depth
- The depth of the entire lookahead/followk
- The lookahead level to printlookahead
- The lookahead/follow set to print
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |