From 11aab6374f3c78d9fad68c874742983c3f4cf71b Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 27 Apr 2014 13:44:25 +0200 Subject: [PATCH] s/head/first/ & s/tail/rest/ in a testcase Makes the testcase in sync with example grammars. --- spec/generated-parser.spec.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/generated-parser.spec.js b/spec/generated-parser.spec.js index 13c8e5b..71cca65 100644 --- a/spec/generated-parser.spec.js +++ b/spec/generated-parser.spec.js @@ -1115,19 +1115,19 @@ describe("generated parser", function() { */ var parser = PEG.buildParser([ 'Expr = Sum', - 'Sum = head:Product tail:(("+" / "-") Product)* {', - ' var result = head, i;', - ' for (i = 0; i < tail.length; i++) {', - ' if (tail[i][0] == "+") { result += tail[i][1]; }', - ' if (tail[i][0] == "-") { result -= tail[i][1]; }', + 'Sum = first:Product rest:(("+" / "-") Product)* {', + ' var result = first, i;', + ' for (i = 0; i < rest.length; i++) {', + ' if (rest[i][0] == "+") { result += rest[i][1]; }', + ' if (rest[i][0] == "-") { result -= rest[i][1]; }', ' }', ' return result;', ' }', - 'Product = head:Value tail:(("*" / "/") Value)* {', - ' var result = head, i;', - ' for (i = 0; i < tail.length; i++) {', - ' if (tail[i][0] == "*") { result *= tail[i][1]; }', - ' if (tail[i][0] == "/") { result /= tail[i][1]; }', + 'Product = first:Value rest:(("*" / "/") Value)* {', + ' var result = first, i;', + ' for (i = 0; i < rest.length; i++) {', + ' if (rest[i][0] == "*") { result *= rest[i][1]; }', + ' if (rest[i][0] == "/") { result /= rest[i][1]; }', ' }', ' return result;', ' }',