Package org.antlr.v4.tool
Class LeftRecursiveRule
- java.lang.Object
-
- org.antlr.v4.tool.Rule
-
- org.antlr.v4.tool.LeftRecursiveRule
-
- All Implemented Interfaces:
AttributeResolver
public class LeftRecursiveRule extends Rule
-
-
Field Summary
Fields Modifier and Type Field Description List<Pair<GrammarAST,String>>
leftRecursiveRuleRefLabels
Did we delete any labels on direct left-recur refs? Points at ID of ^(= ID el)RuleAST
originalAST
OrderedHashMap<Integer,LeftRecursiveRuleAltInfo>
recOpAlts
List<LeftRecursiveRuleAltInfo>
recPrimaryAlts
-
Fields inherited from class org.antlr.v4.tool.Rule
actionIndex, actions, alt, args, ast, caseInsensitive, exceptions, finallyAction, g, index, isStartRule, locals, mode, modifiers, name, namedActions, numberOfAlts, predefinedRulePropertiesDict, retvals, validLexerCommands
-
-
Constructor Summary
Constructors Constructor Description LeftRecursiveRule(Grammar g, String name, RuleAST ast)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,List<Pair<Integer,AltAST>>>
getAltLabels()
Get -> labels from those alts we deleted for left-recursive rules.RuleAST
getOriginalAST()
int
getOriginalNumberOfAlts()
Used for recursive rules (subclass), which have 1 alt, but many original altsint[]
getPrimaryAlts()
Return an array that maps predicted alt from primary decision to original alt of rule.int[]
getRecursiveOpAlts()
Return an array that maps predicted alt from recursive op decision to original alt of rule.List<AltAST>
getUnlabeledAltASTs()
boolean
hasAltSpecificContexts()
-
Methods inherited from class org.antlr.v4.tool.Rule
defineActionInAlt, defineLexerAction, definePredicateInAlt, equals, getAnyLabelDef, getElementLabelDefs, getElementLabelNames, getPredefinedScope, getTokenRefs, hashCode, isFragment, resolveRetvalOrProperty, resolvesToAttributeDict, resolvesToLabel, resolvesToListLabel, resolvesToToken, resolveToAttribute, resolveToAttribute, resolveToRule, toString
-
-
-
-
Field Detail
-
recPrimaryAlts
public List<LeftRecursiveRuleAltInfo> recPrimaryAlts
-
recOpAlts
public OrderedHashMap<Integer,LeftRecursiveRuleAltInfo> recOpAlts
-
originalAST
public RuleAST originalAST
-
leftRecursiveRuleRefLabels
public List<Pair<GrammarAST,String>> leftRecursiveRuleRefLabels
Did we delete any labels on direct left-recur refs? Points at ID of ^(= ID el)
-
-
Method Detail
-
hasAltSpecificContexts
public boolean hasAltSpecificContexts()
- Overrides:
hasAltSpecificContexts
in classRule
-
getOriginalNumberOfAlts
public int getOriginalNumberOfAlts()
Description copied from class:Rule
Used for recursive rules (subclass), which have 1 alt, but many original alts- Overrides:
getOriginalNumberOfAlts
in classRule
-
getOriginalAST
public RuleAST getOriginalAST()
-
getUnlabeledAltASTs
public List<AltAST> getUnlabeledAltASTs()
- Overrides:
getUnlabeledAltASTs
in classRule
-
getPrimaryAlts
public int[] getPrimaryAlts()
Return an array that maps predicted alt from primary decision to original alt of rule. For following rule, return [0, 2, 4] e : e '*' e | INT | e '+' e | ID ; That maps predicted alt 1 to original alt 2 and predicted 2 to alt 4.- Since:
- 4.5.1
-
getRecursiveOpAlts
public int[] getRecursiveOpAlts()
Return an array that maps predicted alt from recursive op decision to original alt of rule. For following rule, return [0, 1, 3] e : e '*' e | INT | e '+' e | ID ; That maps predicted alt 1 to original alt 1 and predicted 2 to alt 3.- Since:
- 4.5.1
-
-