Updating NPM dependencies
This commit is contained in:
16
node_modules/@babel/parser/lib/tokenizer/context.js
generated
vendored
16
node_modules/@babel/parser/lib/tokenizer/context.js
generated
vendored
@@ -7,10 +7,12 @@ exports.types = exports.TokContext = void 0;
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
var _whitespace = require("../util/whitespace");
|
||||
|
||||
class TokContext {
|
||||
constructor(token, isExpr, preserveSpace, override) {
|
||||
this.token = void 0;
|
||||
this.isExpr = void 0;
|
||||
this.preserveSpace = void 0;
|
||||
this.override = void 0;
|
||||
this.token = token;
|
||||
this.isExpr = !!isExpr;
|
||||
this.preserveSpace = !!preserveSpace;
|
||||
@@ -23,6 +25,7 @@ exports.TokContext = TokContext;
|
||||
const types = {
|
||||
braceStatement: new TokContext("{", false),
|
||||
braceExpression: new TokContext("{", true),
|
||||
recordExpression: new TokContext("#{", true),
|
||||
templateQuasi: new TokContext("${", false),
|
||||
parenStatement: new TokContext("(", false),
|
||||
parenExpression: new TokContext("(", true),
|
||||
@@ -51,7 +54,7 @@ _types.types.name.updateContext = function (prevType) {
|
||||
let allowed = false;
|
||||
|
||||
if (prevType !== _types.types.dot) {
|
||||
if (this.state.value === "of" && !this.state.exprAllowed || this.state.value === "yield" && this.scope.inGenerator) {
|
||||
if (this.state.value === "of" && !this.state.exprAllowed && prevType !== _types.types._function && prevType !== _types.types._class) {
|
||||
allowed = true;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +85,7 @@ _types.types.parenL.updateContext = function (prevType) {
|
||||
_types.types.incDec.updateContext = function () {};
|
||||
|
||||
_types.types._function.updateContext = _types.types._class.updateContext = function (prevType) {
|
||||
if (prevType.beforeExpr && prevType !== _types.types.semi && prevType !== _types.types._else && !(prevType === _types.types._return && _whitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) && !((prevType === _types.types.colon || prevType === _types.types.braceL) && this.curContext() === types.b_stat)) {
|
||||
if (prevType.beforeExpr && prevType !== _types.types.semi && prevType !== _types.types._else && !(prevType === _types.types._return && this.hasPrecedingLineBreak()) && !((prevType === _types.types.colon || prevType === _types.types.braceL) && this.curContext() === types.b_stat)) {
|
||||
this.state.context.push(types.functionExpression);
|
||||
} else {
|
||||
this.state.context.push(types.functionStatement);
|
||||
@@ -99,4 +102,9 @@ _types.types.backQuote.updateContext = function () {
|
||||
}
|
||||
|
||||
this.state.exprAllowed = false;
|
||||
};
|
||||
|
||||
_types.types.braceHashL.updateContext = function () {
|
||||
this.state.context.push(types.recordExpression);
|
||||
this.state.exprAllowed = true;
|
||||
};
|
||||
268
node_modules/@babel/parser/lib/tokenizer/index.js
generated
vendored
268
node_modules/@babel/parser/lib/tokenizer/index.js
generated
vendored
@@ -13,9 +13,9 @@ var _types2 = require("./types");
|
||||
|
||||
var _context = require("./context");
|
||||
|
||||
var _location = _interopRequireDefault(require("../parser/location"));
|
||||
var _error = _interopRequireWildcard(require("../parser/error"));
|
||||
|
||||
var _location2 = require("../util/location");
|
||||
var _location = require("../util/location");
|
||||
|
||||
var _whitespace = require("../util/whitespace");
|
||||
|
||||
@@ -48,16 +48,17 @@ class Token {
|
||||
this.value = state.value;
|
||||
this.start = state.start;
|
||||
this.end = state.end;
|
||||
this.loc = new _location2.SourceLocation(state.startLoc, state.endLoc);
|
||||
this.loc = new _location.SourceLocation(state.startLoc, state.endLoc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.Token = Token;
|
||||
|
||||
class Tokenizer extends _location.default {
|
||||
class Tokenizer extends _error.default {
|
||||
constructor(options, input) {
|
||||
super();
|
||||
this.isLookahead = void 0;
|
||||
this.tokens = [];
|
||||
this.state = new _state.default();
|
||||
this.state.init(options);
|
||||
@@ -113,12 +114,15 @@ class Tokenizer extends _location.default {
|
||||
}
|
||||
|
||||
nextTokenStart() {
|
||||
const thisTokEnd = this.state.pos;
|
||||
_whitespace.skipWhiteSpace.lastIndex = thisTokEnd;
|
||||
return this.nextTokenStartSince(this.state.pos);
|
||||
}
|
||||
|
||||
nextTokenStartSince(pos) {
|
||||
_whitespace.skipWhiteSpace.lastIndex = pos;
|
||||
|
||||
const skip = _whitespace.skipWhiteSpace.exec(this.input);
|
||||
|
||||
return thisTokEnd + skip[0].length;
|
||||
return pos + skip[0].length;
|
||||
}
|
||||
|
||||
lookaheadCharCode() {
|
||||
@@ -144,9 +148,8 @@ class Tokenizer extends _location.default {
|
||||
|
||||
nextToken() {
|
||||
const curContext = this.curContext();
|
||||
if (!curContext || !curContext.preserveSpace) this.skipSpace();
|
||||
this.state.containsOctal = false;
|
||||
this.state.octalPosition = null;
|
||||
if (!curContext?.preserveSpace) this.skipSpace();
|
||||
this.state.octalPositions = [];
|
||||
this.state.start = this.state.pos;
|
||||
this.state.startLoc = this.state.curPosition();
|
||||
|
||||
@@ -155,8 +158,10 @@ class Tokenizer extends _location.default {
|
||||
return;
|
||||
}
|
||||
|
||||
if (curContext.override) {
|
||||
curContext.override(this);
|
||||
const override = curContext?.override;
|
||||
|
||||
if (override) {
|
||||
override(this);
|
||||
} else {
|
||||
this.getTokenFromCode(this.input.codePointAt(this.state.pos));
|
||||
}
|
||||
@@ -168,7 +173,7 @@ class Tokenizer extends _location.default {
|
||||
value: text,
|
||||
start: start,
|
||||
end: end,
|
||||
loc: new _location2.SourceLocation(startLoc, endLoc)
|
||||
loc: new _location.SourceLocation(startLoc, endLoc)
|
||||
};
|
||||
if (this.options.tokens) this.pushToken(comment);
|
||||
this.state.comments.push(comment);
|
||||
@@ -179,7 +184,7 @@ class Tokenizer extends _location.default {
|
||||
const startLoc = this.state.curPosition();
|
||||
const start = this.state.pos;
|
||||
const end = this.input.indexOf("*/", this.state.pos + 2);
|
||||
if (end === -1) throw this.raise(start, "Unterminated comment");
|
||||
if (end === -1) throw this.raise(start, _error.Errors.UnterminatedComment);
|
||||
this.state.pos = end + 2;
|
||||
_whitespace.lineBreakG.lastIndex = start;
|
||||
let match;
|
||||
@@ -277,13 +282,25 @@ class Tokenizer extends _location.default {
|
||||
const next = this.input.charCodeAt(nextPos);
|
||||
|
||||
if (next >= 48 && next <= 57) {
|
||||
throw this.raise(this.state.pos, "Unexpected digit after hash token");
|
||||
throw this.raise(this.state.pos, _error.Errors.UnexpectedDigitAfterHash);
|
||||
}
|
||||
|
||||
if (this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods") || this.getPluginOption("pipelineOperator", "proposal") === "smart") {
|
||||
this.finishOp(_types2.types.hash, 1);
|
||||
if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
|
||||
this.expectPlugin("recordAndTuple");
|
||||
|
||||
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
|
||||
throw this.raise(this.state.pos, next === 123 ? _error.Errors.RecordExpressionHashIncorrectStartSyntaxType : _error.Errors.TupleExpressionHashIncorrectStartSyntaxType);
|
||||
}
|
||||
|
||||
if (next === 123) {
|
||||
this.finishToken(_types2.types.braceHashL);
|
||||
} else {
|
||||
this.finishToken(_types2.types.bracketHashL);
|
||||
}
|
||||
|
||||
this.state.pos += 2;
|
||||
} else {
|
||||
throw this.raise(this.state.pos, "Unexpected character '#'");
|
||||
this.finishOp(_types2.types.hash, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,10 +339,10 @@ class Tokenizer extends _location.default {
|
||||
|
||||
readToken_interpreter() {
|
||||
if (this.state.pos !== 0 || this.length < 2) return false;
|
||||
let ch = this.input.charCodeAt(this.state.pos + 1);
|
||||
if (ch !== 33) return false;
|
||||
const start = this.state.pos;
|
||||
this.state.pos += 1;
|
||||
let ch = this.input.charCodeAt(this.state.pos);
|
||||
if (ch !== 33) return false;
|
||||
|
||||
while (!(0, _whitespace.isNewLine)(ch) && ++this.state.pos < this.length) {
|
||||
ch = this.input.charCodeAt(this.state.pos);
|
||||
@@ -374,6 +391,24 @@ class Tokenizer extends _location.default {
|
||||
this.finishOp(_types2.types.pipeline, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.hasPlugin("recordAndTuple") && next === 125) {
|
||||
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
||||
throw this.raise(this.state.pos, _error.Errors.RecordExpressionBarIncorrectEndSyntaxType);
|
||||
}
|
||||
|
||||
this.finishOp(_types2.types.braceBarR, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.hasPlugin("recordAndTuple") && next === 93) {
|
||||
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
||||
throw this.raise(this.state.pos, _error.Errors.TupleExpressionBarIncorrectEndSyntaxType);
|
||||
}
|
||||
|
||||
this.finishOp(_types2.types.bracketBarR, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (next === 61) {
|
||||
@@ -398,7 +433,7 @@ class Tokenizer extends _location.default {
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
|
||||
if (next === code) {
|
||||
if (next === 45 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 62 && (this.state.lastTokEnd === 0 || _whitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos)))) {
|
||||
if (next === 45 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 62 && (this.state.lastTokEnd === 0 || this.hasPrecedingLineBreak())) {
|
||||
this.skipLineComment(3);
|
||||
this.skipSpace();
|
||||
this.nextToken();
|
||||
@@ -467,7 +502,7 @@ class Tokenizer extends _location.default {
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
const next2 = this.input.charCodeAt(this.state.pos + 2);
|
||||
|
||||
if (next === 63 && !this.state.inType) {
|
||||
if (next === 63) {
|
||||
if (next2 === 61) {
|
||||
this.finishOp(_types2.types.assign, 3);
|
||||
} else {
|
||||
@@ -509,8 +544,18 @@ class Tokenizer extends _location.default {
|
||||
return;
|
||||
|
||||
case 91:
|
||||
++this.state.pos;
|
||||
this.finishToken(_types2.types.bracketL);
|
||||
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
||||
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
||||
throw this.raise(this.state.pos, _error.Errors.TupleExpressionBarIncorrectStartSyntaxType);
|
||||
}
|
||||
|
||||
this.finishToken(_types2.types.bracketBarL);
|
||||
this.state.pos += 2;
|
||||
} else {
|
||||
++this.state.pos;
|
||||
this.finishToken(_types2.types.bracketL);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
case 93:
|
||||
@@ -519,8 +564,18 @@ class Tokenizer extends _location.default {
|
||||
return;
|
||||
|
||||
case 123:
|
||||
++this.state.pos;
|
||||
this.finishToken(_types2.types.braceL);
|
||||
if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
|
||||
if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
|
||||
throw this.raise(this.state.pos, _error.Errors.RecordExpressionBarIncorrectStartSyntaxType);
|
||||
}
|
||||
|
||||
this.finishToken(_types2.types.braceBarL);
|
||||
this.state.pos += 2;
|
||||
} else {
|
||||
++this.state.pos;
|
||||
this.finishToken(_types2.types.braceL);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
case 125:
|
||||
@@ -642,7 +697,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
}
|
||||
|
||||
throw this.raise(this.state.pos, `Unexpected character '${String.fromCodePoint(code)}'`);
|
||||
throw this.raise(this.state.pos, _error.Errors.InvalidOrUnexpectedToken, String.fromCodePoint(code));
|
||||
}
|
||||
|
||||
finishOp(type, size) {
|
||||
@@ -657,13 +712,13 @@ class Tokenizer extends _location.default {
|
||||
|
||||
for (;;) {
|
||||
if (this.state.pos >= this.length) {
|
||||
throw this.raise(start, "Unterminated regular expression");
|
||||
throw this.raise(start, _error.Errors.UnterminatedRegExp);
|
||||
}
|
||||
|
||||
const ch = this.input.charAt(this.state.pos);
|
||||
|
||||
if (_whitespace.lineBreak.test(ch)) {
|
||||
throw this.raise(start, "Unterminated regular expression");
|
||||
throw this.raise(start, _error.Errors.UnterminatedRegExp);
|
||||
}
|
||||
|
||||
if (escaped) {
|
||||
@@ -693,10 +748,10 @@ class Tokenizer extends _location.default {
|
||||
|
||||
if (VALID_REGEX_FLAGS.has(char)) {
|
||||
if (mods.indexOf(char) > -1) {
|
||||
this.raise(this.state.pos + 1, "Duplicate regular expression flag");
|
||||
this.raise(this.state.pos + 1, _error.Errors.DuplicateRegExpFlags);
|
||||
}
|
||||
} else if ((0, _identifier.isIdentifierChar)(charCode) || charCode === 92) {
|
||||
this.raise(this.state.pos + 1, "Invalid regular expression flag");
|
||||
this.raise(this.state.pos + 1, _error.Errors.MalformedRegExpFlags);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -722,24 +777,22 @@ class Tokenizer extends _location.default {
|
||||
const code = this.input.charCodeAt(this.state.pos);
|
||||
let val;
|
||||
|
||||
if (this.hasPlugin("numericSeparator")) {
|
||||
if (code === 95) {
|
||||
const prev = this.input.charCodeAt(this.state.pos - 1);
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
if (code === 95) {
|
||||
const prev = this.input.charCodeAt(this.state.pos - 1);
|
||||
const next = this.input.charCodeAt(this.state.pos + 1);
|
||||
|
||||
if (allowedSiblings.indexOf(next) === -1) {
|
||||
this.raise(this.state.pos, "A numeric separator is only allowed between two digits");
|
||||
} else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
|
||||
this.raise(this.state.pos, "A numeric separator is only allowed between two digits");
|
||||
}
|
||||
|
||||
if (!allowNumSeparator) {
|
||||
this.raise(this.state.pos, "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences");
|
||||
}
|
||||
|
||||
++this.state.pos;
|
||||
continue;
|
||||
if (allowedSiblings.indexOf(next) === -1) {
|
||||
this.raise(this.state.pos, _error.Errors.UnexpectedNumericSeparator);
|
||||
} else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
|
||||
this.raise(this.state.pos, _error.Errors.UnexpectedNumericSeparator);
|
||||
}
|
||||
|
||||
if (!allowNumSeparator) {
|
||||
this.raise(this.state.pos, _error.Errors.NumericSeparatorInEscapeSequence);
|
||||
}
|
||||
|
||||
++this.state.pos;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code >= 97) {
|
||||
@@ -755,7 +808,7 @@ class Tokenizer extends _location.default {
|
||||
if (val >= radix) {
|
||||
if (this.options.errorRecovery && val <= 9) {
|
||||
val = 0;
|
||||
this.raise(this.state.start + i + 2, "Expected number in radix " + radix);
|
||||
this.raise(this.state.start + i + 2, _error.Errors.InvalidDigit, radix);
|
||||
} else if (forceLen) {
|
||||
val = 0;
|
||||
invalid = true;
|
||||
@@ -782,18 +835,20 @@ class Tokenizer extends _location.default {
|
||||
const val = this.readInt(radix);
|
||||
|
||||
if (val == null) {
|
||||
this.raise(this.state.start + 2, "Expected number in radix " + radix);
|
||||
this.raise(this.state.start + 2, _error.Errors.InvalidDigit, radix);
|
||||
}
|
||||
|
||||
if (this.hasPlugin("bigInt")) {
|
||||
if (this.input.charCodeAt(this.state.pos) === 110) {
|
||||
++this.state.pos;
|
||||
isBigInt = true;
|
||||
}
|
||||
const next = this.input.charCodeAt(this.state.pos);
|
||||
|
||||
if (next === 110) {
|
||||
++this.state.pos;
|
||||
isBigInt = true;
|
||||
} else if (next === 109) {
|
||||
throw this.raise(start, _error.Errors.InvalidDecimal);
|
||||
}
|
||||
|
||||
if ((0, _identifier.isIdentifierStart)(this.input.codePointAt(this.state.pos))) {
|
||||
throw this.raise(this.state.pos, "Identifier directly after number");
|
||||
throw this.raise(this.state.pos, _error.Errors.NumberIdentifier);
|
||||
}
|
||||
|
||||
if (isBigInt) {
|
||||
@@ -809,77 +864,94 @@ class Tokenizer extends _location.default {
|
||||
const start = this.state.pos;
|
||||
let isFloat = false;
|
||||
let isBigInt = false;
|
||||
let isNonOctalDecimalInt = false;
|
||||
let isDecimal = false;
|
||||
let hasExponent = false;
|
||||
let isOctal = false;
|
||||
|
||||
if (!startsWithDot && this.readInt(10) === null) {
|
||||
this.raise(start, "Invalid number");
|
||||
this.raise(start, _error.Errors.InvalidNumber);
|
||||
}
|
||||
|
||||
let octal = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
||||
const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
||||
|
||||
if (hasLeadingZero) {
|
||||
const integer = this.input.slice(start, this.state.pos);
|
||||
|
||||
if (octal) {
|
||||
if (this.state.strict) {
|
||||
this.raise(start, "Legacy octal literals are not allowed in strict mode");
|
||||
this.raise(start, _error.Errors.StrictOctalLiteral);
|
||||
} else {
|
||||
const underscorePos = integer.indexOf("_");
|
||||
|
||||
if (underscorePos > 0) {
|
||||
this.raise(underscorePos + start, _error.Errors.ZeroDigitNumericSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
if (/[89]/.test(this.input.slice(start, this.state.pos))) {
|
||||
octal = false;
|
||||
isNonOctalDecimalInt = true;
|
||||
}
|
||||
isOctal = hasLeadingZero && !/[89]/.test(integer);
|
||||
}
|
||||
|
||||
let next = this.input.charCodeAt(this.state.pos);
|
||||
|
||||
if (next === 46 && !octal) {
|
||||
if (next === 46 && !isOctal) {
|
||||
++this.state.pos;
|
||||
this.readInt(10);
|
||||
isFloat = true;
|
||||
next = this.input.charCodeAt(this.state.pos);
|
||||
}
|
||||
|
||||
if ((next === 69 || next === 101) && !octal) {
|
||||
if ((next === 69 || next === 101) && !isOctal) {
|
||||
next = this.input.charCodeAt(++this.state.pos);
|
||||
|
||||
if (next === 43 || next === 45) {
|
||||
++this.state.pos;
|
||||
}
|
||||
|
||||
if (this.readInt(10) === null) this.raise(start, "Invalid number");
|
||||
if (this.readInt(10) === null) {
|
||||
this.raise(start, _error.Errors.InvalidOrMissingExponent);
|
||||
}
|
||||
|
||||
isFloat = true;
|
||||
hasExponent = true;
|
||||
next = this.input.charCodeAt(this.state.pos);
|
||||
}
|
||||
|
||||
if (this.hasPlugin("numericSeparator") && (octal || isNonOctalDecimalInt)) {
|
||||
const underscorePos = this.input.slice(start, this.state.pos).indexOf("_");
|
||||
|
||||
if (underscorePos > 0) {
|
||||
this.raise(underscorePos + start, "Numeric separator can not be used after leading 0");
|
||||
if (next === 110) {
|
||||
if (isFloat || hasLeadingZero) {
|
||||
this.raise(start, _error.Errors.InvalidBigIntLiteral);
|
||||
}
|
||||
|
||||
++this.state.pos;
|
||||
isBigInt = true;
|
||||
}
|
||||
|
||||
if (this.hasPlugin("bigInt")) {
|
||||
if (next === 110) {
|
||||
if (isFloat || octal || isNonOctalDecimalInt) {
|
||||
this.raise(start, "Invalid BigIntLiteral");
|
||||
}
|
||||
if (next === 109) {
|
||||
this.expectPlugin("decimal", this.state.pos);
|
||||
|
||||
++this.state.pos;
|
||||
isBigInt = true;
|
||||
if (hasExponent || hasLeadingZero) {
|
||||
this.raise(start, _error.Errors.InvalidDecimal);
|
||||
}
|
||||
|
||||
++this.state.pos;
|
||||
isDecimal = true;
|
||||
}
|
||||
|
||||
if ((0, _identifier.isIdentifierStart)(this.input.codePointAt(this.state.pos))) {
|
||||
throw this.raise(this.state.pos, "Identifier directly after number");
|
||||
throw this.raise(this.state.pos, _error.Errors.NumberIdentifier);
|
||||
}
|
||||
|
||||
const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
|
||||
const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
|
||||
|
||||
if (isBigInt) {
|
||||
this.finishToken(_types2.types.bigint, str);
|
||||
return;
|
||||
}
|
||||
|
||||
const val = octal ? parseInt(str, 8) : parseFloat(str);
|
||||
if (isDecimal) {
|
||||
this.finishToken(_types2.types.decimal, str);
|
||||
return;
|
||||
}
|
||||
|
||||
const val = isOctal ? parseInt(str, 8) : parseFloat(str);
|
||||
this.finishToken(_types2.types.num, val);
|
||||
}
|
||||
|
||||
@@ -894,7 +966,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
if (code !== null && code > 0x10ffff) {
|
||||
if (throwOnInvalid) {
|
||||
this.raise(codePos, "Code point out of bounds");
|
||||
this.raise(codePos, _error.Errors.InvalidCodePoint);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -912,7 +984,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
for (;;) {
|
||||
if (this.state.pos >= this.length) {
|
||||
throw this.raise(this.state.start, "Unterminated string constant");
|
||||
throw this.raise(this.state.start, _error.Errors.UnterminatedString);
|
||||
}
|
||||
|
||||
const ch = this.input.charCodeAt(this.state.pos);
|
||||
@@ -927,7 +999,7 @@ class Tokenizer extends _location.default {
|
||||
++this.state.curLine;
|
||||
this.state.lineStart = this.state.pos;
|
||||
} else if ((0, _whitespace.isNewLine)(ch)) {
|
||||
throw this.raise(this.state.start, "Unterminated string constant");
|
||||
throw this.raise(this.state.start, _error.Errors.UnterminatedString);
|
||||
} else {
|
||||
++this.state.pos;
|
||||
}
|
||||
@@ -944,7 +1016,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
for (;;) {
|
||||
if (this.state.pos >= this.length) {
|
||||
throw this.raise(this.state.start, "Unterminated template");
|
||||
throw this.raise(this.state.start, _error.Errors.UnterminatedTemplate);
|
||||
}
|
||||
|
||||
const ch = this.input.charCodeAt(this.state.pos);
|
||||
@@ -1059,12 +1131,15 @@ class Tokenizer extends _location.default {
|
||||
case 57:
|
||||
if (inTemplate) {
|
||||
return null;
|
||||
} else if (this.state.strict) {
|
||||
this.raise(this.state.pos - 1, _error.Errors.StrictNumericEscape);
|
||||
}
|
||||
|
||||
default:
|
||||
if (ch >= 48 && ch <= 55) {
|
||||
const codePos = this.state.pos - 1;
|
||||
let octalStr = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/)[0];
|
||||
const match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
|
||||
let octalStr = match[0];
|
||||
let octal = parseInt(octalStr, 8);
|
||||
|
||||
if (octal > 255) {
|
||||
@@ -1079,10 +1154,9 @@ class Tokenizer extends _location.default {
|
||||
if (inTemplate) {
|
||||
return null;
|
||||
} else if (this.state.strict) {
|
||||
this.raise(codePos, "Octal literal in strict mode");
|
||||
} else if (!this.state.containsOctal) {
|
||||
this.state.containsOctal = true;
|
||||
this.state.octalPosition = codePos;
|
||||
this.raise(codePos, _error.Errors.StrictNumericEscape);
|
||||
} else {
|
||||
this.state.octalPositions.push(codePos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,7 +1173,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
if (n === null) {
|
||||
if (throwOnInvalid) {
|
||||
this.raise(codePos, "Bad character escape sequence");
|
||||
this.raise(codePos, _error.Errors.InvalidEscapeSequence);
|
||||
} else {
|
||||
this.state.pos = codePos - 1;
|
||||
}
|
||||
@@ -1128,7 +1202,7 @@ class Tokenizer extends _location.default {
|
||||
const identifierCheck = this.state.pos === start ? _identifier.isIdentifierStart : _identifier.isIdentifierChar;
|
||||
|
||||
if (this.input.charCodeAt(++this.state.pos) !== 117) {
|
||||
this.raise(this.state.pos, "Expecting Unicode escape sequence \\uXXXX");
|
||||
this.raise(this.state.pos, _error.Errors.MissingUnicodeEscape);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1211,7 @@ class Tokenizer extends _location.default {
|
||||
|
||||
if (esc !== null) {
|
||||
if (!identifierCheck(esc)) {
|
||||
this.raise(escStart, "Invalid Unicode escape");
|
||||
this.raise(escStart, _error.Errors.EscapedCharNotAnIdentifier);
|
||||
}
|
||||
|
||||
word += String.fromCodePoint(esc);
|
||||
@@ -1162,7 +1236,7 @@ class Tokenizer extends _location.default {
|
||||
const type = _types2.keywords.get(word) || _types2.types.name;
|
||||
|
||||
if (this.state.isIterator && (!this.isIterator(word) || !this.state.inType)) {
|
||||
this.raise(this.state.pos, `Invalid identifier ${word}`);
|
||||
this.raise(this.state.pos, _error.Errors.InvalidIdentifier, word);
|
||||
}
|
||||
|
||||
this.finishToken(type, word);
|
||||
@@ -1172,7 +1246,7 @@ class Tokenizer extends _location.default {
|
||||
const kw = this.state.type.keyword;
|
||||
|
||||
if (kw && this.state.containsEsc) {
|
||||
this.raise(this.state.start, `Escape sequence in keyword ${kw}`);
|
||||
this.raise(this.state.start, _error.Errors.InvalidEscapedReservedWord, kw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1188,7 +1262,7 @@ class Tokenizer extends _location.default {
|
||||
}
|
||||
|
||||
if (prevType === _types2.types._return || prevType === _types2.types.name && this.state.exprAllowed) {
|
||||
return _whitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
|
||||
return this.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
if (prevType === _types2.types._else || prevType === _types2.types.semi || prevType === _types2.types.eof || prevType === _types2.types.parenR || prevType === _types2.types.arrow) {
|
||||
|
||||
11
node_modules/@babel/parser/lib/tokenizer/state.js
generated
vendored
11
node_modules/@babel/parser/lib/tokenizer/state.js
generated
vendored
@@ -19,11 +19,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
||||
|
||||
class State {
|
||||
constructor() {
|
||||
this.strict = void 0;
|
||||
this.curLine = void 0;
|
||||
this.startLoc = void 0;
|
||||
this.endLoc = void 0;
|
||||
this.errors = [];
|
||||
this.potentialArrowAt = -1;
|
||||
this.noArrowAt = [];
|
||||
this.noArrowParamsConversionAt = [];
|
||||
this.inParameters = false;
|
||||
this.maybeInArrowParameters = false;
|
||||
this.inPipeline = false;
|
||||
this.inType = false;
|
||||
@@ -31,6 +34,7 @@ class State {
|
||||
this.inPropertyName = false;
|
||||
this.hasFlowComment = false;
|
||||
this.isIterator = false;
|
||||
this.isDeclareContext = false;
|
||||
this.topicContext = {
|
||||
maxNumOfResolvableTopics: 0,
|
||||
maxTopicIndex: null
|
||||
@@ -39,8 +43,6 @@ class State {
|
||||
this.inFSharpPipelineDirectBody = false;
|
||||
this.labels = [];
|
||||
this.decoratorStack = [[]];
|
||||
this.yieldPos = -1;
|
||||
this.awaitPos = -1;
|
||||
this.comments = [];
|
||||
this.trailingComments = [];
|
||||
this.leadingComments = [];
|
||||
@@ -59,8 +61,7 @@ class State {
|
||||
this.context = [_context.types.braceStatement];
|
||||
this.exprAllowed = true;
|
||||
this.containsEsc = false;
|
||||
this.containsOctal = false;
|
||||
this.octalPosition = null;
|
||||
this.octalPositions = [];
|
||||
this.exportedIdentifiers = [];
|
||||
this.tokensLength = 0;
|
||||
}
|
||||
|
||||
31
node_modules/@babel/parser/lib/tokenizer/types.js
generated
vendored
31
node_modules/@babel/parser/lib/tokenizer/types.js
generated
vendored
@@ -13,6 +13,17 @@ const postfix = true;
|
||||
|
||||
class TokenType {
|
||||
constructor(label, conf = {}) {
|
||||
this.label = void 0;
|
||||
this.keyword = void 0;
|
||||
this.beforeExpr = void 0;
|
||||
this.startsExpr = void 0;
|
||||
this.rightAssociative = void 0;
|
||||
this.isLoop = void 0;
|
||||
this.isAssign = void 0;
|
||||
this.prefix = void 0;
|
||||
this.postfix = void 0;
|
||||
this.binop = void 0;
|
||||
this.updateContext = void 0;
|
||||
this.label = label;
|
||||
this.keyword = conf.keyword;
|
||||
this.beforeExpr = !!conf.beforeExpr;
|
||||
@@ -53,6 +64,9 @@ const types = {
|
||||
bigint: new TokenType("bigint", {
|
||||
startsExpr
|
||||
}),
|
||||
decimal: new TokenType("decimal", {
|
||||
startsExpr
|
||||
}),
|
||||
regexp: new TokenType("regexp", {
|
||||
startsExpr
|
||||
}),
|
||||
@@ -67,7 +81,16 @@ const types = {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
}),
|
||||
bracketHashL: new TokenType("#[", {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
}),
|
||||
bracketBarL: new TokenType("[|", {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
}),
|
||||
bracketR: new TokenType("]"),
|
||||
bracketBarR: new TokenType("|]"),
|
||||
braceL: new TokenType("{", {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
@@ -76,6 +99,10 @@ const types = {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
}),
|
||||
braceHashL: new TokenType("#{", {
|
||||
beforeExpr,
|
||||
startsExpr
|
||||
}),
|
||||
braceR: new TokenType("}"),
|
||||
braceBarR: new TokenType("|}"),
|
||||
parenL: new TokenType("(", {
|
||||
@@ -163,7 +190,9 @@ const types = {
|
||||
binop: 10,
|
||||
startsExpr
|
||||
}),
|
||||
star: createBinop("*", 10),
|
||||
star: new TokenType("*", {
|
||||
binop: 10
|
||||
}),
|
||||
slash: createBinop("/", 10),
|
||||
exponent: new TokenType("**", {
|
||||
beforeExpr,
|
||||
|
||||
Reference in New Issue
Block a user