|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--antlr.CodeGenerator
|
+--antlr.DiagnosticCodeGenerator
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 |
| Constructor Summary | |
DiagnosticCodeGenerator()
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()
Generate the parser, lexer, and token types documentation |
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 TXT file |
void |
gen(antlr.OneOrMoreBlock blk)
Generate code for the given grammar element. |
void |
gen(antlr.ParserGrammar g)
Generate the parser TXT 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-walker TXT file |
void |
gen(antlr.WildcardElement wc)
Generate a wildcard element |
void |
gen(antlr.ZeroOrMoreBlock blk)
Generate code for the given grammar element. |
protected void |
genAlt(antlr.Alternative alt)
|
protected void |
genBlockPreamble(antlr.AlternativeBlock blk)
Generate the header for a block, which may be a RuleBlock or a plain AlternativeBLock. |
void |
genCommonBlock(antlr.AlternativeBlock blk)
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)
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(antlr.Alternative alt)
Generate the lookahead set for an alternate. |
void |
genLookaheadSetForBlock(antlr.AlternativeBlock blk)
Generate a textual representation of the lookahead set for a block. |
void |
genNextToken()
Generate the nextToken rule. |
void |
genRule(antlr.RuleSymbol s)
Generate code for a named rule block |
protected void |
genSynPred(antlr.SynPredBlock blk)
Generate the syntactic predicate. |
protected void |
genTokenTypes(antlr.TokenManager tm)
Generate the token types TXT file |
String |
getASTCreateString(antlr.GrammarAtom atom,
String str)
Get a string for an expression to generate creating of an AST node |
String |
getASTCreateString(Vector v)
Get a string for an expression to generate creation of an AST subtree. |
String |
mapTreeId(String id,
ActionTransInfo tInfo)
Map an identifier to it's corresponding tree-node variable. |
void |
printSet(int depth,
int k,
Lookahead lookahead)
Format a lookahead or follow set. |
protected String |
processActionForSpecialSymbols(String actionStr,
int line,
RuleBlock currentRule,
ActionTransInfo tInfo)
Lexically process $ and # references within the action. |
| 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 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 IOException
gen in class CodeGeneratorIOExceptionpublic void gen(antlr.OneOrMoreBlock blk)
gen in class CodeGeneratorblk - The (...)+ block to generate
public void gen(antlr.ParserGrammar g)
throws IOException
gen in class CodeGeneratorIOExceptionpublic 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 IOException
gen in class CodeGeneratorIOExceptionpublic 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 generateprotected void genAlt(antlr.Alternative alt)
protected void genBlockPreamble(antlr.AlternativeBlock blk)
public void genCommonBlock(antlr.AlternativeBlock blk)
public void genFollowSetForRuleBlock(RuleBlock blk)
blk - The rule block of interestprotected void genHeader()
protected void genLookaheadSetForAlt(antlr.Alternative alt)
public void genLookaheadSetForBlock(antlr.AlternativeBlock blk)
blk - The block of interestpublic void genNextToken()
public void genRule(antlr.RuleSymbol s)
s - The RuleSymbol describing the rule to generateprotected void genSynPred(antlr.SynPredBlock blk)
blk - The syntactic predicate block
protected void genTokenTypes(antlr.TokenManager tm)
throws IOException
IOExceptionpublic 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 String getASTCreateString(antlr.GrammarAtom atom,
String str)
getASTCreateString in class CodeGeneratorstr - The arguments to the AST constructor
protected String processActionForSpecialSymbols(String actionStr,
int line,
RuleBlock currentRule,
ActionTransInfo tInfo)
CodeGenerator
processActionForSpecialSymbols in class CodeGenerator
public String mapTreeId(String id,
ActionTransInfo tInfo)
mapTreeId in class CodeGeneratorid - 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 | |||||||||