feat: enable numericSeparator parsing support (#11863)
This commit is contained in:
parent
ccd98f042c
commit
0e985fb287
@ -1016,7 +1016,6 @@ export default class Tokenizer extends ParserErrors {
|
|||||||
const code = this.input.charCodeAt(this.state.pos);
|
const code = this.input.charCodeAt(this.state.pos);
|
||||||
let val;
|
let val;
|
||||||
|
|
||||||
if (this.hasPlugin("numericSeparator")) {
|
|
||||||
if (code === charCodes.underscore) {
|
if (code === charCodes.underscore) {
|
||||||
const prev = this.input.charCodeAt(this.state.pos - 1);
|
const prev = this.input.charCodeAt(this.state.pos - 1);
|
||||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||||
@ -1038,7 +1037,6 @@ export default class Tokenizer extends ParserErrors {
|
|||||||
++this.state.pos;
|
++this.state.pos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (code >= charCodes.lowercaseA) {
|
if (code >= charCodes.lowercaseA) {
|
||||||
val = code - charCodes.lowercaseA + charCodes.lineFeed;
|
val = code - charCodes.lowercaseA + charCodes.lineFeed;
|
||||||
@ -1088,10 +1086,6 @@ export default class Tokenizer extends ParserErrors {
|
|||||||
}
|
}
|
||||||
const next = this.input.charCodeAt(this.state.pos);
|
const next = this.input.charCodeAt(this.state.pos);
|
||||||
|
|
||||||
if (next === charCodes.underscore) {
|
|
||||||
this.expectPlugin("numericSeparator", this.state.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next === charCodes.lowercaseN) {
|
if (next === charCodes.lowercaseN) {
|
||||||
++this.state.pos;
|
++this.state.pos;
|
||||||
isBigInt = true;
|
isBigInt = true;
|
||||||
@ -1133,7 +1127,7 @@ export default class Tokenizer extends ParserErrors {
|
|||||||
const integer = this.input.slice(start, this.state.pos);
|
const integer = this.input.slice(start, this.state.pos);
|
||||||
if (this.state.strict) {
|
if (this.state.strict) {
|
||||||
this.raise(start, Errors.StrictOctalLiteral);
|
this.raise(start, Errors.StrictOctalLiteral);
|
||||||
} else if (this.hasPlugin("numericSeparator")) {
|
} else {
|
||||||
// disallow numeric separators in non octal decimals and legacy octal likes
|
// disallow numeric separators in non octal decimals and legacy octal likes
|
||||||
const underscorePos = integer.indexOf("_");
|
const underscorePos = integer.indexOf("_");
|
||||||
if (underscorePos > 0) {
|
if (underscorePos > 0) {
|
||||||
@ -1165,10 +1159,6 @@ export default class Tokenizer extends ParserErrors {
|
|||||||
next = this.input.charCodeAt(this.state.pos);
|
next = this.input.charCodeAt(this.state.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next === charCodes.underscore) {
|
|
||||||
this.expectPlugin("numericSeparator", this.state.pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next === charCodes.lowercaseN) {
|
if (next === charCodes.lowercaseN) {
|
||||||
// disallow floats, legacy octal syntax and non octal decimals
|
// disallow floats, legacy octal syntax and non octal decimals
|
||||||
// new style octal ("0o") is handled in this.readRadixNumber
|
// new style octal ("0o") is handled in this.readRadixNumber
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user