generated-parser-behavior.spec.js: Switch from first/rest to head/tail

Follow-up to these commits:

  e510ecc3d0
  a4a66a2e5b
redux
David Majda 8 years ago
parent 0d48ffca2b
commit f0657ba628

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

Loading…
Cancel
Save