Standardize on 3 spaces before // comments

redux
David Majda 10 years ago
parent f3a83788aa
commit d9354c4632

@ -273,9 +273,9 @@ module.exports = function(ast) {
rule: function(node) { rule: function(node) {
node.bytecode = generate(node.expression, { node.bytecode = generate(node.expression, {
sp: -1, // stack pointer sp: -1, // stack pointer
env: { }, // mapping of label names to stack positions env: { }, // mapping of label names to stack positions
action: null // action nodes pass themselves to children here action: null // action nodes pass themselves to children here
}); });
}, },

@ -172,99 +172,99 @@ module.exports = function(ast, options) {
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.PUSH_CURR_POS + ':', // PUSH_CURR_POS ' case ' + op.PUSH_CURR_POS + ':', // PUSH_CURR_POS
' stack.push(peg$currPos);', ' stack.push(peg$currPos);',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.POP + ':', // POP ' case ' + op.POP + ':', // POP
' stack.pop();', ' stack.pop();',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.POP_CURR_POS + ':', // POP_CURR_POS ' case ' + op.POP_CURR_POS + ':', // POP_CURR_POS
' peg$currPos = stack.pop();', ' peg$currPos = stack.pop();',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.POP_N + ':', // POP_N n ' case ' + op.POP_N + ':', // POP_N n
' stack.length -= bc[ip + 1];', ' stack.length -= bc[ip + 1];',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.NIP + ':', // NIP ' case ' + op.NIP + ':', // NIP
' stack.splice(-2, 1);', ' stack.splice(-2, 1);',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.APPEND + ':', // APPEND ' case ' + op.APPEND + ':', // APPEND
' stack[stack.length - 2].push(stack.pop());', ' stack[stack.length - 2].push(stack.pop());',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.WRAP + ':', // WRAP n ' case ' + op.WRAP + ':', // WRAP n
' stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));', ' stack.push(stack.splice(stack.length - bc[ip + 1], bc[ip + 1]));',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.TEXT + ':', // TEXT ' case ' + op.TEXT + ':', // TEXT
' stack.pop();', ' stack.pop();',
' stack.push(input.substring(stack[stack.length - 1], peg$currPos));', ' stack.push(input.substring(stack[stack.length - 1], peg$currPos));',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.IF + ':', // IF t, f ' case ' + op.IF + ':', // IF t, f
indent10(generateCondition('stack[stack.length - 1]', 0)), indent10(generateCondition('stack[stack.length - 1]', 0)),
'', '',
' case ' + op.IF_ERROR + ':', // IF_ERROR t, f ' case ' + op.IF_ERROR + ':', // IF_ERROR t, f
indent10(generateCondition( indent10(generateCondition(
'stack[stack.length - 1] === peg$FAILED', 'stack[stack.length - 1] === peg$FAILED',
0 0
)), )),
'', '',
' case ' + op.IF_NOT_ERROR + ':', // IF_NOT_ERROR t, f ' case ' + op.IF_NOT_ERROR + ':', // IF_NOT_ERROR t, f
indent10( indent10(
generateCondition('stack[stack.length - 1] !== peg$FAILED', generateCondition('stack[stack.length - 1] !== peg$FAILED',
0 0
)), )),
'', '',
' case ' + op.WHILE_NOT_ERROR + ':', // WHILE_NOT_ERROR b ' case ' + op.WHILE_NOT_ERROR + ':', // WHILE_NOT_ERROR b
indent10(generateLoop('stack[stack.length - 1] !== peg$FAILED')), indent10(generateLoop('stack[stack.length - 1] !== peg$FAILED')),
'', '',
' case ' + op.MATCH_ANY + ':', // MATCH_ANY a, f, ... ' case ' + op.MATCH_ANY + ':', // MATCH_ANY a, f, ...
indent10(generateCondition('input.length > peg$currPos', 0)), indent10(generateCondition('input.length > peg$currPos', 0)),
'', '',
' case ' + op.MATCH_STRING + ':', // MATCH_STRING s, a, f, ... ' case ' + op.MATCH_STRING + ':', // MATCH_STRING s, a, f, ...
indent10(generateCondition( indent10(generateCondition(
'input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]', 'input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]',
1 1
)), )),
'', '',
' case ' + op.MATCH_STRING_IC + ':', // MATCH_STRING_IC s, a, f, ... ' case ' + op.MATCH_STRING_IC + ':', // MATCH_STRING_IC s, a, f, ...
indent10(generateCondition( indent10(generateCondition(
'input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]', 'input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]',
1 1
)), )),
'', '',
' case ' + op.MATCH_REGEXP + ':', // MATCH_REGEXP r, a, f, ... ' case ' + op.MATCH_REGEXP + ':', // MATCH_REGEXP r, a, f, ...
indent10(generateCondition( indent10(generateCondition(
'peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))', 'peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))',
1 1
)), )),
'', '',
' case ' + op.ACCEPT_N + ':', // ACCEPT_N n ' case ' + op.ACCEPT_N + ':', // ACCEPT_N n
' stack.push(input.substr(peg$currPos, bc[ip + 1]));', ' stack.push(input.substr(peg$currPos, bc[ip + 1]));',
' peg$currPos += bc[ip + 1];', ' peg$currPos += bc[ip + 1];',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.ACCEPT_STRING + ':', // ACCEPT_STRING s ' case ' + op.ACCEPT_STRING + ':', // ACCEPT_STRING s
' stack.push(peg$consts[bc[ip + 1]]);', ' stack.push(peg$consts[bc[ip + 1]]);',
' peg$currPos += peg$consts[bc[ip + 1]].length;', ' peg$currPos += peg$consts[bc[ip + 1]].length;',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.FAIL + ':', // FAIL e ' case ' + op.FAIL + ':', // FAIL e
' stack.push(peg$FAILED);', ' stack.push(peg$FAILED);',
' if (peg$silentFails === 0) {', ' if (peg$silentFails === 0) {',
' peg$fail(peg$consts[bc[ip + 1]]);', ' peg$fail(peg$consts[bc[ip + 1]]);',
@ -272,30 +272,30 @@ module.exports = function(ast, options) {
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.REPORT_SAVED_POS + ':', // REPORT_SAVED_POS p ' case ' + op.REPORT_SAVED_POS + ':', // REPORT_SAVED_POS p
' peg$reportedPos = stack[stack.length - 1 - bc[ip + 1]];', ' peg$reportedPos = stack[stack.length - 1 - bc[ip + 1]];',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.REPORT_CURR_POS + ':', // REPORT_CURR_POS ' case ' + op.REPORT_CURR_POS + ':', // REPORT_CURR_POS
' peg$reportedPos = peg$currPos;', ' peg$reportedPos = peg$currPos;',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.CALL + ':', // CALL f, n, pc, p1, p2, ..., pN ' case ' + op.CALL + ':', // CALL f, n, pc, p1, p2, ..., pN
indent10(generateCall()), indent10(generateCall()),
'', '',
' case ' + op.RULE + ':', // RULE r ' case ' + op.RULE + ':', // RULE r
' stack.push(peg$parseRule(bc[ip + 1]));', ' stack.push(peg$parseRule(bc[ip + 1]));',
' ip += 2;', ' ip += 2;',
' break;', ' break;',
'', '',
' case ' + op.SILENT_FAILS_ON + ':', // SILENT_FAILS_ON ' case ' + op.SILENT_FAILS_ON + ':', // SILENT_FAILS_ON
' peg$silentFails++;', ' peg$silentFails++;',
' ip++;', ' ip++;',
' break;', ' break;',
'', '',
' case ' + op.SILENT_FAILS_OFF + ':', // SILENT_FAILS_OFF ' case ' + op.SILENT_FAILS_OFF + ':', // SILENT_FAILS_OFF
' peg$silentFails--;', ' peg$silentFails--;',
' ip++;', ' ip++;',
' break;', ' break;',
@ -445,7 +445,7 @@ module.exports = function(ast, options) {
while (ip < end) { while (ip < end) {
switch (bc[ip]) { switch (bc[ip]) {
case op.PUSH: // PUSH c case op.PUSH: // PUSH c
/* /*
* Hack: One of the constants can be an empty array. It needs to be * Hack: One of the constants can be an empty array. It needs to be
* handled specially because it can be modified later on the stack * handled specially because it can be modified later on the stack
@ -457,47 +457,47 @@ module.exports = function(ast, options) {
ip += 2; ip += 2;
break; break;
case op.PUSH_CURR_POS: // PUSH_CURR_POS case op.PUSH_CURR_POS: // PUSH_CURR_POS
parts.push(stack.push('peg$currPos')); parts.push(stack.push('peg$currPos'));
ip++; ip++;
break; break;
case op.POP: // POP case op.POP: // POP
stack.pop(); stack.pop();
ip++; ip++;
break; break;
case op.POP_CURR_POS: // POP_CURR_POS case op.POP_CURR_POS: // POP_CURR_POS
parts.push('peg$currPos = ' + stack.pop() + ';'); parts.push('peg$currPos = ' + stack.pop() + ';');
ip++; ip++;
break; break;
case op.POP_N: // POP_N n case op.POP_N: // POP_N n
stack.pop(bc[ip + 1]); stack.pop(bc[ip + 1]);
ip += 2; ip += 2;
break; break;
case op.NIP: // NIP case op.NIP: // NIP
value = stack.pop(); value = stack.pop();
stack.pop(); stack.pop();
parts.push(stack.push(value)); parts.push(stack.push(value));
ip++; ip++;
break; break;
case op.APPEND: // APPEND case op.APPEND: // APPEND
value = stack.pop(); value = stack.pop();
parts.push(stack.top() + '.push(' + value + ');'); parts.push(stack.top() + '.push(' + value + ');');
ip++; ip++;
break; break;
case op.WRAP: // WRAP n case op.WRAP: // WRAP n
parts.push( parts.push(
stack.push('[' + stack.pop(bc[ip + 1]).join(', ') + ']') stack.push('[' + stack.pop(bc[ip + 1]).join(', ') + ']')
); );
ip += 2; ip += 2;
break; break;
case op.TEXT: // TEXT case op.TEXT: // TEXT
stack.pop(); stack.pop();
parts.push( parts.push(
stack.push('input.substring(' + stack.top() + ', peg$currPos)') stack.push('input.substring(' + stack.top() + ', peg$currPos)')
@ -505,27 +505,27 @@ module.exports = function(ast, options) {
ip++; ip++;
break; break;
case op.IF: // IF t, f case op.IF: // IF t, f
compileCondition(stack.top(), 0); compileCondition(stack.top(), 0);
break; break;
case op.IF_ERROR: // IF_ERROR t, f case op.IF_ERROR: // IF_ERROR t, f
compileCondition(stack.top() + ' === peg$FAILED', 0); compileCondition(stack.top() + ' === peg$FAILED', 0);
break; break;
case op.IF_NOT_ERROR: // IF_NOT_ERROR t, f case op.IF_NOT_ERROR: // IF_NOT_ERROR t, f
compileCondition(stack.top() + ' !== peg$FAILED', 0); compileCondition(stack.top() + ' !== peg$FAILED', 0);
break; break;
case op.WHILE_NOT_ERROR: // WHILE_NOT_ERROR b case op.WHILE_NOT_ERROR: // WHILE_NOT_ERROR b
compileLoop(stack.top() + ' !== peg$FAILED', 0); compileLoop(stack.top() + ' !== peg$FAILED', 0);
break; break;
case op.MATCH_ANY: // MATCH_ANY a, f, ... case op.MATCH_ANY: // MATCH_ANY a, f, ...
compileCondition('input.length > peg$currPos', 0); compileCondition('input.length > peg$currPos', 0);
break; break;
case op.MATCH_STRING: // MATCH_STRING s, a, f, ... case op.MATCH_STRING: // MATCH_STRING s, a, f, ...
compileCondition( compileCondition(
eval(ast.consts[bc[ip + 1]]).length > 1 eval(ast.consts[bc[ip + 1]]).length > 1
? 'input.substr(peg$currPos, ' ? 'input.substr(peg$currPos, '
@ -538,7 +538,7 @@ module.exports = function(ast, options) {
); );
break; break;
case op.MATCH_STRING_IC: // MATCH_STRING_IC s, a, f, ... case op.MATCH_STRING_IC: // MATCH_STRING_IC s, a, f, ...
compileCondition( compileCondition(
'input.substr(peg$currPos, ' 'input.substr(peg$currPos, '
+ eval(ast.consts[bc[ip + 1]]).length + eval(ast.consts[bc[ip + 1]]).length
@ -548,14 +548,14 @@ module.exports = function(ast, options) {
); );
break; break;
case op.MATCH_REGEXP: // MATCH_REGEXP r, a, f, ... case op.MATCH_REGEXP: // MATCH_REGEXP r, a, f, ...
compileCondition( compileCondition(
c(bc[ip + 1]) + '.test(input.charAt(peg$currPos))', c(bc[ip + 1]) + '.test(input.charAt(peg$currPos))',
1 1
); );
break; break;
case op.ACCEPT_N: // ACCEPT_N n case op.ACCEPT_N: // ACCEPT_N n
parts.push(stack.push( parts.push(stack.push(
bc[ip + 1] > 1 bc[ip + 1] > 1
? 'input.substr(peg$currPos, ' + bc[ip + 1] + ')' ? 'input.substr(peg$currPos, ' + bc[ip + 1] + ')'
@ -569,7 +569,7 @@ module.exports = function(ast, options) {
ip += 2; ip += 2;
break; break;
case op.ACCEPT_STRING: // ACCEPT_STRING s case op.ACCEPT_STRING: // ACCEPT_STRING s
parts.push(stack.push(c(bc[ip + 1]))); parts.push(stack.push(c(bc[ip + 1])));
parts.push( parts.push(
eval(ast.consts[bc[ip + 1]]).length > 1 eval(ast.consts[bc[ip + 1]]).length > 1
@ -579,37 +579,37 @@ module.exports = function(ast, options) {
ip += 2; ip += 2;
break; break;
case op.FAIL: // FAIL e case op.FAIL: // FAIL e
parts.push(stack.push('peg$FAILED')); parts.push(stack.push('peg$FAILED'));
parts.push('if (peg$silentFails === 0) { peg$fail(' + c(bc[ip + 1]) + '); }'); parts.push('if (peg$silentFails === 0) { peg$fail(' + c(bc[ip + 1]) + '); }');
ip += 2; ip += 2;
break; break;
case op.REPORT_SAVED_POS: // REPORT_SAVED_POS p case op.REPORT_SAVED_POS: // REPORT_SAVED_POS p
parts.push('peg$reportedPos = ' + stack.index(bc[ip + 1]) + ';'); parts.push('peg$reportedPos = ' + stack.index(bc[ip + 1]) + ';');
ip += 2; ip += 2;
break; break;
case op.REPORT_CURR_POS: // REPORT_CURR_POS case op.REPORT_CURR_POS: // REPORT_CURR_POS
parts.push('peg$reportedPos = peg$currPos;'); parts.push('peg$reportedPos = peg$currPos;');
ip++; ip++;
break; break;
case op.CALL: // CALL f, n, pc, p1, p2, ..., pN case op.CALL: // CALL f, n, pc, p1, p2, ..., pN
compileCall(); compileCall();
break; break;
case op.RULE: // RULE r case op.RULE: // RULE r
parts.push(stack.push("peg$parse" + ast.rules[bc[ip + 1]].name + "()")); parts.push(stack.push("peg$parse" + ast.rules[bc[ip + 1]].name + "()"));
ip += 2; ip += 2;
break; break;
case op.SILENT_FAILS_ON: // SILENT_FAILS_ON case op.SILENT_FAILS_ON: // SILENT_FAILS_ON
parts.push('peg$silentFails++;'); parts.push('peg$silentFails++;');
ip++; ip++;
break; break;
case op.SILENT_FAILS_OFF: // SILENT_FAILS_OFF case op.SILENT_FAILS_OFF: // SILENT_FAILS_OFF
parts.push('peg$silentFails--;'); parts.push('peg$silentFails--;');
ip++; ip++;
break; break;
@ -730,7 +730,7 @@ module.exports = function(ast, options) {
' peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },', ' peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },',
' peg$maxFailPos = 0,', ' peg$maxFailPos = 0,',
' peg$maxFailExpected = [],', ' peg$maxFailExpected = [],',
' peg$silentFails = 0,', // 0 = report failures, > 0 = silence failures ' peg$silentFails = 0,', // 0 = report failures, > 0 = silence failures
'' ''
].join('\n')); ].join('\n'));
@ -882,13 +882,13 @@ module.exports = function(ast, options) {
* not like the first and IE the second. * not like the first and IE the second.
*/ */
' return s', ' return s',
' .replace(/\\\\/g, \'\\\\\\\\\')', // backslash ' .replace(/\\\\/g, \'\\\\\\\\\')', // backslash
' .replace(/"/g, \'\\\\"\')', // closing double quote ' .replace(/"/g, \'\\\\"\')', // closing double quote
' .replace(/\\x08/g, \'\\\\b\')', // backspace ' .replace(/\\x08/g, \'\\\\b\')', // backspace
' .replace(/\\t/g, \'\\\\t\')', // horizontal tab ' .replace(/\\t/g, \'\\\\t\')', // horizontal tab
' .replace(/\\n/g, \'\\\\n\')', // line feed ' .replace(/\\n/g, \'\\\\n\')', // line feed
' .replace(/\\f/g, \'\\\\f\')', // form feed ' .replace(/\\f/g, \'\\\\f\')', // form feed
' .replace(/\\r/g, \'\\\\r\')', // carriage return ' .replace(/\\r/g, \'\\\\r\')', // carriage return
' .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return \'\\\\x0\' + hex(ch); })', ' .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return \'\\\\x0\' + hex(ch); })',
' .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return \'\\\\x\' + hex(ch); })', ' .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return \'\\\\x\' + hex(ch); })',
' .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return \'\\\\u0\' + hex(ch); })', ' .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return \'\\\\u0\' + hex(ch); })',

@ -175,13 +175,13 @@ var utils = {
* not like the first and IE the second. * not like the first and IE the second.
*/ */
return '"' + s return '"' + s
.replace(/\\/g, '\\\\') // backslash .replace(/\\/g, '\\\\') // backslash
.replace(/"/g, '\\"') // closing quote character .replace(/"/g, '\\"') // closing quote character
.replace(/\x08/g, '\\b') // backspace .replace(/\x08/g, '\\b') // backspace
.replace(/\t/g, '\\t') // horizontal tab .replace(/\t/g, '\\t') // horizontal tab
.replace(/\n/g, '\\n') // line feed .replace(/\n/g, '\\n') // line feed
.replace(/\f/g, '\\f') // form feed .replace(/\f/g, '\\f') // form feed
.replace(/\r/g, '\\r') // carriage return .replace(/\r/g, '\\r') // carriage return
.replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, utils.escape) .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, utils.escape)
+ '"'; + '"';
}, },
@ -197,17 +197,17 @@ var utils = {
* For portability, we also escape all control and non-ASCII characters. * For portability, we also escape all control and non-ASCII characters.
*/ */
return s return s
.replace(/\\/g, '\\\\') // backslash .replace(/\\/g, '\\\\') // backslash
.replace(/\//g, '\\/') // closing slash .replace(/\//g, '\\/') // closing slash
.replace(/\]/g, '\\]') // closing bracket .replace(/\]/g, '\\]') // closing bracket
.replace(/\^/g, '\\^') // caret .replace(/\^/g, '\\^') // caret
.replace(/-/g, '\\-') // dash .replace(/-/g, '\\-') // dash
.replace(/\0/g, '\\0') // null .replace(/\0/g, '\\0') // null
.replace(/\t/g, '\\t') // horizontal tab .replace(/\t/g, '\\t') // horizontal tab
.replace(/\n/g, '\\n') // line feed .replace(/\n/g, '\\n') // line feed
.replace(/\v/g, '\\x0B') // vertical tab .replace(/\v/g, '\\x0B') // vertical tab
.replace(/\f/g, '\\f') // form feed .replace(/\f/g, '\\f') // form feed
.replace(/\r/g, '\\r') // carriage return .replace(/\r/g, '\\r') // carriage return
.replace(/[\x01-\x08\x0E-\x1F\x80-\uFFFF]/g, utils.escape); .replace(/[\x01-\x08\x0E-\x1F\x80-\uFFFF]/g, utils.escape);
}, },

@ -323,13 +323,13 @@ describe("generated parser", function() {
expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]); expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]);
/* Non-Unix newlines */ /* Non-Unix newlines */
expect(parser).toParse("1\rx", [2, 1]); // Old Mac expect(parser).toParse("1\rx", [2, 1]); // Old Mac
expect(parser).toParse("1\r\nx", [2, 1]); // Windows expect(parser).toParse("1\r\nx", [2, 1]); // Windows
expect(parser).toParse("1\n\rx", [3, 1]); // mismatched expect(parser).toParse("1\n\rx", [3, 1]); // mismatched
/* Strange newlines */ /* Strange newlines */
expect(parser).toParse("1\u2028x", [2, 1]); // line separator expect(parser).toParse("1\u2028x", [2, 1]); // line separator
expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator
}); });
it("can use variables defined in the initializer", function() { it("can use variables defined in the initializer", function() {
@ -528,13 +528,13 @@ describe("generated parser", function() {
expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]); expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]);
/* Non-Unix newlines */ /* Non-Unix newlines */
expect(parser).toParse("1\rx", [2, 1]); // Old Mac expect(parser).toParse("1\rx", [2, 1]); // Old Mac
expect(parser).toParse("1\r\nx", [2, 1]); // Windows expect(parser).toParse("1\r\nx", [2, 1]); // Windows
expect(parser).toParse("1\n\rx", [3, 1]); // mismatched expect(parser).toParse("1\n\rx", [3, 1]); // mismatched
/* Strange newlines */ /* Strange newlines */
expect(parser).toParse("1\u2028x", [2, 1]); // line separator expect(parser).toParse("1\u2028x", [2, 1]); // line separator
expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator
}); });
it("can use variables defined in the initializer", function() { it("can use variables defined in the initializer", function() {
@ -628,13 +628,13 @@ describe("generated parser", function() {
expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]); expect(parser).toParse("1\n2\n\n3\n\n\n4 5 x", [7, 5]);
/* Non-Unix newlines */ /* Non-Unix newlines */
expect(parser).toParse("1\rx", [2, 1]); // Old Mac expect(parser).toParse("1\rx", [2, 1]); // Old Mac
expect(parser).toParse("1\r\nx", [2, 1]); // Windows expect(parser).toParse("1\r\nx", [2, 1]); // Windows
expect(parser).toParse("1\n\rx", [3, 1]); // mismatched expect(parser).toParse("1\n\rx", [3, 1]); // mismatched
/* Strange newlines */ /* Strange newlines */
expect(parser).toParse("1\u2028x", [2, 1]); // line separator expect(parser).toParse("1\u2028x", [2, 1]); // line separator
expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator expect(parser).toParse("1\u2029x", [2, 1]); // paragraph separator
}); });
it("can use variables defined in the initializer", function() { it("can use variables defined in the initializer", function() {

Loading…
Cancel
Save