From ebf5d969b2ba8767d4a35b36bf412eecda72504f Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 4 Sep 2015 17:35:37 +0200 Subject: [PATCH] s/alwaysAdvancesOnSuccess/alwaysConsumesOnSuccess/ Matches terminology change from the previous commit. --- lib/compiler/asts.js | 48 +++++++++---------- lib/compiler/passes/report-infinite-loops.js | 4 +- lib/compiler/passes/report-left-recursion.js | 2 +- .../passes/report-infinite-loops.spec.js | 2 +- .../passes/report-left-recursion.spec.js | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/compiler/asts.js b/lib/compiler/asts.js index aad50a6..fbca4fb 100644 --- a/lib/compiler/asts.js +++ b/lib/compiler/asts.js @@ -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); } }; diff --git a/lib/compiler/passes/report-infinite-loops.js b/lib/compiler/passes/report-infinite-loops.js index 7d23936..f4481f1 100644 --- a/lib/compiler/passes/report-infinite-loops.js +++ b/lib/compiler/passes/report-infinite-loops.js @@ -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); } } diff --git a/lib/compiler/passes/report-left-recursion.js b/lib/compiler/passes/report-left-recursion.js index 9745fce..252c172 100644 --- a/lib/compiler/passes/report-left-recursion.js +++ b/lib/compiler/passes/report-left-recursion.js @@ -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); }); }, diff --git a/spec/unit/compiler/passes/report-infinite-loops.spec.js b/spec/unit/compiler/passes/report-infinite-loops.spec.js index 42a8748..21f8e57 100644 --- a/spec/unit/compiler/passes/report-infinite-loops.spec.js +++ b/spec/unit/compiler/passes/report-infinite-loops.spec.js @@ -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" = ""' diff --git a/spec/unit/compiler/passes/report-left-recursion.spec.js b/spec/unit/compiler/passes/report-left-recursion.spec.js index 1c98c51..272af3a 100644 --- a/spec/unit/compiler/passes/report-left-recursion.spec.js +++ b/spec/unit/compiler/passes/report-left-recursion.spec.js @@ -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" = ""'