Public Member Functions | Protected Member Functions | Protected Attributes | Static Package Functions

antlr.DocBookCodeGenerator Class Reference

Inheritance diagram for antlr.DocBookCodeGenerator:
antlr.CodeGenerator

List of all members.

Public Member Functions

 DocBookCodeGenerator ()
void gen ()
void gen (ActionElement action)
void gen (AlternativeBlock blk)
void gen (BlockEndElement end)
void gen (CharLiteralElement atom)
void gen (CharRangeElement r)
void gen (LexerGrammar g) throws IOException
void gen (OneOrMoreBlock blk)
void gen (ParserGrammar g) throws IOException
void gen (RuleRefElement rr)
void gen (StringLiteralElement atom)
void gen (TokenRangeElement r)
void gen (TokenRefElement atom)
void gen (TreeElement t)
void gen (TreeWalkerGrammar g) throws IOException
void gen (WildcardElement wc)
void gen (ZeroOrMoreBlock blk)
void genCommonBlock (AlternativeBlock blk)
void genFollowSetForRuleBlock (RuleBlock blk)
void genLookaheadSetForBlock (AlternativeBlock blk)
void genNextToken ()
void genRule (RuleSymbol s)
void genTail ()
String getASTCreateString (Vector v)
String getASTCreateString (GrammarAtom atom, String str)
String mapTreeId (String id, ActionTransInfo tInfo)
void printSet (int depth, int k, Lookahead lookahead)

Protected Member Functions

void genAlt (Alternative alt)
void genGenericBlock (AlternativeBlock blk, String blkOp)
void genHeader ()
void genLookaheadSetForAlt (Alternative alt)
void genSynPred (SynPredBlock blk)
void genTokenTypes (TokenManager tm) throws IOException
String processActionForSpecialSymbols (String actionStr, int line, RuleBlock currentRule, ActionTransInfo tInfo)
 unused.

Protected Attributes

int syntacticPredLevel = 0
boolean doingLexRules = false
boolean firstElementInAlt
AlternativeElement prevAltElem = null

Static Package Functions

static String HTMLEncode (String s)
static String QuoteForId (String s)

Detailed Description

Generate P.sgml, a cross-linked representation of P with or without actions


Constructor & Destructor Documentation

antlr.DocBookCodeGenerator.DocBookCodeGenerator (  ) 

Create a Diagnostic code-generator using the given Grammar The caller must still call setTool, setBehavior, and setAnalyzer before generating code.

References antlr.CodeGenerator.charFormatter.


Member Function Documentation

void antlr.DocBookCodeGenerator.gen ( ActionElement  action  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The {...} action to generate

Implements antlr.CodeGenerator.

void antlr.DocBookCodeGenerator.gen ( CharRangeElement  r  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The character-range reference to generate

Implements antlr.CodeGenerator.

References antlr.CharRangeElement.beginText, antlr.CharRangeElement.endText, and antlr.CodeGenerator.print().

void antlr.DocBookCodeGenerator.gen ( TreeElement  t  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The tree to generate code for.

Implements antlr.CodeGenerator.

References antlr.CodeGenerator.print().

void antlr.DocBookCodeGenerator.gen ( WildcardElement  wc  )  [virtual]

Generate a wildcard element

Implements antlr.CodeGenerator.

References antlr.CodeGenerator._print().

void antlr.DocBookCodeGenerator.gen ( ZeroOrMoreBlock  blk  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The (...)* block to generate

Implements antlr.CodeGenerator.

References antlr.DocBookCodeGenerator.genGenericBlock().

void antlr.DocBookCodeGenerator.gen ( AlternativeBlock  blk  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The "x|y|z|..." block to generate

Implements antlr.CodeGenerator.

References antlr.DocBookCodeGenerator.genGenericBlock().

void antlr.DocBookCodeGenerator.gen ( OneOrMoreBlock  blk  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The (...)+ block to generate

Implements antlr.CodeGenerator.

References antlr.DocBookCodeGenerator.genGenericBlock().

void antlr.DocBookCodeGenerator.gen ( BlockEndElement  end  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The block-end element to generate. Block-end elements are synthesized by the grammar parser to represent the end of a block.

Implements antlr.CodeGenerator.

void antlr.DocBookCodeGenerator.gen ( RuleRefElement  rr  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The rule-reference to generate

Implements antlr.CodeGenerator.

References antlr.CodeGenerator._print(), antlr.Grammar.getSymbol(), antlr.CodeGenerator.grammar, antlr.DocBookCodeGenerator.QuoteForId(), and antlr.RuleRefElement.targetRule.

void antlr.DocBookCodeGenerator.gen ( StringLiteralElement  atom  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The string-literal reference to generate

Implements antlr.CodeGenerator.

References antlr.CodeGenerator._print(), antlr.GrammarAtom.atomText, antlr.DocBookCodeGenerator.HTMLEncode(), and antlr.GrammarAtom.not.

void antlr.DocBookCodeGenerator.gen ( CharLiteralElement  atom  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The character literal reference to generate

Implements antlr.CodeGenerator.

References antlr.CodeGenerator._print(), antlr.GrammarAtom.atomText, antlr.DocBookCodeGenerator.HTMLEncode(), and antlr.GrammarAtom.not.

void antlr.DocBookCodeGenerator.gen ( TokenRangeElement  r  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The token-range reference to generate

Implements antlr.CodeGenerator.

References antlr.TokenRangeElement.beginText, antlr.TokenRangeElement.endText, and antlr.CodeGenerator.print().

void antlr.DocBookCodeGenerator.gen ( TokenRefElement  atom  )  [virtual]

Generate code for the given grammar element.

Parameters:
blk The token-reference to generate

Implements antlr.CodeGenerator.

References antlr.CodeGenerator._print(), antlr.GrammarAtom.atomText, and antlr.GrammarAtom.not.

void antlr.DocBookCodeGenerator.genCommonBlock ( 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. The block for which the preamble is to be generated. 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.

References antlr.CodeGenerator._print(), antlr.CodeGenerator._println(), antlr.AlternativeBlock.alternatives, antlr.DocBookCodeGenerator.firstElementInAlt, antlr.DocBookCodeGenerator.genAlt(), antlr.AlternativeBlock.getAlternativeAt(), antlr.Alternative.head, antlr.CodeGenerator.print(), antlr.CodeGenerator.println(), antlr.collections.impl.Vector.size(), and antlr.CodeGenerator.tabs.

Referenced by antlr.DocBookCodeGenerator.genGenericBlock(), antlr.DocBookCodeGenerator.genNextToken(), and antlr.DocBookCodeGenerator.genRule().

void antlr.DocBookCodeGenerator.genFollowSetForRuleBlock ( RuleBlock  blk  ) 

Generate a textual representation of the follow set for a block.

Parameters:
blk The rule block of interest

References antlr.RuleBlock.endNode, antlr.LLkGrammarAnalyzer.FOLLOW(), antlr.CodeGenerator.grammar, antlr.Grammar.maxk, antlr.DocBookCodeGenerator.printSet(), and antlr.Grammar.theLLkAnalyzer.

void antlr.DocBookCodeGenerator.genHeader (  )  [protected]
void antlr.DocBookCodeGenerator.genLookaheadSetForBlock ( AlternativeBlock  blk  ) 
void antlr.DocBookCodeGenerator.genNextToken (  ) 

Generate the nextToken rule. nextToken is a synthetic lexer rule that is the implicit OR of all user-defined lexer rules.

References antlr.RuleSymbol.access, antlr.Grammar.define(), antlr.DocBookCodeGenerator.genCommonBlock(), antlr.CodeGenerator.grammar, antlr.CodeGenerator.println(), antlr.Grammar.rules, antlr.RuleSymbol.setBlock(), and antlr.RuleSymbol.setDefined().

Referenced by antlr.DocBookCodeGenerator.gen().

void antlr.DocBookCodeGenerator.genSynPred ( SynPredBlock  blk  )  [protected]

Generate the syntactic predicate. This basically generates the alternative block, buts tracks if we are inside a synPred

Parameters:
blk The syntactic predicate block
void antlr.DocBookCodeGenerator.genTail (  ) 
String antlr.DocBookCodeGenerator.getASTCreateString ( Vector  v  )  [virtual]

Get a string for an expression to generate creation of an AST subtree.

Parameters:
v A Vector of String, where each element is an expression in the target language yielding an AST node.

Implements antlr.CodeGenerator.

String antlr.DocBookCodeGenerator.getASTCreateString ( GrammarAtom  atom,
String  str 
) [virtual]

Get a string for an expression to generate creating of an AST node

Parameters:
str The arguments to the AST constructor

Implements antlr.CodeGenerator.

static String antlr.DocBookCodeGenerator.HTMLEncode ( String  s  )  [static, package]

Encode a string for printing in a HTML document.. e.g. encode '<' '>' and similar stuff

Parameters:
s the string to encode

Referenced by antlr.DocBookCodeGenerator.gen(), and antlr.DocBookCodeGenerator.genRule().

String antlr.DocBookCodeGenerator.mapTreeId ( String  id,
ActionTransInfo  tInfo 
) [virtual]

Map an identifier to it's corresponding tree-node variable. This is context-sensitive, depending on the rule and alternative being generated

Parameters:
id The identifier name to map
forInput true if the input tree node variable is to be returned, otherwise the output variable is returned.

Implements antlr.CodeGenerator.

String antlr.DocBookCodeGenerator.processActionForSpecialSymbols ( String  actionStr,
int  line,
RuleBlock  currentRule,
ActionTransInfo  tInfo 
) [protected, virtual]

unused.

Implements antlr.CodeGenerator.

static String antlr.DocBookCodeGenerator.QuoteForId ( String  s  )  [static, package]

Encode a string for printing in a HTML document.. e.g. encode '<' '>' and similar stuff

Parameters:
s the string to encode

Referenced by antlr.DocBookCodeGenerator.gen(), and antlr.DocBookCodeGenerator.genRule().


Member Data Documentation

boolean antlr.DocBookCodeGenerator.doingLexRules = false [protected]

true during lexer generation, false during parser generation

Referenced by antlr.DocBookCodeGenerator.gen(), antlr.DocBookCodeGenerator.genLookaheadSetForAlt(), and antlr.DocBookCodeGenerator.printSet().

non-zero if inside syntactic predicate generation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties