diff --git a/lib/parser.js b/lib/parser.js index 0f7ed5f..a5f23c1 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -281,7 +281,7 @@ module.exports = (function() { }, peg$c111 = "\\u", peg$c112 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, - peg$c113 = function(eol) { return eol; }, + peg$c113 = function(eol) { return ""; }, peg$c114 = /^[0-9]/, peg$c115 = { type: "class", value: "[0-9]", description: "[0-9]" }, peg$c116 = /^[0-9a-fA-F]/, diff --git a/spec/parser.spec.js b/spec/parser.spec.js index e6d4193..f5f651b 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -392,7 +392,7 @@ describe("PEG.js grammar parser", function() { expect('start = "\\0"' ).toParseAs(literalGrammar("\x00")); expect('start = "\\xFF"' ).toParseAs(literalGrammar("\xFF")); expect('start = "\\uFFFF"').toParseAs(literalGrammar("\uFFFF")); - expect('start = "\\\n"' ).toParseAs(literalGrammar("\n")); + expect('start = "\\\n"' ).toParseAs(literalGrammar("")); }); /* Canonical simpleDoubleQuotedCharacter is "a". */ @@ -418,7 +418,7 @@ describe("PEG.js grammar parser", function() { expect("start = '\\0'" ).toParseAs(literalGrammar("\x00")); expect("start = '\\xFF'" ).toParseAs(literalGrammar("\xFF")); expect("start = '\\uFFFF'").toParseAs(literalGrammar("\uFFFF")); - expect("start = '\\\n'" ).toParseAs(literalGrammar("\n")); + expect("start = '\\\n'" ).toParseAs(literalGrammar("")); }); /* Canonical simpleSingleQuotedCharacter is "a". */ @@ -471,7 +471,7 @@ describe("PEG.js grammar parser", function() { expect('start = [\\0]' ).toParseAs(classGrammar(["\x00"], "[\\0]")); expect('start = [\\xFF]' ).toParseAs(classGrammar(["\xFF"], "[\\xFF]")); expect('start = [\\uFFFF]').toParseAs(classGrammar(["\uFFFF"], "[\\uFFFF]")); - expect('start = [\\\n]' ).toParseAs(classGrammar(["\n"], "[\\\n]")); + expect('start = [\\\n]' ).toParseAs(classGrammar([""], "[\\\n]")); }); /* Canonical simpleBracketDelimiedCharacter is "a". */ @@ -518,11 +518,7 @@ describe("PEG.js grammar parser", function() { /* Canonical eolEscapeSequence is "\\\n". */ it("parses eolEscapeSequence", function() { - expect('start = "\\\n"' ).toParseAs(literalGrammar("\n")); - expect('start = "\\\r\n"' ).toParseAs(literalGrammar("\r\n")); - expect('start = "\\\r"' ).toParseAs(literalGrammar("\r")); - expect('start = "\\\u2028"').toParseAs(literalGrammar("\u2028")); - expect('start = "\\\u2029"').toParseAs(literalGrammar("\u2029")); + expect('start = "\\\n"' ).toParseAs(literalGrammar("")); }); /* Trivial character class rules are not tested. */ diff --git a/src/parser.pegjs b/src/parser.pegjs index 58927d0..2b9fc22 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -308,7 +308,7 @@ unicodeEscapeSequence } eolEscapeSequence - = "\\" eol:eol { return eol; } + = "\\" eol:eol { return ""; } digit = [0-9]