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({
|
var check = visitor.build({
|
||||||
rule: function(node, appliedRules) {
|
rule: function(node, visitedRules) {
|
||||||
check(node.expression, appliedRules.concat(node.name));
|
check(node.expression, visitedRules.concat(node.name));
|
||||||
},
|
},
|
||||||
|
|
||||||
sequence: function(node, appliedRules) {
|
sequence: function(node, visitedRules) {
|
||||||
arrays.every(node.elements, function(element) {
|
arrays.every(node.elements, function(element) {
|
||||||
if (element.type === "rule_ref") {
|
if (element.type === "rule_ref") {
|
||||||
check(element, appliedRules);
|
check(element, visitedRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matchesEmpty(element);
|
return matchesEmpty(element);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
rule_ref: function(node, appliedRules) {
|
rule_ref: function(node, visitedRules) {
|
||||||
if (arrays.contains(appliedRules, node.name)) {
|
if (arrays.contains(visitedRules, node.name)) {
|
||||||
throw new GrammarError(
|
throw new GrammarError(
|
||||||
"Left recursion detected for rule \"" + node.name + "\"."
|
"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