Class Rule

    • Field Detail

      • 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
      • 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
      • index

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

        public int actionIndex
    • Method Detail

      • defineActionInAlt

        public void defineActionInAlt(int currentAlt,
                                      ActionAST actionAST)
      • defineLexerAction

        public void defineLexerAction(ActionAST actionAST)
        Lexer actions are numbered across rules 0..n-1
      • definePredicateInAlt

        public void definePredicateInAlt(int currentAlt,
                                         PredAST predAST)
      • resolveRetvalOrProperty

        public Attribute resolveRetvalOrProperty(String y)
      • getTokenRefs

        public Set<String> getTokenRefs()
      • getElementLabelNames

        public Set<String> getElementLabelNames()
      • getElementLabelDefs

        public <any> getElementLabelDefs()
      • hasAltSpecificContexts

        public boolean hasAltSpecificContexts()
      • getOriginalNumberOfAlts

        public int getOriginalNumberOfAlts()
        Used for recursive rules (subclass), which have 1 alt, but many original alts
      • getAltLabels

        public Map<String,List<<any>>> getAltLabels()
        Get # labels. The keys of the map are the labels applied to outer alternatives of a lexer rule, and the values are collections of pairs (alternative number and AltAST) identifying the alternatives with this label. Unlabeled alternatives are not included in the result.
      • getUnlabeledAltASTs

        public List<AltAST> getUnlabeledAltASTs()
      • resolveToAttribute

        public Attribute resolveToAttribute(String x,
                                            ActionAST node)
        $x Attribute: rule arguments, return values, predefined rule prop.
      • resolveToAttribute

        public Attribute resolveToAttribute(String x,
                                            String y,
                                            ActionAST node)
        $x.y Attribute: x is surrounding rule, label ref (in any alts)
      • resolvesToLabel

        public boolean resolvesToLabel(String x,
                                       ActionAST node)
      • resolvesToListLabel

        public boolean resolvesToListLabel(String x,
                                           ActionAST node)
      • resolvesToToken

        public boolean resolvesToToken(String x,
                                       ActionAST node)
      • resolvesToAttributeDict

        public boolean resolvesToAttributeDict(String x,
                                               ActionAST node)
      • resolveToRule

        public Rule resolveToRule(String x)
      • isFragment

        public boolean isFragment()
      • hashCode

        public int hashCode()
      • equals

        public boolean equals(Object obj)
      • toString

        public String toString()