s/appliedRules/visitedRules/
The rules are not really *applied* by the |reportLeftRecursion| pass, they are just *visited*.
This commit is contained in:
parent
25ed2b7ee2
commit
03a391e874
|
@ -59,28 +59,28 @@ function reportLeftRecursion(ast) {
|
|||
});
|
||||
|
||||
var check = visitor.build({
|
||||
rule: function(node, appliedRules) {
|
||||
check(node.expression, appliedRules.concat(node.name));
|
||||
rule: function(node, visitedRules) {
|
||||
check(node.expression, visitedRules.concat(node.name));
|
||||
},
|
||||
|
||||
sequence: function(node, appliedRules) {
|
||||
sequence: function(node, visitedRules) {
|
||||
arrays.every(node.elements, function(element) {
|
||||
if (element.type === "rule_ref") {
|
||||
check(element, appliedRules);
|
||||
check(element, visitedRules);
|
||||
}
|
||||
|
||||
return matchesEmpty(element);
|
||||
});
|
||||
},
|
||||
|
||||
rule_ref: function(node, appliedRules) {
|
||||
if (arrays.contains(appliedRules, node.name)) {
|
||||
rule_ref: function(node, visitedRules) {
|
||||
if (arrays.contains(visitedRules, node.name)) {
|
||||
throw new GrammarError(
|
||||
"Left recursion detected for rule \"" + node.name + "\"."
|
||||
);
|
||||
}
|
||||
|
||||
check(asts.findRule(ast, node.name), appliedRules);
|
||||
check(asts.findRule(ast, node.name), visitedRules);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue