s/alwaysAdvancesOnSuccess/alwaysConsumesOnSuccess/

Matches terminology change from the previous commit.
redux
David Majda 9 years ago
parent 6ff005786c
commit ebf5d969b2

@ -13,51 +13,51 @@ var asts = {
return arrays.indexOf(ast.rules, function(r) { return r.name === name; });
},
alwaysAdvancesOnSuccess: function(ast, node) {
function advancesTrue() { return true; }
function advancesFalse() { return false; }
alwaysConsumesOnSuccess: function(ast, node) {
function consumesTrue() { return true; }
function consumesFalse() { return false; }
function advancesExpression(node) {
return advances(node.expression);
function consumesExpression(node) {
return consumes(node.expression);
}
var advances = visitor.build({
rule: advancesExpression,
named: advancesExpression,
var consumes = visitor.build({
rule: consumesExpression,
named: consumesExpression,
choice: function(node) {
return arrays.every(node.alternatives, advances);
return arrays.every(node.alternatives, consumes);
},
action: advancesExpression,
action: consumesExpression,
sequence: function(node) {
return arrays.some(node.elements, advances);
return arrays.some(node.elements, consumes);
},
labeled: advancesExpression,
text: advancesExpression,
simple_and: advancesFalse,
simple_not: advancesFalse,
optional: advancesFalse,
zero_or_more: advancesFalse,
one_or_more: advancesExpression,
semantic_and: advancesFalse,
semantic_not: advancesFalse,
labeled: consumesExpression,
text: consumesExpression,
simple_and: consumesFalse,
simple_not: consumesFalse,
optional: consumesFalse,
zero_or_more: consumesFalse,
one_or_more: consumesExpression,
semantic_and: consumesFalse,
semantic_not: consumesFalse,
rule_ref: function(node) {
return advances(asts.findRule(ast, node.name));
return consumes(asts.findRule(ast, node.name));
},
literal: function(node) {
return node.value !== "";
},
"class": advancesTrue,
any: advancesTrue
"class": consumesTrue,
any: consumesTrue
});
return advances(node);
return consumes(node);
}
};

@ -11,13 +11,13 @@ var GrammarError = require("../../grammar-error"),
function reportInfiniteLoops(ast) {
var check = visitor.build({
zero_or_more: function(node) {
if (!asts.alwaysAdvancesOnSuccess(ast, node.expression)) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError("Infinite loop detected.", node.location);
}
},
one_or_more: function(node) {
if (!asts.alwaysAdvancesOnSuccess(ast, node.expression)) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError("Infinite loop detected.", node.location);
}
}

@ -31,7 +31,7 @@ function reportLeftRecursion(ast) {
arrays.every(node.elements, function(element) {
check(element);
return !asts.alwaysAdvancesOnSuccess(ast, element);
return !asts.alwaysConsumesOnSuccess(ast, element);
});
},

@ -26,7 +26,7 @@ describe("compiler pass |reportInfiniteLoops|", function() {
});
});
it("computes expressions that always advance on success correctly", function() {
it("computes expressions that always consume input on success correctly", function() {
expect(pass).toReportError([
'start = a*',
'a "a" = ""'

@ -45,7 +45,7 @@ describe("compiler pass |reportLeftRecursion|", function() {
expect(pass).toReportError('start = "" start?');
});
it("computes expressions that always advance on success correctly", function() {
it("computes expressions that always consume input on success correctly", function() {
expect(pass).toReportError([
'start = a start',
'a "a" = ""'

Loading…
Cancel
Save