Subsume json (#7985)
* Add Subsume JSON transform https://github.com/tc39/proposal-json-superset is at stage 3. This allows U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR to appear unescaped inside strings and directives. * Move to Stage 3 * Break diretive parsing * Update README * Handle multi-escape sequences * Remove babylon files after rename
This commit is contained in:
@@ -1069,6 +1069,7 @@ export default class Tokenizer extends LocationParser {
|
||||
readString(quote: number): void {
|
||||
let out = "",
|
||||
chunkStart = ++this.state.pos;
|
||||
const hasJsonStrings = this.hasPlugin("jsonStrings");
|
||||
for (;;) {
|
||||
if (this.state.pos >= this.input.length) {
|
||||
this.raise(this.state.start, "Unterminated string constant");
|
||||
@@ -1080,10 +1081,14 @@ export default class Tokenizer extends LocationParser {
|
||||
// $FlowFixMe
|
||||
out += this.readEscapedChar(false);
|
||||
chunkStart = this.state.pos;
|
||||
} else if (
|
||||
hasJsonStrings &&
|
||||
(ch === charCodes.lineSeparator || ch === charCodes.paragraphSeparator)
|
||||
) {
|
||||
++this.state.pos;
|
||||
} else if (isNewLine(ch)) {
|
||||
this.raise(this.state.start, "Unterminated string constant");
|
||||
} else {
|
||||
if (isNewLine(ch)) {
|
||||
this.raise(this.state.start, "Unterminated string constant");
|
||||
}
|
||||
++this.state.pos;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user