/** 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.
*/
protected void addRulesToCycle(Rule enclosingRule, Rule targetRule) {
//System.err.println("left-recursion to "+targetRule.name+" from "+enclosingRule.name);
boolean foundCycle = false;
for (Set<Rule> rulesInCycle : listOfRecursiveCycles) {
// ensure both rules are in same cycle
if (rulesInCycle.contains(targetRule)) {
rulesInCycle.add(enclosingRule);
foundCycle = true;
}
if (rulesInCycle.contains(enclosingRule)) {
rulesInCycle.add(targetRule);
foundCycle = true;
}
}
if ( !foundCycle ) {
Set<Rule> cycle = new OrderedHashSet<Rule>();
cycle.add(targetRule);
cycle.add(enclosingRule);
listOfRecursiveCycles.add(cycle);
}
}
LeftRecursionDetector.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:codebuff
作者:
评论列表
文章目录