s/head/first/ & s/tail/rest/ in a testcase

Makes the testcase in sync with example grammars.
redux
David Majda 11 years ago
parent d9354c4632
commit 11aab6374f

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

Loading…
Cancel
Save