Class Rule

java.lang.Object
org.antlr.v4.tool.Rule
All Implemented Interfaces:
AttributeResolver
Direct Known Subclasses:
LeftRecursiveRule

public class Rule extends Object implements AttributeResolver
  • Field Details

    • predefinedRulePropertiesDict

      public static final AttributeDict predefinedRulePropertiesDict
      Rule refs have a predefined set of attributes as well as the return values and args. These must be consistent with ActionTranslator.rulePropToModelMap, ...
    • validLexerCommands

      public static final Set<String> validLexerCommands
    • name

      public String name
    • modifiers

      public List<GrammarAST> modifiers
    • ast

      public RuleAST ast
    • args

      public AttributeDict args
    • retvals

      public AttributeDict retvals
    • locals

      public AttributeDict locals
    • g

      public Grammar g
      In which grammar does this rule live?
    • mode

      public String mode
      If we're in a lexer grammar, we might be in a mode
    • namedActions

      public Map<String,ActionAST> namedActions
      Map a name to an action for this rule like @init {...}. The code generator will use this to fill holes in the rule template. I track the AST node for the action in case I need the line number for errors.
    • exceptions

      public List<GrammarAST> exceptions
      Track exception handlers; points at "catch" node of (catch exception action) don't track finally action
    • actions

      public List<ActionAST> actions
      Track all executable actions other than named actions like @init and catch/finally (not in an alt). Also tracks predicates, rewrite actions. We need to examine these actions before code generation so that we can detect refs to $rule.attr etc... This tracks per rule; Alternative objs also track per alt.
    • finallyAction

      public ActionAST finallyAction
    • numberOfAlts

      public int numberOfAlts
    • isStartRule

      public boolean isStartRule
    • alt

      public Alternative[] alt
      1..n alts
    • index

      public int index
      All rules have unique index 0..n-1
    • actionIndex

      public int actionIndex
  • Constructor Details

  • Method Details