public class Rule extends Object implements AttributeResolver
Modifier and Type | Field and Description |
---|---|
int |
actionIndex |
List<ActionAST> |
actions
Track all executable actions other than named actions like @init
and catch/finally (not in an alt).
|
Alternative[] |
alt
1..n alts
|
AttributeDict |
args |
RuleAST |
ast |
List<GrammarAST> |
exceptions
Track exception handlers; points at "catch" node of (catch exception action)
don't track finally action
|
ActionAST |
finallyAction |
Grammar |
g
In which grammar does this rule live?
|
int |
index
All rules have unique index 0..n-1
|
boolean |
isStartRule |
AttributeDict |
locals |
String |
mode
If we're in a lexer grammar, we might be in a mode
|
List<GrammarAST> |
modifiers |
String |
name |
Map<String,ActionAST> |
namedActions
Map a name to an action for this rule like @init {...}.
|
int |
numberOfAlts |
static AttributeDict |
predefinedRulePropertiesDict
Rule refs have a predefined set of attributes as well as
the return values and args.
|
AttributeDict |
retvals |
static Set<String> |
validLexerCommands |
Constructor and Description |
---|
Rule(Grammar g,
String name,
RuleAST ast,
int numberOfAlts) |
public static final AttributeDict predefinedRulePropertiesDict
public String name
public List<GrammarAST> modifiers
public RuleAST ast
public AttributeDict args
public AttributeDict retvals
public AttributeDict locals
public Grammar g
public String mode
public Map<String,ActionAST> namedActions
public List<GrammarAST> exceptions
public List<ActionAST> actions
public ActionAST finallyAction
public int numberOfAlts
public boolean isStartRule
public Alternative[] alt
public int index
public int actionIndex
public void defineActionInAlt(int currentAlt, ActionAST actionAST)
public void defineLexerAction(ActionAST actionAST)
public void definePredicateInAlt(int currentAlt, PredAST predAST)
public org.stringtemplate.v4.misc.MultiMap<String,LabelElementPair> getElementLabelDefs()
public boolean hasAltSpecificContexts()
public int getOriginalNumberOfAlts()
public Map<String,List<Pair<Integer,AltAST>>> getAltLabels()
#
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.public Attribute resolveToAttribute(String x, ActionAST node)
resolveToAttribute
in interface AttributeResolver
public Attribute resolveToAttribute(String x, String y, ActionAST node)
resolveToAttribute
in interface AttributeResolver
public boolean resolvesToLabel(String x, ActionAST node)
resolvesToLabel
in interface AttributeResolver
public boolean resolvesToListLabel(String x, ActionAST node)
resolvesToListLabel
in interface AttributeResolver
public boolean resolvesToToken(String x, ActionAST node)
resolvesToToken
in interface AttributeResolver
public boolean resolvesToAttributeDict(String x, ActionAST node)
resolvesToAttributeDict
in interface AttributeResolver
public LabelElementPair getAnyLabelDef(String x)
public AttributeDict getPredefinedScope(LabelType ltype)
public boolean isFragment()
Copyright © 1992–2020 ANTLR. All rights reserved.