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
  • Field Details

    • RULE_BLOCK_NESTING_LEVEL

      protected static final int RULE_BLOCK_NESTING_LEVEL
      See Also:
    • OUTER_REWRITE_NESTING_LEVEL

      protected static final int OUTER_REWRITE_NESTING_LEVEL
      See Also:
    • currentRuleName

      protected 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 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 String outputOption
    • _tokenNames

      public static final String[] _tokenNames
  • Constructor Details

    • CodeGenTreeWalker

      public CodeGenTreeWalker()
  • Method Details

    • getCurrentRuleName

      public String getCurrentRuleName()
    • setCurrentRuleName

      public void setCurrentRuleName(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(String s)
      Overrides:
      reportError in class antlr.TreeParser
    • getWildcardST

      protected org.antlr.stringtemplate.StringTemplate getWildcardST(GrammarAST elementAST, GrammarAST ast_suffix, String label)
    • getRuleElementST

      protected org.antlr.stringtemplate.StringTemplate getRuleElementST(String name, String ruleTargetName, GrammarAST elementAST, GrammarAST ast_suffix, String label)
    • getTokenElementST

      protected org.antlr.stringtemplate.StringTemplate getTokenElementST(String name, String elementName, GrammarAST elementAST, GrammarAST ast_suffix, String label)
    • isListLabel

      public boolean isListLabel(String label)
    • getSTSuffix

      protected String getSTSuffix(GrammarAST elementAST, GrammarAST ast_suffix, String label)
      Return a non-empty template name suffix if the token is to be tracked, added to a tree, or both.
    • getTokenTypesAsTargetLabels

      protected List<String> getTokenTypesAsTargetLabels(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, 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, 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