Fix line continuation with Unicode line terminators (#9403)

This commit is contained in:
Daniel Tschinder 2019-01-28 13:35:35 -08:00 committed by GitHub
parent 1452e977a0
commit 828169e611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View File

@ -1213,6 +1213,8 @@ export default class Tokenizer extends LocationParser {
case charCodes.lineFeed:
this.state.lineStart = this.state.pos;
++this.state.curLine;
case charCodes.lineSeparator:
case charCodes.paragraphSeparator:
return "";
default:
if (ch >= charCodes.digit0 && ch <= charCodes.digit7) {
@ -1242,6 +1244,7 @@ export default class Tokenizer extends LocationParser {
this.state.pos += octalStr.length - 1;
return String.fromCharCode(octal);
}
return String.fromCharCode(ch);
}
}

View File

@ -1,3 +1,3 @@
`\n\r\b\v\t\f\
\
`
\\`

View File

@ -1,7 +1,7 @@
{
"type": "File",
"start": 0,
"end": 18,
"end": 22,
"loc": {
"start": {
"line": 1,
@ -9,13 +9,13 @@
},
"end": {
"line": 3,
"column": 1
"column": 5
}
},
"program": {
"type": "Program",
"start": 0,
"end": 18,
"end": 22,
"loc": {
"start": {
"line": 1,
@ -23,7 +23,7 @@
},
"end": {
"line": 3,
"column": 1
"column": 5
}
},
"sourceType": "script",
@ -32,7 +32,7 @@
{
"type": "ExpressionStatement",
"start": 0,
"end": 18,
"end": 22,
"loc": {
"start": {
"line": 1,
@ -40,13 +40,13 @@
},
"end": {
"line": 3,
"column": 1
"column": 5
}
},
"expression": {
"type": "TemplateLiteral",
"start": 0,
"end": 18,
"end": 22,
"loc": {
"start": {
"line": 1,
@ -54,7 +54,7 @@
},
"end": {
"line": 3,
"column": 1
"column": 5
}
},
"expressions": [],
@ -62,7 +62,7 @@
{
"type": "TemplateElement",
"start": 1,
"end": 17,
"end": 21,
"loc": {
"start": {
"line": 1,
@ -70,11 +70,11 @@
},
"end": {
"line": 3,
"column": 0
"column": 4
}
},
"value": {
"raw": "\\n\\r\\b\\v\\t\\f\\\n\\\n",
"raw": "\\n\\r\\b\\v\\t\\f\\\n\\\n\\\u2028\\\u2029",
"cooked": "\n\r\b\u000b\t\f"
},
"tail": true