public class DocBookCodeGenerator extends CodeGenerator
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
doingLexRules
true during lexer generation, false during parser generation
|
protected boolean |
firstElementInAlt |
protected persistence.antlr.AlternativeElement |
prevAltElem |
protected int |
syntacticPredLevel
non-zero if inside syntactic predicate generation
|
analyzer, antlrTool, behavior, BITSET_OPTIMIZE_INIT_THRESHOLD, bitsetsUsed, bitsetTestThreshold, charFormatter, currentOutput, DEBUG_CODE_GENERATOR, DEFAULT_BITSET_TEST_THRESHOLD, DEFAULT_MAKE_SWITCH_THRESHOLD, grammar, makeSwitchThreshold, tabs, TokenTypesFileExt, TokenTypesFileSuffix| Constructor and Description |
|---|
DocBookCodeGenerator()
Create a Diagnostic code-generator using the given Grammar
The caller must still call setTool, setBehavior, and setAnalyzer
before generating code.
|
| Modifier and Type | Method and Description |
|---|---|
void |
gen()
Generate the code for all grammars
|
void |
gen(persistence.antlr.ActionElement action)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.AlternativeBlock blk)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.BlockEndElement end)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.CharLiteralElement atom)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.CharRangeElement r)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.LexerGrammar g)
Generate the lexer HTML file
|
void |
gen(persistence.antlr.OneOrMoreBlock blk)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.ParserGrammar g)
Generate the parser HTML file
|
void |
gen(persistence.antlr.RuleRefElement rr)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.StringLiteralElement atom)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.TokenRangeElement r)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.TokenRefElement atom)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.TreeElement t)
Generate code for the given grammar element.
|
void |
gen(persistence.antlr.TreeWalkerGrammar g)
Generate the tree-walker TXT file
|
void |
gen(persistence.antlr.WildcardElement wc)
Generate a wildcard element
|
void |
gen(persistence.antlr.ZeroOrMoreBlock blk)
Generate code for the given grammar element.
|
protected void |
genAlt(persistence.antlr.Alternative alt) |
void |
genCommonBlock(persistence.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 |
genGenericBlock(persistence.antlr.AlternativeBlock blk,
java.lang.String blkOp) |
protected void |
genHeader()
Generate a header that is common to all TXT files
|
protected void |
genLookaheadSetForAlt(persistence.antlr.Alternative alt)
Generate the lookahead set for an alternate.
|
void |
genLookaheadSetForBlock(persistence.antlr.AlternativeBlock blk)
Generate a textual representation of the lookahead set
for a block.
|
void |
genNextToken()
Generate the nextToken rule.
|
void |
genRule(persistence.antlr.RuleSymbol s)
Generate code for a named rule block
|
protected void |
genSynPred(persistence.antlr.SynPredBlock blk)
Generate the syntactic predicate.
|
void |
genTail() |
protected void |
genTokenTypes(persistence.antlr.TokenManager tm)
Generate the token types TXT file
|
java.lang.String |
getASTCreateString(persistence.antlr.GrammarAtom atom,
java.lang.String str)
Get a string for an expression to generate creating of an AST node
|
java.lang.String |
getASTCreateString(persistence.antlr.collections.impl.Vector v)
Get a string for an expression to generate creation of an AST subtree.
|
java.lang.String |
mapTreeId(java.lang.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 java.lang.String |
processActionForSpecialSymbols(java.lang.String actionStr,
int line,
RuleBlock currentRule,
ActionTransInfo tInfo)
Lexically process $ and # references within the action.
|
_print, _printAction, _println, decodeLexerRuleName, elementsAreRange, encodeLexerRuleName, extractIdOfAction, extractIdOfAction, extractTypeOfAction, extractTypeOfAction, genTokenInterchange, getBitsetName, getFIRSTBitSet, getFOLLOWBitSet, markBitsetForGen, print, printAction, println, printTabs, processStringForASTConstructor, removeAssignmentFromDeclaration, reverseLexerRuleName, setAnalyzer, setBehavior, setGrammar, setToolprotected int syntacticPredLevel
protected boolean doingLexRules
protected boolean firstElementInAlt
protected persistence.antlr.AlternativeElement prevAltElem
public DocBookCodeGenerator()
public void gen()
CodeGeneratorgen in class CodeGeneratorpublic void gen(persistence.antlr.ActionElement action)
gen in class CodeGeneratorblk - The {...} action to generatepublic void gen(persistence.antlr.AlternativeBlock blk)
gen in class CodeGeneratorblk - The "x|y|z|..." block to generatepublic void gen(persistence.antlr.BlockEndElement end)
gen in class CodeGeneratorblk - 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(persistence.antlr.CharLiteralElement atom)
gen in class CodeGeneratorblk - The character literal reference to generatepublic void gen(persistence.antlr.CharRangeElement r)
gen in class CodeGeneratorblk - The character-range reference to generatepublic void gen(persistence.antlr.LexerGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(persistence.antlr.OneOrMoreBlock blk)
gen in class CodeGeneratorblk - The (...)+ block to generatepublic void gen(persistence.antlr.ParserGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(persistence.antlr.RuleRefElement rr)
gen in class CodeGeneratorblk - The rule-reference to generatepublic void gen(persistence.antlr.StringLiteralElement atom)
gen in class CodeGeneratorblk - The string-literal reference to generatepublic void gen(persistence.antlr.TokenRangeElement r)
gen in class CodeGeneratorblk - The token-range reference to generatepublic void gen(persistence.antlr.TokenRefElement atom)
gen in class CodeGeneratorblk - The token-reference to generatepublic void gen(persistence.antlr.TreeElement t)
CodeGeneratorgen in class CodeGeneratorpublic void gen(persistence.antlr.TreeWalkerGrammar g)
throws java.io.IOException
gen in class CodeGeneratorjava.io.IOExceptionpublic void gen(persistence.antlr.WildcardElement wc)
gen in class CodeGeneratorwc - The wildcard element to generatepublic void gen(persistence.antlr.ZeroOrMoreBlock blk)
gen in class CodeGeneratorblk - The (...)* block to generateprotected void genAlt(persistence.antlr.Alternative alt)
public void genCommonBlock(persistence.antlr.AlternativeBlock blk)
public void genFollowSetForRuleBlock(RuleBlock blk)
blk - The rule block of interestprotected void genGenericBlock(persistence.antlr.AlternativeBlock blk,
java.lang.String blkOp)
protected void genHeader()
protected void genLookaheadSetForAlt(persistence.antlr.Alternative alt)
public void genLookaheadSetForBlock(persistence.antlr.AlternativeBlock blk)
blk - The block of interestpublic void genNextToken()
public void genRule(persistence.antlr.RuleSymbol s)
s - The RuleSymbol describing the rule to generateprotected void genSynPred(persistence.antlr.SynPredBlock blk)
blk - The syntactic predicate blockpublic void genTail()
protected void genTokenTypes(persistence.antlr.TokenManager tm)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String processActionForSpecialSymbols(java.lang.String actionStr,
int line,
RuleBlock currentRule,
ActionTransInfo tInfo)
CodeGeneratorprocessActionForSpecialSymbols in class CodeGeneratorpublic java.lang.String getASTCreateString(persistence.antlr.collections.impl.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(persistence.antlr.GrammarAtom atom,
java.lang.String str)
getASTCreateString in class CodeGeneratorstr - The arguments to the AST constructorpublic java.lang.String mapTreeId(java.lang.String id,
ActionTransInfo tInfo)
mapTreeId in class CodeGeneratorid - The identifier name to mapforInput - true if the input tree node variable is to be returned, otherwise the output variable is returned.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