Class Rule
java.lang.Object
org.antlr.v4.tool.Rule
- All Implemented Interfaces:
AttributeResolver
- Direct Known Subclasses:
LeftRecursiveRule
-
Field Summary
FieldsModifier and TypeFieldDescriptionintTrack all executable actions other than named actions like @init and catch/finally (not in an alt).1..n altsfinal booleanIf null then use value from global option that is false by defaultTrack exception handlers; points at "catch" node of (catch exception action) don't track finally actionfinal GrammarIn which grammar does this rule live?intAll rules have unique index 0..n-1booleanfinal StringIf we're in a lexer grammar, we might be in a modefinal StringMap a name to an action for this rule like @init {...}.final intstatic final AttributeDictRule refs have a predefined set of attributes as well as the return values and args. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddefineActionInAlt(int currentAlt, ActionAST actionAST) voiddefineLexerAction(ActionAST actionAST) Lexer actions are numbered across rules 0..n-1voiddefinePredicateInAlt(int currentAlt, PredAST predAST) booleanGet#labels.org.stringtemplate.v4.misc.MultiMap<String, LabelElementPair> intUsed for recursive rules (subclass), which have 1 alt, but many original altsgetPredefinedScope(LabelType ltype) booleaninthashCode()booleanbooleanresolvesToAttributeDict(String x, ActionAST node) booleanresolvesToLabel(String x, ActionAST node) booleanresolvesToListLabel(String x, ActionAST node) booleanresolvesToToken(String x, ActionAST node) resolveToAttribute(String x, String y, ActionAST node) $x.y Attribute: x is surrounding rule, label ref (in any alts)resolveToAttribute(String x, ActionAST node) $x Attribute: rule arguments, return values, predefined rule prop.toString()
-
Field Details
-
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
-
name
-
modifiers
-
ast
-
args
-
retvals
-
locals
-
g
In which grammar does this rule live? -
mode
If we're in a lexer grammar, we might be in a mode -
caseInsensitive
public final boolean caseInsensitiveIf null then use value from global option that is false by default -
namedActions
-
exceptions
Track exception handlers; points at "catch" node of (catch exception action) don't track finally action -
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
-
numberOfAlts
public final int numberOfAlts -
isStartRule
public boolean isStartRule -
alt
1..n alts -
index
public int indexAll rules have unique index 0..n-1 -
actionIndex
public int actionIndex
-
-
Constructor Details
-
Rule
-
Rule
-
-
Method Details
-
defineActionInAlt
-
defineLexerAction
Lexer actions are numbered across rules 0..n-1 -
definePredicateInAlt
-
resolveRetvalOrProperty
-
getTokenRefs
-
getElementLabelNames
-
getElementLabelDefs
-
hasAltSpecificContexts
public boolean hasAltSpecificContexts() -
getOriginalNumberOfAlts
public int getOriginalNumberOfAlts()Used for recursive rules (subclass), which have 1 alt, but many original alts -
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 andAltAST) identifying the alternatives with this label. Unlabeled alternatives are not included in the result. -
getUnlabeledAltASTs
-
resolveToAttribute
$x Attribute: rule arguments, return values, predefined rule prop.- Specified by:
resolveToAttributein interfaceAttributeResolver
-
resolveToAttribute
$x.y Attribute: x is surrounding rule, label ref (in any alts)- Specified by:
resolveToAttributein interfaceAttributeResolver
-
resolvesToLabel
- Specified by:
resolvesToLabelin interfaceAttributeResolver
-
resolvesToListLabel
- Specified by:
resolvesToListLabelin interfaceAttributeResolver
-
resolvesToToken
- Specified by:
resolvesToTokenin interfaceAttributeResolver
-
resolvesToAttributeDict
- Specified by:
resolvesToAttributeDictin interfaceAttributeResolver
-
resolveToRule
-
getAnyLabelDef
-
getPredefinedScope
-
isFragment
public boolean isFragment() -
hashCode
-
equals
-
toString
-