public class GrammarSanity extends Object
Modifier and Type | Field | Description |
---|---|---|
protected Grammar |
grammar |
|
protected Set<Rule> |
visitedDuringRecursionCheck |
The checkForLeftRecursion method needs to track what rules it has
visited to track infinite recursion.
|
Constructor | Description |
---|---|
GrammarSanity(Grammar grammar) |
Modifier and Type | Method | Description |
---|---|---|
protected void |
addRulesToCycle(Rule targetRule,
Rule enclosingRule,
List<Set<Rule>> listOfRecursiveCycles) |
enclosingRuleName calls targetRuleName, find the cycle containing
the target and add the caller.
|
List<Set<Rule>> |
checkAllRulesForLeftRecursion() |
Check all rules for infinite left recursion before analysis.
|
void |
checkRuleReference(GrammarAST scopeAST,
GrammarAST refAST,
GrammarAST argsAST,
String currentRuleName) |
|
void |
ensureAltIsSimpleNodeOrTree(GrammarAST altAST,
GrammarAST elementAST,
int outerAltNum) |
Rules in tree grammar that use -> rewrites and are spitting out
templates via output=template and then use rewrite=true must only
use -> on alts that are simple nodes or trees or single rule refs
that match either nodes or trees.
|
protected boolean |
isNextNonActionElementEOA(GrammarAST t) |
|
protected boolean |
isValidSimpleElementNode(org.antlr.runtime.tree.Tree t) |
|
protected boolean |
traceStatesLookingForLeftRecursion(NFAState s,
Set<NFAState> visitedStates,
List<Set<Rule>> listOfRecursiveCycles) |
From state s, look for any transition to a rule that is currently
being traced.
|
protected Set<Rule> visitedDuringRecursionCheck
protected Grammar grammar
public GrammarSanity(Grammar grammar)
public List<Set<Rule>> checkAllRulesForLeftRecursion()
protected boolean traceStatesLookingForLeftRecursion(NFAState s, Set<NFAState> visitedStates, List<Set<Rule>> listOfRecursiveCycles)
protected void addRulesToCycle(Rule targetRule, Rule enclosingRule, List<Set<Rule>> listOfRecursiveCycles)
public void checkRuleReference(GrammarAST scopeAST, GrammarAST refAST, GrammarAST argsAST, String currentRuleName)
public void ensureAltIsSimpleNodeOrTree(GrammarAST altAST, GrammarAST elementAST, int outerAltNum)
protected boolean isValidSimpleElementNode(org.antlr.runtime.tree.Tree t)
protected boolean isNextNonActionElementEOA(GrammarAST t)
Copyright © 1992–2019 ANTLR. All rights reserved.