Top Description Fields Constructors Methods
org.antlr.v4.tool

public Class Alternative

extends Object
implements AttributeResolver
Class Inheritance
All Implemented Interfaces
org.antlr.v4.tool.AttributeResolver
Imports
org.antlr.v4.tool.ast.ActionAST, .AltAST, .GrammarAST, .TerminalAST, org.stringtemplate.v4.misc.MultiMap, java.util.ArrayList, .List

An outermost alternative for a rule. We don't track inner alternatives.

Field Summary

Modifier and TypeField and Description
public List<ActionAST>
actions

Track all executable actions other than named actions like @init and catch/finally (not in an alt).

public int
altNum

What alternative number is this outermost alt?

public AltAST
public MultiMap<String, LabelElementPair>
labelDefs

A list of all LabelElementPair attached to tokens like id=ID, ids+=ID

public Rule
public MultiMap<String, GrammarAST>
public MultiMap<String, GrammarAST>
public MultiMap<String, TerminalAST>
public MultiMap<String, GrammarAST>

Constructor Summary

AccessConstructor and Description
public
Alternative(Rule r, int altNum)

Method Summary

Modifier and TypeMethod and Description
public LabelElementPair
public boolean
public boolean
public boolean
public boolean
public Attribute
resolveToAttribute(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolveToAttribute.

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

Implements org.antlr.v4.tool.AttributeResolver.resolveToAttribute.

$x.y, x can be surrounding rule, token/rule/label ref.
public Rule
resolveToRule(String x)

x can be ruleref or rule label.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionsback to summary
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

altNumback to summary
public int altNum

What alternative number is this outermost alt? 1..n

astback to summary
public AltAST ast
labelDefsback to summary
public MultiMap<String, LabelElementPair> labelDefs

A list of all LabelElementPair attached to tokens like id=ID, ids+=ID

ruleback to summary
public Rule rule
ruleRefsback to summary
public MultiMap<String, GrammarAST> ruleRefs
ruleRefsInActionsback to summary
public MultiMap<String, GrammarAST> ruleRefsInActions
tokenRefsback to summary
public MultiMap<String, TerminalAST> tokenRefs
tokenRefsInActionsback to summary
public MultiMap<String, GrammarAST> tokenRefsInActions

Constructor Detail

Alternativeback to summary
public Alternative(Rule r, int altNum)

Method Detail

getAnyLabelDefback to summary
public LabelElementPair getAnyLabelDef(String x)
resolvesToAttributeDictback to summary
public boolean resolvesToAttributeDict(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolvesToAttributeDict.

Annotations
@Override
resolvesToLabelback to summary
public boolean resolvesToLabel(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolvesToLabel.

Annotations
@Override
resolvesToListLabelback to summary
public boolean resolvesToListLabel(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolvesToListLabel.

Annotations
@Override
resolvesToTokenback to summary
public boolean resolvesToToken(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolvesToToken.

Annotations
@Override
resolveToAttributeback to summary
public Attribute resolveToAttribute(String x, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolveToAttribute.

$x Attribute: rule arguments, return values, predefined rule prop.

Annotations
@Override
resolveToAttributeback to summary
public Attribute resolveToAttribute(String x, String y, ActionAST node)

Implements org.antlr.v4.tool.AttributeResolver.resolveToAttribute.

$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.

Annotations
@Override
resolveToRuleback to summary
public Rule resolveToRule(String x)

x can be ruleref or rule label.