Package org.antlr.v4.tool
Class Alternative
- java.lang.Object
-
- org.antlr.v4.tool.Alternative
-
- All Implemented Interfaces:
AttributeResolver
public class Alternative extends Object implements AttributeResolver
An outermost alternative for a rule. We don't track inner alternatives.
-
-
Field Summary
Fields Modifier and Type Field Description List<ActionAST>actionsTrack all executable actions other than named actions like @init and catch/finally (not in an alt).intaltNumWhat alternative number is this outermost alt? 1..nAltASTastorg.stringtemplate.v4.misc.MultiMap<String,LabelElementPair>labelDefsA list of all LabelElementPair attached to tokens like id=ID, ids+=IDRuleruleorg.stringtemplate.v4.misc.MultiMap<String,GrammarAST>ruleRefsorg.stringtemplate.v4.misc.MultiMap<String,GrammarAST>ruleRefsInActionsorg.stringtemplate.v4.misc.MultiMap<String,TerminalAST>tokenRefsorg.stringtemplate.v4.misc.MultiMap<String,GrammarAST>tokenRefsInActions
-
Constructor Summary
Constructors Constructor Description Alternative(Rule r, int altNum)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LabelElementPairgetAnyLabelDef(String x)booleanresolvesToAttributeDict(String x, ActionAST node)booleanresolvesToLabel(String x, ActionAST node)booleanresolvesToListLabel(String x, ActionAST node)booleanresolvesToToken(String x, ActionAST node)AttributeresolveToAttribute(String x, String y, ActionAST node)$x.y, x can be surrounding rule, token/rule/label ref.AttributeresolveToAttribute(String x, ActionAST node)$x Attribute: rule arguments, return values, predefined rule prop.RuleresolveToRule(String x)x can be ruleref or rule label.
-
-
-
Field Detail
-
rule
public Rule rule
-
ast
public AltAST ast
-
altNum
public int altNum
What alternative number is this outermost alt? 1..n
-
tokenRefs
public org.stringtemplate.v4.misc.MultiMap<String,TerminalAST> tokenRefs
-
tokenRefsInActions
public org.stringtemplate.v4.misc.MultiMap<String,GrammarAST> tokenRefsInActions
-
ruleRefs
public org.stringtemplate.v4.misc.MultiMap<String,GrammarAST> ruleRefs
-
ruleRefsInActions
public org.stringtemplate.v4.misc.MultiMap<String,GrammarAST> ruleRefsInActions
-
labelDefs
public org.stringtemplate.v4.misc.MultiMap<String,LabelElementPair> labelDefs
A list of all LabelElementPair attached to tokens like id=ID, ids+=ID
-
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 alt
-
-
Constructor Detail
-
Alternative
public Alternative(Rule r, int altNum)
-
-
Method Detail
-
resolvesToToken
public boolean resolvesToToken(String x, ActionAST node)
- Specified by:
resolvesToTokenin interfaceAttributeResolver
-
resolvesToAttributeDict
public boolean resolvesToAttributeDict(String x, ActionAST node)
- Specified by:
resolvesToAttributeDictin interfaceAttributeResolver
-
resolveToAttribute
public Attribute resolveToAttribute(String x, ActionAST node)
$x Attribute: rule arguments, return values, predefined rule prop.- Specified by:
resolveToAttributein interfaceAttributeResolver
-
resolveToAttribute
public Attribute resolveToAttribute(String x, String y, ActionAST node)
$x.y, x can be surrounding rule, token/rule/label ref. y is visible attr in that dictionary. Can't see args on rule refs.- Specified by:
resolveToAttributein interfaceAttributeResolver
-
resolvesToLabel
public boolean resolvesToLabel(String x, ActionAST node)
- Specified by:
resolvesToLabelin interfaceAttributeResolver
-
resolvesToListLabel
public boolean resolvesToListLabel(String x, ActionAST node)
- Specified by:
resolvesToListLabelin interfaceAttributeResolver
-
getAnyLabelDef
public LabelElementPair getAnyLabelDef(String x)
-
-