| Modifier and Type | Field and Description |
|---|---|
| public ATN | |
| pack-priv Grammar | |
| public List | listOfRecursiveCycles
Holds a list of cycles (sets of rule names). |
| pack-priv Set | rulesVisitedPerRuleCheck
Which rule start states have we visited while looking for a single left-recursion check? |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public void | |
| public boolean |
| atn | back to summary |
|---|---|
| public ATN atn | |
| g | back to summary |
|---|---|
| pack-priv Grammar g | |
| listOfRecursiveCycles | back to summary |
|---|---|
| public List<Set<Rule>> listOfRecursiveCycles Holds a list of cycles (sets of rule names). | |
| rulesVisitedPerRuleCheck | back to summary |
|---|---|
| pack-priv Set<RuleStartState> rulesVisitedPerRuleCheck Which rule start states have we visited while looking for a single left-recursion check? | |
| LeftRecursionDetector | back to summary |
|---|---|
| public LeftRecursionDetector(Grammar g, ATN atn) | |
| addRulesToCycle | back to summary |
|---|---|
| protected void addRulesToCycle(Rule enclosingRule, Rule targetRule) enclosingRule calls targetRule. Find the cycle containing the target and add the caller. Find the cycle containing the caller and add the target. If no cycles contain either, then create a new cycle. | |
| check | back to summary |
|---|---|
| public void check() | |
| check | back to summary |
|---|---|
| public boolean check(Rule enclosingRule, ATNState s, Set<ATNState> visitedStates) From state s, look for any transition to a rule that is currently being traced. When tracing r, visitedPerRuleCheck has r initially. If you reach a rule stop state, return but notify the invoking rule that the called rule is nullable. This implies that invoking rule must look at follow transition for that invoking state. The visitedStates tracks visited states within a single rule so we can avoid epsilon-loop-induced infinite recursion here. Keep filling the cycles in listOfRecursiveCycles and also, as a side-effect, set leftRecursiveRules. | |