From f0657ba628c4a8d658462521fbd6b8314df4ea95 Mon Sep 17 00:00:00 2001 From: David Majda Date: Thu, 1 Sep 2016 15:31:26 +0200 Subject: [PATCH] generated-parser-behavior.spec.js: Switch from first/rest to head/tail Follow-up to these commits: e510ecc3d01103b61b504128cee5341dd8c4e005 a4a66a2e5be41832bcf23127a37515d155b700bc --- spec/behavior/generated-parser-behavior.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/behavior/generated-parser-behavior.spec.js b/spec/behavior/generated-parser-behavior.spec.js index fc746b4..8a0107b 100644 --- a/spec/behavior/generated-parser-behavior.spec.js +++ b/spec/behavior/generated-parser-behavior.spec.js @@ -1495,17 +1495,17 @@ describe("generated parser behavior", function() { */ var parser = peg.generate([ 'Expr = Sum', - 'Sum = first:Product rest:(("+" / "-") Product)* {', - ' return rest.reduce(function(result, element) {', + 'Sum = head:Product tail:(("+" / "-") Product)* {', + ' return tail.reduce(function(result, element) {', ' if (element[0] === "+") { return result + element[1]; }', ' if (element[0] === "-") { return result - element[1]; }', - ' }, first);', + ' }, head);', ' }', - 'Product = first:Value rest:(("*" / "/") Value)* {', - ' return rest.reduce(function(result, element) {', + 'Product = head:Value tail:(("*" / "/") Value)* {', + ' return tail.reduce(function(result, element) {', ' if (element[0] === "*") { return result * element[1]; }', ' if (element[0] === "/") { return result / element[1]; }', - ' }, first);', + ' }, head);', ' }', 'Value = digits:[0-9]+ { return parseInt(digits.join(""), 10); }', ' / "(" expr:Expr ")" { return expr; }'