org.antlr.grammar.v2
Class CodeGenTreeWalker
java.lang.Object
antlr.TreeParser
org.antlr.grammar.v2.CodeGenTreeWalker
- All Implemented Interfaces:
- CodeGenTreeWalkerTokenTypes
public class CodeGenTreeWalker
- extends antlr.TreeParser
- implements CodeGenTreeWalkerTokenTypes
Walk a grammar and generate code by gradually building up
a bigger and bigger StringTemplate.
Terence Parr
University of San Francisco
June 15, 2004
Fields inherited from class antlr.TreeParser |
_retTree, astFactory, ASTNULL, inputState, returnAST, tokenNames, traceDepth |
Fields inherited from interface org.antlr.grammar.v2.CodeGenTreeWalkerTokenTypes |
ACTION, ACTION_CHAR_LITERAL, ACTION_ESC, ACTION_STRING_LITERAL, ALT, AMPERSAND, ARG, ARG_ACTION, ARGLIST, ASSIGN, BACKTRACK_SEMPRED, BANG, BLOCK, CHAR_LITERAL, CHAR_RANGE, CLOSE_ELEMENT_OPTION, CLOSURE, COLON, COMBINED_GRAMMAR, COMMA, COMMENT, DIGIT, DOC_COMMENT, DOLLAR, DOT, DOUBLE_ANGLE_STRING_LITERAL, DOUBLE_QUOTE_STRING_LITERAL, EOA, EOB, EOF, EOR, EPSILON, ESC, ETC, FORCED_ACTION, FRAGMENT, GATED_SEMPRED, ID, IMPLIES, IMPORT, INITACTION, INT, INTERNAL_RULE_REF, LABEL, LEXER, LEXER_GRAMMAR, LITERAL_catch, LITERAL_finally, LITERAL_grammar, LITERAL_lexer, LITERAL_private, LITERAL_protected, LITERAL_public, LITERAL_returns, LITERAL_throws, LITERAL_tree, LPAREN, ML_COMMENT, NESTED_ACTION, NESTED_ARG_ACTION, NOT, NULL_TREE_LOOKAHEAD, OPEN_ELEMENT_OPTION, OPTIONAL, OPTIONS, OR, PARSER, PARSER_GRAMMAR, PLUS, PLUS_ASSIGN, POSITIVE_CLOSURE, QUESTION, RANGE, RCURLY, RET, REWRITE, ROOT, RPAREN, RULE, RULE_REF, SCOPE, SEMI, SEMPRED, SL_COMMENT, SRC, STAR, STRAY_BRACKET, STRING_LITERAL, SYN_SEMPRED, SYNPRED, TEMPLATE, TOKEN_REF, TOKENS, TREE_BEGIN, TREE_GRAMMAR, WILDCARD, WS, WS_LOOP, WS_OPT, XDIGIT |
Method Summary |
org.antlr.stringtemplate.StringTemplate |
alternative(antlr.collections.AST _t)
|
void |
ast_suffix(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
atom(antlr.collections.AST _t,
GrammarAST scope,
GrammarAST label,
GrammarAST astSuffix)
|
void |
attrScope(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
block(antlr.collections.AST _t,
java.lang.String blockTemplateName,
DFA dfa)
|
org.antlr.stringtemplate.StringTemplate |
ebnf(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
element_action(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
element(antlr.collections.AST _t,
GrammarAST label,
GrammarAST astSuffix)
|
void |
exceptionGroup(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
|
void |
exceptionHandler(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
|
void |
finallyClause(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
|
java.lang.String |
getCurrentRuleName()
|
int |
getOuterAltNum()
|
protected org.antlr.stringtemplate.StringTemplate |
getRuleElementST(java.lang.String name,
java.lang.String ruleTargetName,
GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
|
protected java.lang.String |
getSTSuffix(GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
Return a non-empty template name suffix if the token is to be
tracked, added to a tree, or both. |
protected org.antlr.stringtemplate.StringTemplate |
getTokenElementST(java.lang.String name,
java.lang.String elementName,
GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
|
protected java.util.List<java.lang.String> |
getTokenTypesAsTargetLabels(java.util.Set<GrammarAST> refs)
Convert rewrite AST lists to target labels list |
protected org.antlr.stringtemplate.StringTemplate |
getWildcardST(GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
|
void |
grammar(antlr.collections.AST _t,
Grammar g,
org.antlr.stringtemplate.StringTemplate recognizerST,
org.antlr.stringtemplate.StringTemplate outputFileST,
org.antlr.stringtemplate.StringTemplate headerFileST)
|
void |
grammarSpec(antlr.collections.AST _t)
|
void |
init(Grammar g)
|
boolean |
isListLabel(java.lang.String label)
|
void |
modifier(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
notElement(antlr.collections.AST _t,
GrammarAST n,
GrammarAST label,
GrammarAST astSuffix)
|
void |
reportError(antlr.RecognitionException ex)
|
void |
reportError(java.lang.String s)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_alternative(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_atom(antlr.collections.AST _t,
boolean isRoot)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_block(antlr.collections.AST _t,
java.lang.String blockTemplateName)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_ebnf(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_element(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_template(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rewrite_tree(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rewrite(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
rule(antlr.collections.AST _t)
|
void |
rules(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate recognizerST)
|
void |
ruleScopeSpec(antlr.collections.AST _t)
|
org.antlr.stringtemplate.StringTemplate |
set(antlr.collections.AST _t,
GrammarAST label,
GrammarAST astSuffix)
|
org.antlr.stringtemplate.StringTemplate |
setBlock(antlr.collections.AST _t)
|
void |
setCurrentRuleName(java.lang.String currentRuleName)
|
void |
setElement(antlr.collections.AST _t)
|
void |
setOuterAltNum(int outerAltNum)
|
org.antlr.stringtemplate.StringTemplate |
tree(antlr.collections.AST _t)
|
Methods inherited from class antlr.TreeParser |
getAST, getASTFactory, getTokenName, getTokenNames, match, match, matchNot, panic, reportWarning, setASTFactory, setASTNodeClass, setASTNodeType, traceIn, traceIndent, traceOut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RULE_BLOCK_NESTING_LEVEL
protected static final int RULE_BLOCK_NESTING_LEVEL
- See Also:
- Constant Field Values
OUTER_REWRITE_NESTING_LEVEL
protected static final int OUTER_REWRITE_NESTING_LEVEL
- See Also:
- Constant Field Values
currentRuleName
protected java.lang.String currentRuleName
blockNestingLevel
protected int blockNestingLevel
rewriteBlockNestingLevel
protected int rewriteBlockNestingLevel
outerAltNum
protected int outerAltNum
currentBlockST
protected org.antlr.stringtemplate.StringTemplate currentBlockST
currentAltHasASTRewrite
protected boolean currentAltHasASTRewrite
rewriteTreeNestingLevel
protected int rewriteTreeNestingLevel
rewriteRuleRefs
protected java.util.Set rewriteRuleRefs
generator
protected CodeGenerator generator
grammar
protected Grammar grammar
templates
protected org.antlr.stringtemplate.StringTemplateGroup templates
recognizerST
protected org.antlr.stringtemplate.StringTemplate recognizerST
- The overall lexer/parser template; simulate dynamically scoped
attributes by making this an instance var of the walker.
outputFileST
protected org.antlr.stringtemplate.StringTemplate outputFileST
headerFileST
protected org.antlr.stringtemplate.StringTemplate headerFileST
outputOption
protected java.lang.String outputOption
_tokenNames
public static final java.lang.String[] _tokenNames
CodeGenTreeWalker
public CodeGenTreeWalker()
getCurrentRuleName
public java.lang.String getCurrentRuleName()
setCurrentRuleName
public void setCurrentRuleName(java.lang.String currentRuleName)
getOuterAltNum
public int getOuterAltNum()
setOuterAltNum
public void setOuterAltNum(int outerAltNum)
reportError
public void reportError(antlr.RecognitionException ex)
- Overrides:
reportError
in class antlr.TreeParser
reportError
public void reportError(java.lang.String s)
- Overrides:
reportError
in class antlr.TreeParser
getWildcardST
protected org.antlr.stringtemplate.StringTemplate getWildcardST(GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
getRuleElementST
protected org.antlr.stringtemplate.StringTemplate getRuleElementST(java.lang.String name,
java.lang.String ruleTargetName,
GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
getTokenElementST
protected org.antlr.stringtemplate.StringTemplate getTokenElementST(java.lang.String name,
java.lang.String elementName,
GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
isListLabel
public boolean isListLabel(java.lang.String label)
getSTSuffix
protected java.lang.String getSTSuffix(GrammarAST elementAST,
GrammarAST ast_suffix,
java.lang.String label)
- Return a non-empty template name suffix if the token is to be
tracked, added to a tree, or both.
getTokenTypesAsTargetLabels
protected java.util.List<java.lang.String> getTokenTypesAsTargetLabels(java.util.Set<GrammarAST> refs)
- Convert rewrite AST lists to target labels list
init
public void init(Grammar g)
grammar
public final void grammar(antlr.collections.AST _t,
Grammar g,
org.antlr.stringtemplate.StringTemplate recognizerST,
org.antlr.stringtemplate.StringTemplate outputFileST,
org.antlr.stringtemplate.StringTemplate headerFileST)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
grammarSpec
public final void grammarSpec(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
attrScope
public final void attrScope(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rules
public final void rules(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate recognizerST)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rule
public final org.antlr.stringtemplate.StringTemplate rule(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
modifier
public final void modifier(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
ruleScopeSpec
public final void ruleScopeSpec(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
block
public final org.antlr.stringtemplate.StringTemplate block(antlr.collections.AST _t,
java.lang.String blockTemplateName,
DFA dfa)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
exceptionGroup
public final void exceptionGroup(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
setBlock
public final org.antlr.stringtemplate.StringTemplate setBlock(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
alternative
public final org.antlr.stringtemplate.StringTemplate alternative(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite
public final org.antlr.stringtemplate.StringTemplate rewrite(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
exceptionHandler
public final void exceptionHandler(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
finallyClause
public final void finallyClause(antlr.collections.AST _t,
org.antlr.stringtemplate.StringTemplate ruleST)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
element
public final org.antlr.stringtemplate.StringTemplate element(antlr.collections.AST _t,
GrammarAST label,
GrammarAST astSuffix)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
notElement
public final org.antlr.stringtemplate.StringTemplate notElement(antlr.collections.AST _t,
GrammarAST n,
GrammarAST label,
GrammarAST astSuffix)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
ebnf
public final org.antlr.stringtemplate.StringTemplate ebnf(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
atom
public final org.antlr.stringtemplate.StringTemplate atom(antlr.collections.AST _t,
GrammarAST scope,
GrammarAST label,
GrammarAST astSuffix)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
tree
public final org.antlr.stringtemplate.StringTemplate tree(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
element_action
public final org.antlr.stringtemplate.StringTemplate element_action(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
set
public final org.antlr.stringtemplate.StringTemplate set(antlr.collections.AST _t,
GrammarAST label,
GrammarAST astSuffix)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
ast_suffix
public final void ast_suffix(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
setElement
public final void setElement(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_alternative
public final org.antlr.stringtemplate.StringTemplate rewrite_alternative(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_block
public final org.antlr.stringtemplate.StringTemplate rewrite_block(antlr.collections.AST _t,
java.lang.String blockTemplateName)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_element
public final org.antlr.stringtemplate.StringTemplate rewrite_element(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_template
public final org.antlr.stringtemplate.StringTemplate rewrite_template(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_atom
public final org.antlr.stringtemplate.StringTemplate rewrite_atom(antlr.collections.AST _t,
boolean isRoot)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_ebnf
public final org.antlr.stringtemplate.StringTemplate rewrite_ebnf(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
rewrite_tree
public final org.antlr.stringtemplate.StringTemplate rewrite_tree(antlr.collections.AST _t)
throws antlr.RecognitionException
- Throws:
antlr.RecognitionException
Copyright © 2013. All Rights Reserved.