|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.tool.GrammarSanity
public class GrammarSanity
Factor out routines that check sanity of rules, alts, grammars, etc..
Field Summary | |
---|---|
protected Grammar |
grammar
|
protected java.util.Set<Rule> |
visitedDuringRecursionCheck
The checkForLeftRecursion method needs to track what rules it has visited to track infinite recursion. |
Constructor Summary | |
---|---|
GrammarSanity(Grammar grammar)
|
Method Summary | |
---|---|
protected void |
addRulesToCycle(Rule targetRule,
Rule enclosingRule,
java.util.List<java.util.Set<Rule>> listOfRecursiveCycles)
enclosingRuleName calls targetRuleName, find the cycle containing the target and add the caller. |
java.util.List<java.util.Set<Rule>> |
checkAllRulesForLeftRecursion()
Check all rules for infinite left recursion before analysis. |
void |
checkRuleReference(GrammarAST scopeAST,
GrammarAST refAST,
GrammarAST argsAST,
java.lang.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(GrammarAST t)
|
protected boolean |
traceStatesLookingForLeftRecursion(NFAState s,
java.util.Set visitedStates,
java.util.List<java.util.Set<Rule>> listOfRecursiveCycles)
From state s, look for any transition to a rule that is currently being traced. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Set<Rule> visitedDuringRecursionCheck
protected Grammar grammar
Constructor Detail |
---|
public GrammarSanity(Grammar grammar)
Method Detail |
---|
public java.util.List<java.util.Set<Rule>> checkAllRulesForLeftRecursion()
protected boolean traceStatesLookingForLeftRecursion(NFAState s, java.util.Set visitedStates, java.util.List<java.util.Set<Rule>> listOfRecursiveCycles)
protected void addRulesToCycle(Rule targetRule, Rule enclosingRule, java.util.List<java.util.Set<Rule>> listOfRecursiveCycles)
public void checkRuleReference(GrammarAST scopeAST, GrammarAST refAST, GrammarAST argsAST, java.lang.String currentRuleName)
public void ensureAltIsSimpleNodeOrTree(GrammarAST altAST, GrammarAST elementAST, int outerAltNum)
protected boolean isValidSimpleElementNode(GrammarAST t)
protected boolean isNextNonActionElementEOA(GrammarAST t)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |