antlr
Class HTMLCodeGenerator

java.lang.Object
  |
  +--antlr.CodeGenerator
        |
        +--antlr.HTMLCodeGenerator

public class HTMLCodeGenerator
extends CodeGenerator

Untamed: Generate P.html, a cross-linked representation of P with or without actions


Field Summary
protected  boolean doingLexRules
          true during lexer generation, false during parser generation
protected  boolean firstElementInAlt
           
protected  AlternativeElement prevAltElem
           
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
HTMLCodeGenerator()
          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:
 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 genGenericBlock(AlternativeBlock blk, String blkOp)
           
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.
 void genTail()
          Enabled:
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 antlr.CodeGenerator
_print, _printAction, _println, elementsAreRange, extractIdOfAction, extractIdOfAction, extractTypeOfAction, extractTypeOfAction, genTokenInterchange, getBitsetName, lexerRuleName, markBitsetForGen, print, printAction, println, printTabs, processActionForTreeSpecifiers, processStringForASTConstructor, removeAssignmentFromDeclaration, reverseLexerRuleName, setAnalyzer, setBehavior, setGrammar, setTool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

syntacticPredLevel

protected int syntacticPredLevel
non-zero if inside syntactic predicate generation


doingLexRules

protected boolean doingLexRules
true during lexer generation, false during parser generation


firstElementInAlt

protected boolean firstElementInAlt

prevAltElem

protected AlternativeElement prevAltElem
Constructor Detail

HTMLCodeGenerator

public HTMLCodeGenerator()
Enabled: Create a Diagnostic code-generator using the given Grammar The caller must still call setTool, setBehavior, and setAnalyzer before generating code.

Method Detail

gen

public void gen()
Enabled:

Specified by:
gen in class CodeGenerator

gen

public void gen(ActionElement action)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
action - The {...} action to generate

gen

public void gen(AlternativeBlock blk)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
blk - The "x|y|z|..." block to generate

gen

public void gen(BlockEndElement end)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
end - The block-end element to generate. Block-end elements are synthesized by the grammar parser to represent the end of a block.

gen

public void gen(CharLiteralElement atom)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
atom - The character literal reference to generate

gen

public void gen(CharRangeElement r)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
r - The character-range reference to generate

gen

public void gen(LexerGrammar g)
         throws IOException
Enabled: Generate the lexer TXT file

Specified by:
gen in class CodeGenerator
IOException

gen

public void gen(OneOrMoreBlock blk)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
blk - The (...)+ block to generate

gen

public void gen(ParserGrammar g)
         throws IOException
Enabled: Generate the parser TXT file

Specified by:
gen in class CodeGenerator
IOException

gen

public void gen(RuleRefElement rr)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
rr - The rule-reference to generate

gen

public void gen(StringLiteralElement atom)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
atom - The string-literal reference to generate

gen

public void gen(TokenRangeElement r)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
r - The token-range reference to generate

gen

public void gen(TokenRefElement atom)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
atom - The token-reference to generate

gen

public void gen(TreeElement t)
Enabled:

Specified by:
gen in class CodeGenerator

gen

public void gen(TreeWalkerGrammar g)
         throws IOException
Enabled: Generate the tree-walker TXT file

Specified by:
gen in class CodeGenerator
IOException

gen

public void gen(WildcardElement wc)
Enabled: Generate a wildcard element

Specified by:
gen in class CodeGenerator
Parameters:
wc - The wildcard element to generate

gen

public void gen(ZeroOrMoreBlock blk)
Enabled: Generate code for the given grammar element.

Specified by:
gen in class CodeGenerator
Parameters:
blk - The (...)* block to generate

genAlt

protected void genAlt(Alternative alt)

genBlockPreamble

protected void genBlockPreamble(AlternativeBlock blk)
Generate the header for a block, which may be a RuleBlock or a plain AlternativeBLock. This generates any variable declarations, init-actions, and syntactic-predicate-testing variables.


genCommonBlock

public 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. Other routines may append else-clauses and such for error checking before the postfix is generated.


genFollowSetForRuleBlock

public void genFollowSetForRuleBlock(RuleBlock blk)
Enabled: Generate a textual representation of the follow set for a block.

Parameters:
blk - The rule block of interest

genGenericBlock

protected void genGenericBlock(AlternativeBlock blk,
                               String blkOp)

genHeader

protected void genHeader()
Generate a header that is common to all TXT files


genLookaheadSetForAlt

protected void genLookaheadSetForAlt(Alternative alt)
Generate the lookahead set for an alternate.


genLookaheadSetForBlock

public void genLookaheadSetForBlock(AlternativeBlock blk)
Enabled: Generate a textual representation of the lookahead set for a block.

Parameters:
blk - The block of interest

genNextToken

public void genNextToken()
Enabled: Generate the nextToken rule. nextToken is a synthetic lexer rule that is the implicit OR of all user-defined lexer rules.


genRule

public void genRule(RuleSymbol s)
Enabled: Generate code for a named rule block

Parameters:
s - The RuleSymbol describing the rule to generate

genSynPred

protected void genSynPred(SynPredBlock blk)
Generate the syntactic predicate. This basically generates the alternative block, buts tracks if we are inside a synPred

Parameters:
blk - The syntactic predicate block

genTail

public void genTail()
Enabled:


genTokenTypes

protected void genTokenTypes(TokenManager tm)
                      throws IOException
Generate the token types TXT file

IOException

getASTCreateString

public String getASTCreateString(Vector v)
Enabled: Get a string for an expression to generate creation of an AST subtree.

Specified by:
getASTCreateString in class CodeGenerator
Parameters:
v - A Vector of String, where each element is an expression in the target language yielding an AST node.

getASTCreateString

public String getASTCreateString(GrammarAtom atom,
                                 String str)
Enabled: Get a string for an expression to generate creating of an AST node

Specified by:
getASTCreateString in class CodeGenerator
Parameters:
str - The arguments to the AST constructor

mapTreeId

public String mapTreeId(String id,
                        ActionTransInfo tInfo)
Enabled: Map an identifier to it's corresponding tree-node variable. This is context-sensitive, depending on the rule and alternative being generated

Specified by:
mapTreeId in class CodeGenerator
Parameters:
id - The identifier name to map
Returns:
The mapped id (which may be the same as the input), or null if the mapping is invalid due to duplicates

printSet

public void printSet(int depth,
                     int k,
                     Lookahead lookahead)
Enabled: Format a lookahead or follow set.

Parameters:
depth - The depth of the entire lookahead/follow
k - The lookahead level to print
lookahead - The lookahead/follow set to print


comments?