HTMLEncode
(package private) static String HTMLEncode(String s)
Encode a string for printing in a HTML document..
e.g. encode '<' '>' and similar stuff
s - the string to encode
gen
public void gen()
Generate the code for all grammars
- gen in interface CodeGenerator
gen
public void gen(AlternativeBlock blk)
Generate code for the given grammar element.
- gen in interface CodeGenerator
blk - The "x|y|z|..." block to generate
gen
public void gen(OneOrMoreBlock blk)
Generate code for the given grammar element.
- gen in interface CodeGenerator
blk - The (...)+ block to generate
gen
public void gen(ZeroOrMoreBlock blk)
Generate code for the given grammar element.
- gen in interface CodeGenerator
blk - The (...)* block to generate
genCommonBlock
public void genCommonBlock(AlternativeBlock blk)
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)
Generate a textual representation of the follow set
for a block.
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)
Generate a textual representation of the lookahead set
for a block.
blk - The block of interest
genNextToken
public void genNextToken()
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)
Generate code for a named rule block
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
blk - The syntactic predicate block
genTail
public void genTail()
genTokenTypes
protected void genTokenTypes(TokenManager tm)
throws IOExceptionGenerate the token types TXT file
getASTCreateString
public String getASTCreateString(GrammarAtom atom,
String str)Get a string for an expression to generate creating of an AST node
- getASTCreateString in interface CodeGenerator
str - The arguments to the AST constructor
getASTCreateString
public String getASTCreateString(Vector v)
Get a string for an expression to generate creation of an AST subtree.
- getASTCreateString in interface CodeGenerator
v - A Vector of String, where each element is an expression in the target language yielding an AST node.
mapTreeId
public String mapTreeId(String id,
ActionTransInfo tInfo)Map an identifier to it's corresponding tree-node variable.
This is context-sensitive, depending on the rule and alternative
being generated
- mapTreeId in interface CodeGenerator
id - The identifier name to map
printSet
public void printSet(int depth,
int k,
Lookahead lookahead)Format a lookahead or follow set.
depth - The depth of the entire lookahead/followk - The lookahead level to printlookahead - The lookahead/follow set to print
processActionForSpecialSymbols
protected String processActionForSpecialSymbols(String actionStr,
int line,
RuleBlock currentRule,
ActionTransInfo tInfo)Lexically process $ and # references within the action.
This will replace #id and #(...) with the appropriate
function calls and/or variables etc...
- processActionForSpecialSymbols in interface CodeGenerator