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;', ' }',