refactor: remove unused invalidTemplateEscapePosition tokenizer state (#10935)
* refactor: remove unused invalidTemplateEscapePosition tokenizer state * fix flow error
This commit is contained in:
parent
30449fe05d
commit
2f3f77926d
@ -1430,13 +1430,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
const elem = this.startNode();
|
const elem = this.startNode();
|
||||||
if (this.state.value === null) {
|
if (this.state.value === null) {
|
||||||
if (!isTagged) {
|
if (!isTagged) {
|
||||||
// TODO: fix this
|
this.raise(this.state.start + 1, "Invalid escape sequence in template");
|
||||||
this.raise(
|
|
||||||
this.state.invalidTemplateEscapePosition || 0,
|
|
||||||
"Invalid escape sequence in template",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.state.invalidTemplateEscapePosition = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elem.value = {
|
elem.value = {
|
||||||
|
|||||||
@ -1122,14 +1122,10 @@ export default class Tokenizer extends LocationParser {
|
|||||||
throwOnInvalid,
|
throwOnInvalid,
|
||||||
);
|
);
|
||||||
++this.state.pos;
|
++this.state.pos;
|
||||||
if (code === null) {
|
if (code !== null && code > 0x10ffff) {
|
||||||
// $FlowFixMe (is this always non-null?)
|
|
||||||
--this.state.invalidTemplateEscapePosition; // to point to the '\'' instead of the 'u'
|
|
||||||
} else if (code > 0x10ffff) {
|
|
||||||
if (throwOnInvalid) {
|
if (throwOnInvalid) {
|
||||||
this.raise(codePos, "Code point out of bounds");
|
this.raise(codePos, "Code point out of bounds");
|
||||||
} else {
|
} else {
|
||||||
this.state.invalidTemplateEscapePosition = codePos - 2;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1274,9 +1270,6 @@ export default class Tokenizer extends LocationParser {
|
|||||||
case charCodes.digit8:
|
case charCodes.digit8:
|
||||||
case charCodes.digit9:
|
case charCodes.digit9:
|
||||||
if (inTemplate) {
|
if (inTemplate) {
|
||||||
const codePos = this.state.pos - 1;
|
|
||||||
|
|
||||||
this.state.invalidTemplateEscapePosition = codePos;
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1299,7 +1292,6 @@ export default class Tokenizer extends LocationParser {
|
|||||||
next === charCodes.digit9
|
next === charCodes.digit9
|
||||||
) {
|
) {
|
||||||
if (inTemplate) {
|
if (inTemplate) {
|
||||||
this.state.invalidTemplateEscapePosition = codePos;
|
|
||||||
return null;
|
return null;
|
||||||
} else if (this.state.strict) {
|
} else if (this.state.strict) {
|
||||||
this.raise(codePos, "Octal literal in strict mode");
|
this.raise(codePos, "Octal literal in strict mode");
|
||||||
@ -1332,7 +1324,6 @@ export default class Tokenizer extends LocationParser {
|
|||||||
this.raise(codePos, "Bad character escape sequence");
|
this.raise(codePos, "Bad character escape sequence");
|
||||||
} else {
|
} else {
|
||||||
this.state.pos = codePos - 1;
|
this.state.pos = codePos - 1;
|
||||||
this.state.invalidTemplateEscapePosition = codePos - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
|||||||
@ -156,8 +156,6 @@ export default class State {
|
|||||||
// `export default foo;` and `export { foo as default };`.
|
// `export default foo;` and `export { foo as default };`.
|
||||||
exportedIdentifiers: Array<string> = [];
|
exportedIdentifiers: Array<string> = [];
|
||||||
|
|
||||||
invalidTemplateEscapePosition: ?number = null;
|
|
||||||
|
|
||||||
curPosition(): Position {
|
curPosition(): Position {
|
||||||
return new Position(this.curLine, this.pos - this.lineStart);
|
return new Position(this.curLine, this.pos - this.lineStart);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user