summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js')
-rw-r--r--tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js52
1 files changed, 0 insertions, 52 deletions
diff --git a/tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js
index e4a68bf24e..ebb0aa21b1 100644
--- a/tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js
+++ b/tools/node_modules/eslint/node_modules/@babel/helper-string-parser/lib/index.js
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
exports.readCodePoint = readCodePoint;
exports.readInt = readInt;
exports.readStringContents = readStringContents;
-
var _isDigit = function isDigit(code) {
return code >= 48 && code <= 57;
};
-
const forbiddenNumericSeparatorSiblings = {
decBinOct: new Set([46, 66, 69, 79, 95, 98, 101, 111]),
hex: new Set([46, 88, 95, 120])
@@ -21,7 +19,6 @@ const isAllowedNumericSeparatorSibling = {
dec: ch => ch >= 48 && ch <= 57,
hex: ch => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
};
-
function readStringContents(type, input, pos, lineStart, curLine, errors) {
const initialPos = pos;
const initialLineStart = lineStart;
@@ -32,25 +29,20 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
const {
length
} = input;
-
for (;;) {
if (pos >= length) {
errors.unterminated(initialPos, initialLineStart, initialCurLine);
out += input.slice(chunkStart, pos);
break;
}
-
const ch = input.charCodeAt(pos);
-
if (isStringEnd(type, ch, input, pos)) {
out += input.slice(chunkStart, pos);
break;
}
-
if (ch === 92) {
out += input.slice(chunkStart, pos);
const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
-
if (res.ch === null && !firstInvalidLoc) {
firstInvalidLoc = {
pos,
@@ -60,7 +52,6 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
} else {
out += res.ch;
}
-
({
pos,
lineStart,
@@ -75,11 +66,9 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
if (type === "template") {
out += input.slice(chunkStart, pos) + "\n";
++pos;
-
if (ch === 13 && input.charCodeAt(pos) === 10) {
++pos;
}
-
++curLine;
chunkStart = lineStart = pos;
} else {
@@ -89,7 +78,6 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
++pos;
}
}
-
return {
pos,
str: out,
@@ -99,35 +87,27 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
containsInvalid: !!firstInvalidLoc
};
}
-
function isStringEnd(type, ch, input, pos) {
if (type === "template") {
return ch === 96 || ch === 36 && input.charCodeAt(pos + 1) === 123;
}
-
return ch === (type === "double" ? 34 : 39);
}
-
function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
const throwOnInvalid = !inTemplate;
pos++;
-
const res = ch => ({
pos,
ch,
lineStart,
curLine
});
-
const ch = input.charCodeAt(pos++);
-
switch (ch) {
case 110:
return res("\n");
-
case 114:
return res("\r");
-
case 120:
{
let code;
@@ -137,7 +117,6 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
} = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
return res(code === null ? null : String.fromCharCode(code));
}
-
case 117:
{
let code;
@@ -147,32 +126,24 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
} = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
return res(code === null ? null : String.fromCodePoint(code));
}
-
case 116:
return res("\t");
-
case 98:
return res("\b");
-
case 118:
return res("\u000b");
-
case 102:
return res("\f");
-
case 13:
if (input.charCodeAt(pos) === 10) {
++pos;
}
-
case 10:
lineStart = pos;
++curLine;
-
case 8232:
case 8233:
return res("");
-
case 56:
case 57:
if (inTemplate) {
@@ -180,22 +151,18 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
} else {
errors.strictNumericEscape(pos - 1, lineStart, curLine);
}
-
default:
if (ch >= 48 && ch <= 55) {
const startPos = pos - 1;
const match = input.slice(startPos, pos + 2).match(/^[0-7]+/);
let octalStr = match[0];
let octal = parseInt(octalStr, 8);
-
if (octal > 255) {
octalStr = octalStr.slice(0, -1);
octal = parseInt(octalStr, 8);
}
-
pos += octalStr.length - 1;
const next = input.charCodeAt(pos);
-
if (octalStr !== "0" || next === 56 || next === 57) {
if (inTemplate) {
return res(null);
@@ -203,14 +170,11 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
errors.strictNumericEscape(startPos, lineStart, curLine);
}
}
-
return res(String.fromCharCode(octal));
}
-
return res(String.fromCharCode(ch));
}
}
-
function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
const initialPos = pos;
let n;
@@ -218,7 +182,6 @@ function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInval
n,
pos
} = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
-
if (n === null) {
if (throwOnInvalid) {
errors.invalidEscapeSequence(initialPos, lineStart, curLine);
@@ -226,28 +189,23 @@ function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInval
pos = initialPos - 1;
}
}
-
return {
code: n,
pos
};
}
-
function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
const start = pos;
const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
let invalid = false;
let total = 0;
-
for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
const code = input.charCodeAt(pos);
let val;
-
if (code === 95 && allowNumSeparator !== "bail") {
const prev = input.charCodeAt(pos - 1);
const next = input.charCodeAt(pos + 1);
-
if (!allowNumSeparator) {
if (bailOnError) return {
n: null,
@@ -261,11 +219,9 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
};
errors.unexpectedNumericSeparator(pos, lineStart, curLine);
}
-
++pos;
continue;
}
-
if (code >= 97) {
val = code - 97 + 10;
} else if (code >= 65) {
@@ -275,7 +231,6 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
} else {
val = Infinity;
}
-
if (val >= radix) {
if (val <= 9 && bailOnError) {
return {
@@ -291,28 +246,23 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
break;
}
}
-
++pos;
total = total * radix + val;
}
-
if (pos === start || len != null && pos - start !== len || invalid) {
return {
n: null,
pos
};
}
-
return {
n: total,
pos
};
}
-
function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
const ch = input.charCodeAt(pos);
let code;
-
if (ch === 123) {
++pos;
({
@@ -320,7 +270,6 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
pos
} = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
++pos;
-
if (code !== null && code > 0x10ffff) {
if (throwOnInvalid) {
errors.invalidCodePoint(pos, lineStart, curLine);
@@ -337,7 +286,6 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
pos
} = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
}
-
return {
code,
pos