|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|