json-p3 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/json-p3.cjs.js +1299 -88
- package/dist/json-p3.esm.js +1299 -88
- package/dist/json-p3.iife.js +1299 -88
- package/dist/json-p3.iife.min.js +1 -1
- package/dist/json-p3.iife.min.js.map +1 -1
- package/dist/path/errors.d.ts +7 -0
- package/dist/path/functions/index.d.ts +2 -0
- package/dist/path/functions/match.d.ts +13 -4
- package/dist/path/functions/pattern.d.ts +1 -0
- package/dist/path/functions/search.d.ts +10 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
package/dist/json-p3.iife.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* json-p3 version 1.3.
|
|
2
|
+
* json-p3 version 1.3.2
|
|
3
3
|
* https://github.com/jg-rp/json-p3
|
|
4
4
|
*
|
|
5
5
|
* MIT License
|
|
@@ -139,6 +139,18 @@ var json_p3 = (function (exports) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Error thrown due to invalid I-Regexp syntax.
|
|
144
|
+
*/
|
|
145
|
+
class IRegexpError extends Error {
|
|
146
|
+
constructor(message) {
|
|
147
|
+
super(message);
|
|
148
|
+
this.message = message;
|
|
149
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
150
|
+
this.name = "IRegexpError";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
142
154
|
/**
|
|
143
155
|
* Common types and type predicates.
|
|
144
156
|
*/
|
|
@@ -1083,6 +1095,1255 @@ var json_p3 = (function (exports) {
|
|
|
1083
1095
|
}
|
|
1084
1096
|
}
|
|
1085
1097
|
|
|
1098
|
+
// See https://datatracker.ietf.org/doc/html/rfc9485#name-ecmascript-regexps
|
|
1099
|
+
function mapRegexp(pattern) {
|
|
1100
|
+
let escaped = false;
|
|
1101
|
+
let charClass = false;
|
|
1102
|
+
const parts = [];
|
|
1103
|
+
for (const ch of pattern) {
|
|
1104
|
+
if (escaped) {
|
|
1105
|
+
parts.push(ch);
|
|
1106
|
+
escaped = false;
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
switch (ch) {
|
|
1110
|
+
case ".":
|
|
1111
|
+
if (!charClass) {
|
|
1112
|
+
parts.push("(?:(?![\r\n])\\P{Cs}|\\p{Cs}\\p{Cs})");
|
|
1113
|
+
} else {
|
|
1114
|
+
parts.push(ch);
|
|
1115
|
+
}
|
|
1116
|
+
break;
|
|
1117
|
+
case "\\":
|
|
1118
|
+
escaped = true;
|
|
1119
|
+
parts.push(ch);
|
|
1120
|
+
break;
|
|
1121
|
+
case "[":
|
|
1122
|
+
charClass = true;
|
|
1123
|
+
parts.push(ch);
|
|
1124
|
+
break;
|
|
1125
|
+
case "]":
|
|
1126
|
+
charClass = false;
|
|
1127
|
+
parts.push(ch);
|
|
1128
|
+
break;
|
|
1129
|
+
default:
|
|
1130
|
+
parts.push(ch);
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
return parts.join("");
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/*
|
|
1138
|
+
* iregexp-check version 0.1.1
|
|
1139
|
+
* https://github.com/jg-rp/js-iregexp
|
|
1140
|
+
*
|
|
1141
|
+
* MIT License
|
|
1142
|
+
*
|
|
1143
|
+
* Copyright (c) 2024 James Prior
|
|
1144
|
+
*
|
|
1145
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1146
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
1147
|
+
* in the Software without restriction, including without limitation the rights
|
|
1148
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1149
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
1150
|
+
* furnished to do so, subject to the following conditions:
|
|
1151
|
+
*
|
|
1152
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
1153
|
+
* copies or substantial portions of the Software.
|
|
1154
|
+
*
|
|
1155
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1156
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1157
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1158
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1159
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1160
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1161
|
+
* SOFTWARE.
|
|
1162
|
+
*
|
|
1163
|
+
*/
|
|
1164
|
+
function isNormalChar(c) {
|
|
1165
|
+
return c < "\u0027" || c === "," || c === "-" || c >= "\u002F" && c <= "\u003E" ||
|
|
1166
|
+
// / .. >
|
|
1167
|
+
c >= "\u0040" && c <= "\u005A" ||
|
|
1168
|
+
// @ .. Z
|
|
1169
|
+
c >= "\u005E" && c <= "\u007A" ||
|
|
1170
|
+
// ^ .. z
|
|
1171
|
+
c >= "\u007E" && c <= "\uD7FF" ||
|
|
1172
|
+
// skip surrogate code points
|
|
1173
|
+
c >= "\uE000";
|
|
1174
|
+
}
|
|
1175
|
+
function isCCChar(c) {
|
|
1176
|
+
return c < "\u002C" || c >= "\u002E" && c <= "\u005A" ||
|
|
1177
|
+
// '.' .. Z
|
|
1178
|
+
c >= "\u005E" && c <= "\uD7FF" ||
|
|
1179
|
+
// skip surrogate code points
|
|
1180
|
+
c >= "\uE000";
|
|
1181
|
+
}
|
|
1182
|
+
function peg$subclass(child, parent) {
|
|
1183
|
+
function C() {
|
|
1184
|
+
this.constructor = child;
|
|
1185
|
+
}
|
|
1186
|
+
C.prototype = parent.prototype;
|
|
1187
|
+
child.prototype = new C();
|
|
1188
|
+
}
|
|
1189
|
+
function peg$SyntaxError(message, expected, found, location) {
|
|
1190
|
+
var self = Error.call(this, message);
|
|
1191
|
+
// istanbul ignore next Check is a necessary evil to support older environments
|
|
1192
|
+
if (Object.setPrototypeOf) {
|
|
1193
|
+
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
1194
|
+
}
|
|
1195
|
+
self.expected = expected;
|
|
1196
|
+
self.found = found;
|
|
1197
|
+
self.location = location;
|
|
1198
|
+
self.name = "SyntaxError";
|
|
1199
|
+
return self;
|
|
1200
|
+
}
|
|
1201
|
+
peg$subclass(peg$SyntaxError, Error);
|
|
1202
|
+
function peg$padEnd(str, targetLength, padString) {
|
|
1203
|
+
padString = padString || " ";
|
|
1204
|
+
if (str.length > targetLength) {
|
|
1205
|
+
return str;
|
|
1206
|
+
}
|
|
1207
|
+
targetLength -= str.length;
|
|
1208
|
+
padString += padString.repeat(targetLength);
|
|
1209
|
+
return str + padString.slice(0, targetLength);
|
|
1210
|
+
}
|
|
1211
|
+
peg$SyntaxError.prototype.format = function (sources) {
|
|
1212
|
+
var str = "Error: " + this.message;
|
|
1213
|
+
if (this.location) {
|
|
1214
|
+
var src = null;
|
|
1215
|
+
var k;
|
|
1216
|
+
for (k = 0; k < sources.length; k++) {
|
|
1217
|
+
if (sources[k].source === this.location.source) {
|
|
1218
|
+
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
var s = this.location.start;
|
|
1223
|
+
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
1224
|
+
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
1225
|
+
if (src) {
|
|
1226
|
+
var e = this.location.end;
|
|
1227
|
+
var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
|
|
1228
|
+
var line = src[s.line - 1];
|
|
1229
|
+
var last = s.line === e.line ? e.column : line.length + 1;
|
|
1230
|
+
var hatLen = last - s.column || 1;
|
|
1231
|
+
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, ' ') + peg$padEnd("", hatLen, "^");
|
|
1232
|
+
} else {
|
|
1233
|
+
str += "\n at " + loc;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
return str;
|
|
1237
|
+
};
|
|
1238
|
+
peg$SyntaxError.buildMessage = function (expected, found) {
|
|
1239
|
+
var DESCRIBE_EXPECTATION_FNS = {
|
|
1240
|
+
literal: function (expectation) {
|
|
1241
|
+
return "\"" + literalEscape(expectation.text) + "\"";
|
|
1242
|
+
},
|
|
1243
|
+
class: function (expectation) {
|
|
1244
|
+
var escapedParts = expectation.parts.map(function (part) {
|
|
1245
|
+
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
1246
|
+
});
|
|
1247
|
+
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
1248
|
+
},
|
|
1249
|
+
any: function () {
|
|
1250
|
+
return "any character";
|
|
1251
|
+
},
|
|
1252
|
+
end: function () {
|
|
1253
|
+
return "end of input";
|
|
1254
|
+
},
|
|
1255
|
+
other: function (expectation) {
|
|
1256
|
+
return expectation.description;
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
function hex(ch) {
|
|
1260
|
+
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
1261
|
+
}
|
|
1262
|
+
function literalEscape(s) {
|
|
1263
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function (ch) {
|
|
1264
|
+
return "\\x0" + hex(ch);
|
|
1265
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
|
1266
|
+
return "\\x" + hex(ch);
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
function classEscape(s) {
|
|
1270
|
+
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function (ch) {
|
|
1271
|
+
return "\\x0" + hex(ch);
|
|
1272
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
|
1273
|
+
return "\\x" + hex(ch);
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
function describeExpectation(expectation) {
|
|
1277
|
+
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
1278
|
+
}
|
|
1279
|
+
function describeExpected(expected) {
|
|
1280
|
+
var descriptions = expected.map(describeExpectation);
|
|
1281
|
+
var i, j;
|
|
1282
|
+
descriptions.sort();
|
|
1283
|
+
if (descriptions.length > 0) {
|
|
1284
|
+
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
1285
|
+
if (descriptions[i - 1] !== descriptions[i]) {
|
|
1286
|
+
descriptions[j] = descriptions[i];
|
|
1287
|
+
j++;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
descriptions.length = j;
|
|
1291
|
+
}
|
|
1292
|
+
switch (descriptions.length) {
|
|
1293
|
+
case 1:
|
|
1294
|
+
return descriptions[0];
|
|
1295
|
+
case 2:
|
|
1296
|
+
return descriptions[0] + " or " + descriptions[1];
|
|
1297
|
+
default:
|
|
1298
|
+
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function describeFound(found) {
|
|
1302
|
+
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
|
1303
|
+
}
|
|
1304
|
+
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
1305
|
+
};
|
|
1306
|
+
function peg$parse(input, options) {
|
|
1307
|
+
options = options !== undefined ? options : {};
|
|
1308
|
+
var peg$FAILED = {};
|
|
1309
|
+
var peg$source = options.grammarSource;
|
|
1310
|
+
var peg$startRuleFunctions = {
|
|
1311
|
+
start: peg$parsestart
|
|
1312
|
+
};
|
|
1313
|
+
var peg$startRuleFunction = peg$parsestart;
|
|
1314
|
+
var peg$c0 = "|";
|
|
1315
|
+
var peg$c1 = "{";
|
|
1316
|
+
var peg$c2 = ",";
|
|
1317
|
+
var peg$c3 = "}";
|
|
1318
|
+
var peg$c4 = "(";
|
|
1319
|
+
var peg$c5 = ")";
|
|
1320
|
+
var peg$c6 = ".";
|
|
1321
|
+
var peg$c7 = "\\";
|
|
1322
|
+
var peg$c8 = "[";
|
|
1323
|
+
var peg$c9 = "^";
|
|
1324
|
+
var peg$c10 = "-";
|
|
1325
|
+
var peg$c11 = "]";
|
|
1326
|
+
var peg$c12 = "\\p{";
|
|
1327
|
+
var peg$c13 = "\\P{";
|
|
1328
|
+
var peg$c14 = "L";
|
|
1329
|
+
var peg$c15 = "M";
|
|
1330
|
+
var peg$c16 = "N";
|
|
1331
|
+
var peg$c17 = "P";
|
|
1332
|
+
var peg$c18 = "Z";
|
|
1333
|
+
var peg$c19 = "S";
|
|
1334
|
+
var peg$c20 = "C";
|
|
1335
|
+
var peg$r0 = /^[*-+?]/;
|
|
1336
|
+
var peg$r1 = /^[0-9]/;
|
|
1337
|
+
var peg$r2 = /^[(-+\--.?[-\^nrt{-}]/;
|
|
1338
|
+
var peg$r3 = /^[l-mot-u]/;
|
|
1339
|
+
var peg$r4 = /^[cen]/;
|
|
1340
|
+
var peg$r5 = /^[dlo]/;
|
|
1341
|
+
var peg$r6 = /^[c-fios]/;
|
|
1342
|
+
var peg$r7 = /^[lps]/;
|
|
1343
|
+
var peg$r8 = /^[ckmo]/;
|
|
1344
|
+
var peg$r9 = /^[cfn-o]/;
|
|
1345
|
+
var peg$e0 = peg$literalExpectation("|", false);
|
|
1346
|
+
var peg$e1 = peg$classExpectation([["*", "+"], "?"], false, false);
|
|
1347
|
+
var peg$e2 = peg$literalExpectation("{", false);
|
|
1348
|
+
var peg$e3 = peg$classExpectation([["0", "9"]], false, false);
|
|
1349
|
+
var peg$e4 = peg$literalExpectation(",", false);
|
|
1350
|
+
var peg$e5 = peg$literalExpectation("}", false);
|
|
1351
|
+
var peg$e6 = peg$literalExpectation("(", false);
|
|
1352
|
+
var peg$e7 = peg$literalExpectation(")", false);
|
|
1353
|
+
var peg$e8 = peg$anyExpectation();
|
|
1354
|
+
var peg$e9 = peg$literalExpectation(".", false);
|
|
1355
|
+
var peg$e10 = peg$literalExpectation("\\", false);
|
|
1356
|
+
var peg$e11 = peg$classExpectation([["(", "+"], ["-", "."], "?", ["[", "^"], "n", "r", "t", ["{", "}"]], false, false);
|
|
1357
|
+
var peg$e12 = peg$literalExpectation("[", false);
|
|
1358
|
+
var peg$e13 = peg$literalExpectation("^", false);
|
|
1359
|
+
var peg$e14 = peg$literalExpectation("-", false);
|
|
1360
|
+
var peg$e15 = peg$literalExpectation("]", false);
|
|
1361
|
+
var peg$e16 = peg$literalExpectation("\\p{", false);
|
|
1362
|
+
var peg$e17 = peg$literalExpectation("\\P{", false);
|
|
1363
|
+
var peg$e18 = peg$literalExpectation("L", false);
|
|
1364
|
+
var peg$e19 = peg$classExpectation([["l", "m"], "o", ["t", "u"]], false, false);
|
|
1365
|
+
var peg$e20 = peg$literalExpectation("M", false);
|
|
1366
|
+
var peg$e21 = peg$classExpectation(["c", "e", "n"], false, false);
|
|
1367
|
+
var peg$e22 = peg$literalExpectation("N", false);
|
|
1368
|
+
var peg$e23 = peg$classExpectation(["d", "l", "o"], false, false);
|
|
1369
|
+
var peg$e24 = peg$literalExpectation("P", false);
|
|
1370
|
+
var peg$e25 = peg$classExpectation([["c", "f"], "i", "o", "s"], false, false);
|
|
1371
|
+
var peg$e26 = peg$literalExpectation("Z", false);
|
|
1372
|
+
var peg$e27 = peg$classExpectation(["l", "p", "s"], false, false);
|
|
1373
|
+
var peg$e28 = peg$literalExpectation("S", false);
|
|
1374
|
+
var peg$e29 = peg$classExpectation(["c", "k", "m", "o"], false, false);
|
|
1375
|
+
var peg$e30 = peg$literalExpectation("C", false);
|
|
1376
|
+
var peg$e31 = peg$classExpectation(["c", "f", ["n", "o"]], false, false);
|
|
1377
|
+
var peg$f0 = function (c) {
|
|
1378
|
+
return isNormalChar(c);
|
|
1379
|
+
};
|
|
1380
|
+
var peg$f1 = function (c) {
|
|
1381
|
+
return isCCChar(c);
|
|
1382
|
+
};
|
|
1383
|
+
var peg$currPos = options.peg$currPos | 0;
|
|
1384
|
+
var peg$posDetailsCache = [{
|
|
1385
|
+
line: 1,
|
|
1386
|
+
column: 1
|
|
1387
|
+
}];
|
|
1388
|
+
var peg$maxFailPos = peg$currPos;
|
|
1389
|
+
var peg$maxFailExpected = options.peg$maxFailExpected || [];
|
|
1390
|
+
var peg$silentFails = options.peg$silentFails | 0;
|
|
1391
|
+
var peg$result;
|
|
1392
|
+
if (options.startRule) {
|
|
1393
|
+
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
1394
|
+
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
|
1395
|
+
}
|
|
1396
|
+
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
1397
|
+
}
|
|
1398
|
+
function peg$literalExpectation(text, ignoreCase) {
|
|
1399
|
+
return {
|
|
1400
|
+
type: "literal",
|
|
1401
|
+
text: text,
|
|
1402
|
+
ignoreCase: ignoreCase
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
function peg$classExpectation(parts, inverted, ignoreCase) {
|
|
1406
|
+
return {
|
|
1407
|
+
type: "class",
|
|
1408
|
+
parts: parts,
|
|
1409
|
+
inverted: inverted,
|
|
1410
|
+
ignoreCase: ignoreCase
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function peg$anyExpectation() {
|
|
1414
|
+
return {
|
|
1415
|
+
type: "any"
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
function peg$endExpectation() {
|
|
1419
|
+
return {
|
|
1420
|
+
type: "end"
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function peg$computePosDetails(pos) {
|
|
1424
|
+
var details = peg$posDetailsCache[pos];
|
|
1425
|
+
var p;
|
|
1426
|
+
if (details) {
|
|
1427
|
+
return details;
|
|
1428
|
+
} else {
|
|
1429
|
+
if (pos >= peg$posDetailsCache.length) {
|
|
1430
|
+
p = peg$posDetailsCache.length - 1;
|
|
1431
|
+
} else {
|
|
1432
|
+
p = pos;
|
|
1433
|
+
while (!peg$posDetailsCache[--p]) {}
|
|
1434
|
+
}
|
|
1435
|
+
details = peg$posDetailsCache[p];
|
|
1436
|
+
details = {
|
|
1437
|
+
line: details.line,
|
|
1438
|
+
column: details.column
|
|
1439
|
+
};
|
|
1440
|
+
while (p < pos) {
|
|
1441
|
+
if (input.charCodeAt(p) === 10) {
|
|
1442
|
+
details.line++;
|
|
1443
|
+
details.column = 1;
|
|
1444
|
+
} else {
|
|
1445
|
+
details.column++;
|
|
1446
|
+
}
|
|
1447
|
+
p++;
|
|
1448
|
+
}
|
|
1449
|
+
peg$posDetailsCache[pos] = details;
|
|
1450
|
+
return details;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
function peg$computeLocation(startPos, endPos, offset) {
|
|
1454
|
+
var startPosDetails = peg$computePosDetails(startPos);
|
|
1455
|
+
var endPosDetails = peg$computePosDetails(endPos);
|
|
1456
|
+
var res = {
|
|
1457
|
+
source: peg$source,
|
|
1458
|
+
start: {
|
|
1459
|
+
offset: startPos,
|
|
1460
|
+
line: startPosDetails.line,
|
|
1461
|
+
column: startPosDetails.column
|
|
1462
|
+
},
|
|
1463
|
+
end: {
|
|
1464
|
+
offset: endPos,
|
|
1465
|
+
line: endPosDetails.line,
|
|
1466
|
+
column: endPosDetails.column
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
return res;
|
|
1470
|
+
}
|
|
1471
|
+
function peg$fail(expected) {
|
|
1472
|
+
if (peg$currPos < peg$maxFailPos) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
if (peg$currPos > peg$maxFailPos) {
|
|
1476
|
+
peg$maxFailPos = peg$currPos;
|
|
1477
|
+
peg$maxFailExpected = [];
|
|
1478
|
+
}
|
|
1479
|
+
peg$maxFailExpected.push(expected);
|
|
1480
|
+
}
|
|
1481
|
+
function peg$buildStructuredError(expected, found, location) {
|
|
1482
|
+
return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
|
|
1483
|
+
}
|
|
1484
|
+
function peg$parsestart() {
|
|
1485
|
+
var s0;
|
|
1486
|
+
s0 = peg$parseiregexp();
|
|
1487
|
+
return s0;
|
|
1488
|
+
}
|
|
1489
|
+
function peg$parseiregexp() {
|
|
1490
|
+
var s0, s1, s2, s3, s4, s5;
|
|
1491
|
+
s0 = peg$currPos;
|
|
1492
|
+
s1 = peg$parsebranch();
|
|
1493
|
+
s2 = [];
|
|
1494
|
+
s3 = peg$currPos;
|
|
1495
|
+
if (input.charCodeAt(peg$currPos) === 124) {
|
|
1496
|
+
s4 = peg$c0;
|
|
1497
|
+
peg$currPos++;
|
|
1498
|
+
} else {
|
|
1499
|
+
s4 = peg$FAILED;
|
|
1500
|
+
if (peg$silentFails === 0) {
|
|
1501
|
+
peg$fail(peg$e0);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
if (s4 !== peg$FAILED) {
|
|
1505
|
+
s5 = peg$parsebranch();
|
|
1506
|
+
s4 = [s4, s5];
|
|
1507
|
+
s3 = s4;
|
|
1508
|
+
} else {
|
|
1509
|
+
peg$currPos = s3;
|
|
1510
|
+
s3 = peg$FAILED;
|
|
1511
|
+
}
|
|
1512
|
+
while (s3 !== peg$FAILED) {
|
|
1513
|
+
s2.push(s3);
|
|
1514
|
+
s3 = peg$currPos;
|
|
1515
|
+
if (input.charCodeAt(peg$currPos) === 124) {
|
|
1516
|
+
s4 = peg$c0;
|
|
1517
|
+
peg$currPos++;
|
|
1518
|
+
} else {
|
|
1519
|
+
s4 = peg$FAILED;
|
|
1520
|
+
if (peg$silentFails === 0) {
|
|
1521
|
+
peg$fail(peg$e0);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
if (s4 !== peg$FAILED) {
|
|
1525
|
+
s5 = peg$parsebranch();
|
|
1526
|
+
s4 = [s4, s5];
|
|
1527
|
+
s3 = s4;
|
|
1528
|
+
} else {
|
|
1529
|
+
peg$currPos = s3;
|
|
1530
|
+
s3 = peg$FAILED;
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
s1 = [s1, s2];
|
|
1534
|
+
s0 = s1;
|
|
1535
|
+
return s0;
|
|
1536
|
+
}
|
|
1537
|
+
function peg$parsebranch() {
|
|
1538
|
+
var s0, s1;
|
|
1539
|
+
s0 = [];
|
|
1540
|
+
s1 = peg$parsepiece();
|
|
1541
|
+
while (s1 !== peg$FAILED) {
|
|
1542
|
+
s0.push(s1);
|
|
1543
|
+
s1 = peg$parsepiece();
|
|
1544
|
+
}
|
|
1545
|
+
return s0;
|
|
1546
|
+
}
|
|
1547
|
+
function peg$parsepiece() {
|
|
1548
|
+
var s0, s1, s2;
|
|
1549
|
+
s0 = peg$currPos;
|
|
1550
|
+
s1 = peg$parseatom();
|
|
1551
|
+
if (s1 !== peg$FAILED) {
|
|
1552
|
+
s2 = peg$parsequantifier();
|
|
1553
|
+
if (s2 === peg$FAILED) {
|
|
1554
|
+
s2 = null;
|
|
1555
|
+
}
|
|
1556
|
+
s1 = [s1, s2];
|
|
1557
|
+
s0 = s1;
|
|
1558
|
+
} else {
|
|
1559
|
+
peg$currPos = s0;
|
|
1560
|
+
s0 = peg$FAILED;
|
|
1561
|
+
}
|
|
1562
|
+
return s0;
|
|
1563
|
+
}
|
|
1564
|
+
function peg$parsequantifier() {
|
|
1565
|
+
var s0;
|
|
1566
|
+
s0 = input.charAt(peg$currPos);
|
|
1567
|
+
if (peg$r0.test(s0)) {
|
|
1568
|
+
peg$currPos++;
|
|
1569
|
+
} else {
|
|
1570
|
+
s0 = peg$FAILED;
|
|
1571
|
+
if (peg$silentFails === 0) {
|
|
1572
|
+
peg$fail(peg$e1);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (s0 === peg$FAILED) {
|
|
1576
|
+
s0 = peg$parserange_quantifier();
|
|
1577
|
+
}
|
|
1578
|
+
return s0;
|
|
1579
|
+
}
|
|
1580
|
+
function peg$parserange_quantifier() {
|
|
1581
|
+
var s0, s1, s2, s3, s4, s5;
|
|
1582
|
+
s0 = peg$currPos;
|
|
1583
|
+
if (input.charCodeAt(peg$currPos) === 123) {
|
|
1584
|
+
s1 = peg$c1;
|
|
1585
|
+
peg$currPos++;
|
|
1586
|
+
} else {
|
|
1587
|
+
s1 = peg$FAILED;
|
|
1588
|
+
if (peg$silentFails === 0) {
|
|
1589
|
+
peg$fail(peg$e2);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
if (s1 !== peg$FAILED) {
|
|
1593
|
+
s2 = input.charAt(peg$currPos);
|
|
1594
|
+
if (peg$r1.test(s2)) {
|
|
1595
|
+
peg$currPos++;
|
|
1596
|
+
} else {
|
|
1597
|
+
s2 = peg$FAILED;
|
|
1598
|
+
if (peg$silentFails === 0) {
|
|
1599
|
+
peg$fail(peg$e3);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
if (s2 !== peg$FAILED) {
|
|
1603
|
+
s3 = peg$currPos;
|
|
1604
|
+
if (input.charCodeAt(peg$currPos) === 44) {
|
|
1605
|
+
s4 = peg$c2;
|
|
1606
|
+
peg$currPos++;
|
|
1607
|
+
} else {
|
|
1608
|
+
s4 = peg$FAILED;
|
|
1609
|
+
if (peg$silentFails === 0) {
|
|
1610
|
+
peg$fail(peg$e4);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
if (s4 !== peg$FAILED) {
|
|
1614
|
+
s5 = input.charAt(peg$currPos);
|
|
1615
|
+
if (peg$r1.test(s5)) {
|
|
1616
|
+
peg$currPos++;
|
|
1617
|
+
} else {
|
|
1618
|
+
s5 = peg$FAILED;
|
|
1619
|
+
if (peg$silentFails === 0) {
|
|
1620
|
+
peg$fail(peg$e3);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
if (s5 === peg$FAILED) {
|
|
1624
|
+
s5 = null;
|
|
1625
|
+
}
|
|
1626
|
+
s4 = [s4, s5];
|
|
1627
|
+
s3 = s4;
|
|
1628
|
+
} else {
|
|
1629
|
+
peg$currPos = s3;
|
|
1630
|
+
s3 = peg$FAILED;
|
|
1631
|
+
}
|
|
1632
|
+
if (s3 === peg$FAILED) {
|
|
1633
|
+
s3 = null;
|
|
1634
|
+
}
|
|
1635
|
+
if (input.charCodeAt(peg$currPos) === 125) {
|
|
1636
|
+
s4 = peg$c3;
|
|
1637
|
+
peg$currPos++;
|
|
1638
|
+
} else {
|
|
1639
|
+
s4 = peg$FAILED;
|
|
1640
|
+
if (peg$silentFails === 0) {
|
|
1641
|
+
peg$fail(peg$e5);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
if (s4 !== peg$FAILED) {
|
|
1645
|
+
s1 = [s1, s2, s3, s4];
|
|
1646
|
+
s0 = s1;
|
|
1647
|
+
} else {
|
|
1648
|
+
peg$currPos = s0;
|
|
1649
|
+
s0 = peg$FAILED;
|
|
1650
|
+
}
|
|
1651
|
+
} else {
|
|
1652
|
+
peg$currPos = s0;
|
|
1653
|
+
s0 = peg$FAILED;
|
|
1654
|
+
}
|
|
1655
|
+
} else {
|
|
1656
|
+
peg$currPos = s0;
|
|
1657
|
+
s0 = peg$FAILED;
|
|
1658
|
+
}
|
|
1659
|
+
return s0;
|
|
1660
|
+
}
|
|
1661
|
+
function peg$parseatom() {
|
|
1662
|
+
var s0, s1, s2, s3;
|
|
1663
|
+
s0 = peg$parsenormal_char();
|
|
1664
|
+
if (s0 === peg$FAILED) {
|
|
1665
|
+
s0 = peg$parsechar_class();
|
|
1666
|
+
if (s0 === peg$FAILED) {
|
|
1667
|
+
s0 = peg$currPos;
|
|
1668
|
+
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1669
|
+
s1 = peg$c4;
|
|
1670
|
+
peg$currPos++;
|
|
1671
|
+
} else {
|
|
1672
|
+
s1 = peg$FAILED;
|
|
1673
|
+
if (peg$silentFails === 0) {
|
|
1674
|
+
peg$fail(peg$e6);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
if (s1 !== peg$FAILED) {
|
|
1678
|
+
s2 = peg$parseiregexp();
|
|
1679
|
+
if (s2 !== peg$FAILED) {
|
|
1680
|
+
if (input.charCodeAt(peg$currPos) === 41) {
|
|
1681
|
+
s3 = peg$c5;
|
|
1682
|
+
peg$currPos++;
|
|
1683
|
+
} else {
|
|
1684
|
+
s3 = peg$FAILED;
|
|
1685
|
+
if (peg$silentFails === 0) {
|
|
1686
|
+
peg$fail(peg$e7);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
if (s3 !== peg$FAILED) {
|
|
1690
|
+
s1 = [s1, s2, s3];
|
|
1691
|
+
s0 = s1;
|
|
1692
|
+
} else {
|
|
1693
|
+
peg$currPos = s0;
|
|
1694
|
+
s0 = peg$FAILED;
|
|
1695
|
+
}
|
|
1696
|
+
} else {
|
|
1697
|
+
peg$currPos = s0;
|
|
1698
|
+
s0 = peg$FAILED;
|
|
1699
|
+
}
|
|
1700
|
+
} else {
|
|
1701
|
+
peg$currPos = s0;
|
|
1702
|
+
s0 = peg$FAILED;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
return s0;
|
|
1707
|
+
}
|
|
1708
|
+
function peg$parsenormal_char() {
|
|
1709
|
+
var s0, s1, s2;
|
|
1710
|
+
s0 = peg$currPos;
|
|
1711
|
+
if (input.length > peg$currPos) {
|
|
1712
|
+
s1 = input.charAt(peg$currPos);
|
|
1713
|
+
peg$currPos++;
|
|
1714
|
+
} else {
|
|
1715
|
+
s1 = peg$FAILED;
|
|
1716
|
+
if (peg$silentFails === 0) {
|
|
1717
|
+
peg$fail(peg$e8);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
if (s1 !== peg$FAILED) {
|
|
1721
|
+
s2 = peg$f0(s1);
|
|
1722
|
+
if (s2) {
|
|
1723
|
+
s2 = undefined;
|
|
1724
|
+
} else {
|
|
1725
|
+
s2 = peg$FAILED;
|
|
1726
|
+
}
|
|
1727
|
+
if (s2 !== peg$FAILED) {
|
|
1728
|
+
s0 = s1;
|
|
1729
|
+
} else {
|
|
1730
|
+
peg$currPos = s0;
|
|
1731
|
+
s0 = peg$FAILED;
|
|
1732
|
+
}
|
|
1733
|
+
} else {
|
|
1734
|
+
peg$currPos = s0;
|
|
1735
|
+
s0 = peg$FAILED;
|
|
1736
|
+
}
|
|
1737
|
+
return s0;
|
|
1738
|
+
}
|
|
1739
|
+
function peg$parsechar_class() {
|
|
1740
|
+
var s0;
|
|
1741
|
+
if (input.charCodeAt(peg$currPos) === 46) {
|
|
1742
|
+
s0 = peg$c6;
|
|
1743
|
+
peg$currPos++;
|
|
1744
|
+
} else {
|
|
1745
|
+
s0 = peg$FAILED;
|
|
1746
|
+
if (peg$silentFails === 0) {
|
|
1747
|
+
peg$fail(peg$e9);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
if (s0 === peg$FAILED) {
|
|
1751
|
+
s0 = peg$parsesingle_char_esc();
|
|
1752
|
+
if (s0 === peg$FAILED) {
|
|
1753
|
+
s0 = peg$parsechar_class_esc();
|
|
1754
|
+
if (s0 === peg$FAILED) {
|
|
1755
|
+
s0 = peg$parsechar_class_expr();
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return s0;
|
|
1760
|
+
}
|
|
1761
|
+
function peg$parsesingle_char_esc() {
|
|
1762
|
+
var s0, s1, s2;
|
|
1763
|
+
s0 = peg$currPos;
|
|
1764
|
+
if (input.charCodeAt(peg$currPos) === 92) {
|
|
1765
|
+
s1 = peg$c7;
|
|
1766
|
+
peg$currPos++;
|
|
1767
|
+
} else {
|
|
1768
|
+
s1 = peg$FAILED;
|
|
1769
|
+
if (peg$silentFails === 0) {
|
|
1770
|
+
peg$fail(peg$e10);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
if (s1 !== peg$FAILED) {
|
|
1774
|
+
s2 = input.charAt(peg$currPos);
|
|
1775
|
+
if (peg$r2.test(s2)) {
|
|
1776
|
+
peg$currPos++;
|
|
1777
|
+
} else {
|
|
1778
|
+
s2 = peg$FAILED;
|
|
1779
|
+
if (peg$silentFails === 0) {
|
|
1780
|
+
peg$fail(peg$e11);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
if (s2 !== peg$FAILED) {
|
|
1784
|
+
s1 = [s1, s2];
|
|
1785
|
+
s0 = s1;
|
|
1786
|
+
} else {
|
|
1787
|
+
peg$currPos = s0;
|
|
1788
|
+
s0 = peg$FAILED;
|
|
1789
|
+
}
|
|
1790
|
+
} else {
|
|
1791
|
+
peg$currPos = s0;
|
|
1792
|
+
s0 = peg$FAILED;
|
|
1793
|
+
}
|
|
1794
|
+
return s0;
|
|
1795
|
+
}
|
|
1796
|
+
function peg$parsechar_class_esc() {
|
|
1797
|
+
var s0;
|
|
1798
|
+
s0 = peg$parsecat_esc();
|
|
1799
|
+
if (s0 === peg$FAILED) {
|
|
1800
|
+
s0 = peg$parsecompl_esc();
|
|
1801
|
+
}
|
|
1802
|
+
return s0;
|
|
1803
|
+
}
|
|
1804
|
+
function peg$parsechar_class_expr() {
|
|
1805
|
+
var s0, s1, s2, s3, s4, s5, s6;
|
|
1806
|
+
s0 = peg$currPos;
|
|
1807
|
+
if (input.charCodeAt(peg$currPos) === 91) {
|
|
1808
|
+
s1 = peg$c8;
|
|
1809
|
+
peg$currPos++;
|
|
1810
|
+
} else {
|
|
1811
|
+
s1 = peg$FAILED;
|
|
1812
|
+
if (peg$silentFails === 0) {
|
|
1813
|
+
peg$fail(peg$e12);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (s1 !== peg$FAILED) {
|
|
1817
|
+
if (input.charCodeAt(peg$currPos) === 94) {
|
|
1818
|
+
s2 = peg$c9;
|
|
1819
|
+
peg$currPos++;
|
|
1820
|
+
} else {
|
|
1821
|
+
s2 = peg$FAILED;
|
|
1822
|
+
if (peg$silentFails === 0) {
|
|
1823
|
+
peg$fail(peg$e13);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
if (s2 === peg$FAILED) {
|
|
1827
|
+
s2 = null;
|
|
1828
|
+
}
|
|
1829
|
+
if (input.charCodeAt(peg$currPos) === 45) {
|
|
1830
|
+
s3 = peg$c10;
|
|
1831
|
+
peg$currPos++;
|
|
1832
|
+
} else {
|
|
1833
|
+
s3 = peg$FAILED;
|
|
1834
|
+
if (peg$silentFails === 0) {
|
|
1835
|
+
peg$fail(peg$e14);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
if (s3 === peg$FAILED) {
|
|
1839
|
+
s3 = peg$parsecce1();
|
|
1840
|
+
}
|
|
1841
|
+
if (s3 !== peg$FAILED) {
|
|
1842
|
+
s4 = [];
|
|
1843
|
+
s5 = peg$parsecce1();
|
|
1844
|
+
while (s5 !== peg$FAILED) {
|
|
1845
|
+
s4.push(s5);
|
|
1846
|
+
s5 = peg$parsecce1();
|
|
1847
|
+
}
|
|
1848
|
+
if (input.charCodeAt(peg$currPos) === 45) {
|
|
1849
|
+
s5 = peg$c10;
|
|
1850
|
+
peg$currPos++;
|
|
1851
|
+
} else {
|
|
1852
|
+
s5 = peg$FAILED;
|
|
1853
|
+
if (peg$silentFails === 0) {
|
|
1854
|
+
peg$fail(peg$e14);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
if (s5 === peg$FAILED) {
|
|
1858
|
+
s5 = null;
|
|
1859
|
+
}
|
|
1860
|
+
if (input.charCodeAt(peg$currPos) === 93) {
|
|
1861
|
+
s6 = peg$c11;
|
|
1862
|
+
peg$currPos++;
|
|
1863
|
+
} else {
|
|
1864
|
+
s6 = peg$FAILED;
|
|
1865
|
+
if (peg$silentFails === 0) {
|
|
1866
|
+
peg$fail(peg$e15);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
if (s6 !== peg$FAILED) {
|
|
1870
|
+
s1 = [s1, s2, s3, s4, s5, s6];
|
|
1871
|
+
s0 = s1;
|
|
1872
|
+
} else {
|
|
1873
|
+
peg$currPos = s0;
|
|
1874
|
+
s0 = peg$FAILED;
|
|
1875
|
+
}
|
|
1876
|
+
} else {
|
|
1877
|
+
peg$currPos = s0;
|
|
1878
|
+
s0 = peg$FAILED;
|
|
1879
|
+
}
|
|
1880
|
+
} else {
|
|
1881
|
+
peg$currPos = s0;
|
|
1882
|
+
s0 = peg$FAILED;
|
|
1883
|
+
}
|
|
1884
|
+
return s0;
|
|
1885
|
+
}
|
|
1886
|
+
function peg$parsecce1() {
|
|
1887
|
+
var s0, s1, s2, s3, s4;
|
|
1888
|
+
s0 = peg$currPos;
|
|
1889
|
+
s1 = peg$parsecc_char();
|
|
1890
|
+
if (s1 !== peg$FAILED) {
|
|
1891
|
+
s2 = peg$currPos;
|
|
1892
|
+
if (input.charCodeAt(peg$currPos) === 45) {
|
|
1893
|
+
s3 = peg$c10;
|
|
1894
|
+
peg$currPos++;
|
|
1895
|
+
} else {
|
|
1896
|
+
s3 = peg$FAILED;
|
|
1897
|
+
if (peg$silentFails === 0) {
|
|
1898
|
+
peg$fail(peg$e14);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
if (s3 !== peg$FAILED) {
|
|
1902
|
+
s4 = peg$parsecc_char();
|
|
1903
|
+
if (s4 !== peg$FAILED) {
|
|
1904
|
+
s3 = [s3, s4];
|
|
1905
|
+
s2 = s3;
|
|
1906
|
+
} else {
|
|
1907
|
+
peg$currPos = s2;
|
|
1908
|
+
s2 = peg$FAILED;
|
|
1909
|
+
}
|
|
1910
|
+
} else {
|
|
1911
|
+
peg$currPos = s2;
|
|
1912
|
+
s2 = peg$FAILED;
|
|
1913
|
+
}
|
|
1914
|
+
if (s2 === peg$FAILED) {
|
|
1915
|
+
s2 = null;
|
|
1916
|
+
}
|
|
1917
|
+
s1 = [s1, s2];
|
|
1918
|
+
s0 = s1;
|
|
1919
|
+
} else {
|
|
1920
|
+
peg$currPos = s0;
|
|
1921
|
+
s0 = peg$FAILED;
|
|
1922
|
+
}
|
|
1923
|
+
if (s0 === peg$FAILED) {
|
|
1924
|
+
s0 = peg$parsechar_class_esc();
|
|
1925
|
+
}
|
|
1926
|
+
return s0;
|
|
1927
|
+
}
|
|
1928
|
+
function peg$parsecc_char() {
|
|
1929
|
+
var s0, s1, s2;
|
|
1930
|
+
s0 = peg$currPos;
|
|
1931
|
+
if (input.length > peg$currPos) {
|
|
1932
|
+
s1 = input.charAt(peg$currPos);
|
|
1933
|
+
peg$currPos++;
|
|
1934
|
+
} else {
|
|
1935
|
+
s1 = peg$FAILED;
|
|
1936
|
+
if (peg$silentFails === 0) {
|
|
1937
|
+
peg$fail(peg$e8);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (s1 !== peg$FAILED) {
|
|
1941
|
+
s2 = peg$f1(s1);
|
|
1942
|
+
if (s2) {
|
|
1943
|
+
s2 = undefined;
|
|
1944
|
+
} else {
|
|
1945
|
+
s2 = peg$FAILED;
|
|
1946
|
+
}
|
|
1947
|
+
if (s2 !== peg$FAILED) {
|
|
1948
|
+
s0 = s1;
|
|
1949
|
+
} else {
|
|
1950
|
+
peg$currPos = s0;
|
|
1951
|
+
s0 = peg$FAILED;
|
|
1952
|
+
}
|
|
1953
|
+
} else {
|
|
1954
|
+
peg$currPos = s0;
|
|
1955
|
+
s0 = peg$FAILED;
|
|
1956
|
+
}
|
|
1957
|
+
if (s0 === peg$FAILED) {
|
|
1958
|
+
s0 = peg$parsesingle_char_esc();
|
|
1959
|
+
}
|
|
1960
|
+
return s0;
|
|
1961
|
+
}
|
|
1962
|
+
function peg$parsecat_esc() {
|
|
1963
|
+
var s0, s1, s2, s3;
|
|
1964
|
+
s0 = peg$currPos;
|
|
1965
|
+
if (input.substr(peg$currPos, 3) === peg$c12) {
|
|
1966
|
+
s1 = peg$c12;
|
|
1967
|
+
peg$currPos += 3;
|
|
1968
|
+
} else {
|
|
1969
|
+
s1 = peg$FAILED;
|
|
1970
|
+
if (peg$silentFails === 0) {
|
|
1971
|
+
peg$fail(peg$e16);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
if (s1 !== peg$FAILED) {
|
|
1975
|
+
s2 = peg$parseis_category();
|
|
1976
|
+
if (s2 !== peg$FAILED) {
|
|
1977
|
+
if (input.charCodeAt(peg$currPos) === 125) {
|
|
1978
|
+
s3 = peg$c3;
|
|
1979
|
+
peg$currPos++;
|
|
1980
|
+
} else {
|
|
1981
|
+
s3 = peg$FAILED;
|
|
1982
|
+
if (peg$silentFails === 0) {
|
|
1983
|
+
peg$fail(peg$e5);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
if (s3 !== peg$FAILED) {
|
|
1987
|
+
s1 = [s1, s2, s3];
|
|
1988
|
+
s0 = s1;
|
|
1989
|
+
} else {
|
|
1990
|
+
peg$currPos = s0;
|
|
1991
|
+
s0 = peg$FAILED;
|
|
1992
|
+
}
|
|
1993
|
+
} else {
|
|
1994
|
+
peg$currPos = s0;
|
|
1995
|
+
s0 = peg$FAILED;
|
|
1996
|
+
}
|
|
1997
|
+
} else {
|
|
1998
|
+
peg$currPos = s0;
|
|
1999
|
+
s0 = peg$FAILED;
|
|
2000
|
+
}
|
|
2001
|
+
return s0;
|
|
2002
|
+
}
|
|
2003
|
+
function peg$parsecompl_esc() {
|
|
2004
|
+
var s0, s1, s2, s3;
|
|
2005
|
+
s0 = peg$currPos;
|
|
2006
|
+
if (input.substr(peg$currPos, 3) === peg$c13) {
|
|
2007
|
+
s1 = peg$c13;
|
|
2008
|
+
peg$currPos += 3;
|
|
2009
|
+
} else {
|
|
2010
|
+
s1 = peg$FAILED;
|
|
2011
|
+
if (peg$silentFails === 0) {
|
|
2012
|
+
peg$fail(peg$e17);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
if (s1 !== peg$FAILED) {
|
|
2016
|
+
s2 = peg$parseis_category();
|
|
2017
|
+
if (s2 !== peg$FAILED) {
|
|
2018
|
+
if (input.charCodeAt(peg$currPos) === 125) {
|
|
2019
|
+
s3 = peg$c3;
|
|
2020
|
+
peg$currPos++;
|
|
2021
|
+
} else {
|
|
2022
|
+
s3 = peg$FAILED;
|
|
2023
|
+
if (peg$silentFails === 0) {
|
|
2024
|
+
peg$fail(peg$e5);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
if (s3 !== peg$FAILED) {
|
|
2028
|
+
s1 = [s1, s2, s3];
|
|
2029
|
+
s0 = s1;
|
|
2030
|
+
} else {
|
|
2031
|
+
peg$currPos = s0;
|
|
2032
|
+
s0 = peg$FAILED;
|
|
2033
|
+
}
|
|
2034
|
+
} else {
|
|
2035
|
+
peg$currPos = s0;
|
|
2036
|
+
s0 = peg$FAILED;
|
|
2037
|
+
}
|
|
2038
|
+
} else {
|
|
2039
|
+
peg$currPos = s0;
|
|
2040
|
+
s0 = peg$FAILED;
|
|
2041
|
+
}
|
|
2042
|
+
return s0;
|
|
2043
|
+
}
|
|
2044
|
+
function peg$parseis_category() {
|
|
2045
|
+
var s0;
|
|
2046
|
+
s0 = peg$parseletters();
|
|
2047
|
+
if (s0 === peg$FAILED) {
|
|
2048
|
+
s0 = peg$parsemarks();
|
|
2049
|
+
if (s0 === peg$FAILED) {
|
|
2050
|
+
s0 = peg$parsenumbers();
|
|
2051
|
+
if (s0 === peg$FAILED) {
|
|
2052
|
+
s0 = peg$parsepunctuation();
|
|
2053
|
+
if (s0 === peg$FAILED) {
|
|
2054
|
+
s0 = peg$parseseparators();
|
|
2055
|
+
if (s0 === peg$FAILED) {
|
|
2056
|
+
s0 = peg$parsesymbols();
|
|
2057
|
+
if (s0 === peg$FAILED) {
|
|
2058
|
+
s0 = peg$parseothers();
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
return s0;
|
|
2066
|
+
}
|
|
2067
|
+
function peg$parseletters() {
|
|
2068
|
+
var s0, s1, s2;
|
|
2069
|
+
s0 = peg$currPos;
|
|
2070
|
+
if (input.charCodeAt(peg$currPos) === 76) {
|
|
2071
|
+
s1 = peg$c14;
|
|
2072
|
+
peg$currPos++;
|
|
2073
|
+
} else {
|
|
2074
|
+
s1 = peg$FAILED;
|
|
2075
|
+
if (peg$silentFails === 0) {
|
|
2076
|
+
peg$fail(peg$e18);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
if (s1 !== peg$FAILED) {
|
|
2080
|
+
s2 = input.charAt(peg$currPos);
|
|
2081
|
+
if (peg$r3.test(s2)) {
|
|
2082
|
+
peg$currPos++;
|
|
2083
|
+
} else {
|
|
2084
|
+
s2 = peg$FAILED;
|
|
2085
|
+
if (peg$silentFails === 0) {
|
|
2086
|
+
peg$fail(peg$e19);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
if (s2 === peg$FAILED) {
|
|
2090
|
+
s2 = null;
|
|
2091
|
+
}
|
|
2092
|
+
s1 = [s1, s2];
|
|
2093
|
+
s0 = s1;
|
|
2094
|
+
} else {
|
|
2095
|
+
peg$currPos = s0;
|
|
2096
|
+
s0 = peg$FAILED;
|
|
2097
|
+
}
|
|
2098
|
+
return s0;
|
|
2099
|
+
}
|
|
2100
|
+
function peg$parsemarks() {
|
|
2101
|
+
var s0, s1, s2;
|
|
2102
|
+
s0 = peg$currPos;
|
|
2103
|
+
if (input.charCodeAt(peg$currPos) === 77) {
|
|
2104
|
+
s1 = peg$c15;
|
|
2105
|
+
peg$currPos++;
|
|
2106
|
+
} else {
|
|
2107
|
+
s1 = peg$FAILED;
|
|
2108
|
+
if (peg$silentFails === 0) {
|
|
2109
|
+
peg$fail(peg$e20);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
if (s1 !== peg$FAILED) {
|
|
2113
|
+
s2 = input.charAt(peg$currPos);
|
|
2114
|
+
if (peg$r4.test(s2)) {
|
|
2115
|
+
peg$currPos++;
|
|
2116
|
+
} else {
|
|
2117
|
+
s2 = peg$FAILED;
|
|
2118
|
+
if (peg$silentFails === 0) {
|
|
2119
|
+
peg$fail(peg$e21);
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (s2 === peg$FAILED) {
|
|
2123
|
+
s2 = null;
|
|
2124
|
+
}
|
|
2125
|
+
s1 = [s1, s2];
|
|
2126
|
+
s0 = s1;
|
|
2127
|
+
} else {
|
|
2128
|
+
peg$currPos = s0;
|
|
2129
|
+
s0 = peg$FAILED;
|
|
2130
|
+
}
|
|
2131
|
+
return s0;
|
|
2132
|
+
}
|
|
2133
|
+
function peg$parsenumbers() {
|
|
2134
|
+
var s0, s1, s2;
|
|
2135
|
+
s0 = peg$currPos;
|
|
2136
|
+
if (input.charCodeAt(peg$currPos) === 78) {
|
|
2137
|
+
s1 = peg$c16;
|
|
2138
|
+
peg$currPos++;
|
|
2139
|
+
} else {
|
|
2140
|
+
s1 = peg$FAILED;
|
|
2141
|
+
if (peg$silentFails === 0) {
|
|
2142
|
+
peg$fail(peg$e22);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
if (s1 !== peg$FAILED) {
|
|
2146
|
+
s2 = input.charAt(peg$currPos);
|
|
2147
|
+
if (peg$r5.test(s2)) {
|
|
2148
|
+
peg$currPos++;
|
|
2149
|
+
} else {
|
|
2150
|
+
s2 = peg$FAILED;
|
|
2151
|
+
if (peg$silentFails === 0) {
|
|
2152
|
+
peg$fail(peg$e23);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
if (s2 === peg$FAILED) {
|
|
2156
|
+
s2 = null;
|
|
2157
|
+
}
|
|
2158
|
+
s1 = [s1, s2];
|
|
2159
|
+
s0 = s1;
|
|
2160
|
+
} else {
|
|
2161
|
+
peg$currPos = s0;
|
|
2162
|
+
s0 = peg$FAILED;
|
|
2163
|
+
}
|
|
2164
|
+
return s0;
|
|
2165
|
+
}
|
|
2166
|
+
function peg$parsepunctuation() {
|
|
2167
|
+
var s0, s1, s2;
|
|
2168
|
+
s0 = peg$currPos;
|
|
2169
|
+
if (input.charCodeAt(peg$currPos) === 80) {
|
|
2170
|
+
s1 = peg$c17;
|
|
2171
|
+
peg$currPos++;
|
|
2172
|
+
} else {
|
|
2173
|
+
s1 = peg$FAILED;
|
|
2174
|
+
if (peg$silentFails === 0) {
|
|
2175
|
+
peg$fail(peg$e24);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
if (s1 !== peg$FAILED) {
|
|
2179
|
+
s2 = input.charAt(peg$currPos);
|
|
2180
|
+
if (peg$r6.test(s2)) {
|
|
2181
|
+
peg$currPos++;
|
|
2182
|
+
} else {
|
|
2183
|
+
s2 = peg$FAILED;
|
|
2184
|
+
if (peg$silentFails === 0) {
|
|
2185
|
+
peg$fail(peg$e25);
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
if (s2 === peg$FAILED) {
|
|
2189
|
+
s2 = null;
|
|
2190
|
+
}
|
|
2191
|
+
s1 = [s1, s2];
|
|
2192
|
+
s0 = s1;
|
|
2193
|
+
} else {
|
|
2194
|
+
peg$currPos = s0;
|
|
2195
|
+
s0 = peg$FAILED;
|
|
2196
|
+
}
|
|
2197
|
+
return s0;
|
|
2198
|
+
}
|
|
2199
|
+
function peg$parseseparators() {
|
|
2200
|
+
var s0, s1, s2;
|
|
2201
|
+
s0 = peg$currPos;
|
|
2202
|
+
if (input.charCodeAt(peg$currPos) === 90) {
|
|
2203
|
+
s1 = peg$c18;
|
|
2204
|
+
peg$currPos++;
|
|
2205
|
+
} else {
|
|
2206
|
+
s1 = peg$FAILED;
|
|
2207
|
+
if (peg$silentFails === 0) {
|
|
2208
|
+
peg$fail(peg$e26);
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
if (s1 !== peg$FAILED) {
|
|
2212
|
+
s2 = input.charAt(peg$currPos);
|
|
2213
|
+
if (peg$r7.test(s2)) {
|
|
2214
|
+
peg$currPos++;
|
|
2215
|
+
} else {
|
|
2216
|
+
s2 = peg$FAILED;
|
|
2217
|
+
if (peg$silentFails === 0) {
|
|
2218
|
+
peg$fail(peg$e27);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
if (s2 === peg$FAILED) {
|
|
2222
|
+
s2 = null;
|
|
2223
|
+
}
|
|
2224
|
+
s1 = [s1, s2];
|
|
2225
|
+
s0 = s1;
|
|
2226
|
+
} else {
|
|
2227
|
+
peg$currPos = s0;
|
|
2228
|
+
s0 = peg$FAILED;
|
|
2229
|
+
}
|
|
2230
|
+
return s0;
|
|
2231
|
+
}
|
|
2232
|
+
function peg$parsesymbols() {
|
|
2233
|
+
var s0, s1, s2;
|
|
2234
|
+
s0 = peg$currPos;
|
|
2235
|
+
if (input.charCodeAt(peg$currPos) === 83) {
|
|
2236
|
+
s1 = peg$c19;
|
|
2237
|
+
peg$currPos++;
|
|
2238
|
+
} else {
|
|
2239
|
+
s1 = peg$FAILED;
|
|
2240
|
+
if (peg$silentFails === 0) {
|
|
2241
|
+
peg$fail(peg$e28);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
if (s1 !== peg$FAILED) {
|
|
2245
|
+
s2 = input.charAt(peg$currPos);
|
|
2246
|
+
if (peg$r8.test(s2)) {
|
|
2247
|
+
peg$currPos++;
|
|
2248
|
+
} else {
|
|
2249
|
+
s2 = peg$FAILED;
|
|
2250
|
+
if (peg$silentFails === 0) {
|
|
2251
|
+
peg$fail(peg$e29);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
if (s2 === peg$FAILED) {
|
|
2255
|
+
s2 = null;
|
|
2256
|
+
}
|
|
2257
|
+
s1 = [s1, s2];
|
|
2258
|
+
s0 = s1;
|
|
2259
|
+
} else {
|
|
2260
|
+
peg$currPos = s0;
|
|
2261
|
+
s0 = peg$FAILED;
|
|
2262
|
+
}
|
|
2263
|
+
return s0;
|
|
2264
|
+
}
|
|
2265
|
+
function peg$parseothers() {
|
|
2266
|
+
var s0, s1, s2;
|
|
2267
|
+
s0 = peg$currPos;
|
|
2268
|
+
if (input.charCodeAt(peg$currPos) === 67) {
|
|
2269
|
+
s1 = peg$c20;
|
|
2270
|
+
peg$currPos++;
|
|
2271
|
+
} else {
|
|
2272
|
+
s1 = peg$FAILED;
|
|
2273
|
+
if (peg$silentFails === 0) {
|
|
2274
|
+
peg$fail(peg$e30);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
if (s1 !== peg$FAILED) {
|
|
2278
|
+
s2 = input.charAt(peg$currPos);
|
|
2279
|
+
if (peg$r9.test(s2)) {
|
|
2280
|
+
peg$currPos++;
|
|
2281
|
+
} else {
|
|
2282
|
+
s2 = peg$FAILED;
|
|
2283
|
+
if (peg$silentFails === 0) {
|
|
2284
|
+
peg$fail(peg$e31);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
if (s2 === peg$FAILED) {
|
|
2288
|
+
s2 = null;
|
|
2289
|
+
}
|
|
2290
|
+
s1 = [s1, s2];
|
|
2291
|
+
s0 = s1;
|
|
2292
|
+
} else {
|
|
2293
|
+
peg$currPos = s0;
|
|
2294
|
+
s0 = peg$FAILED;
|
|
2295
|
+
}
|
|
2296
|
+
return s0;
|
|
2297
|
+
}
|
|
2298
|
+
peg$result = peg$startRuleFunction();
|
|
2299
|
+
if (options.peg$library) {
|
|
2300
|
+
return /** @type {any} */{
|
|
2301
|
+
peg$result,
|
|
2302
|
+
peg$currPos,
|
|
2303
|
+
peg$FAILED,
|
|
2304
|
+
peg$maxFailExpected,
|
|
2305
|
+
peg$maxFailPos
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
2309
|
+
return peg$result;
|
|
2310
|
+
} else {
|
|
2311
|
+
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
2312
|
+
peg$fail(peg$endExpectation());
|
|
2313
|
+
}
|
|
2314
|
+
throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
var iregexp$1 = {
|
|
2318
|
+
StartRules: ["start"],
|
|
2319
|
+
SyntaxError: peg$SyntaxError,
|
|
2320
|
+
parse: peg$parse
|
|
2321
|
+
};
|
|
2322
|
+
|
|
2323
|
+
const iregexp = iregexp$1;
|
|
2324
|
+
|
|
2325
|
+
/**
|
|
2326
|
+
* Return _true_ if _pattern_ is a valid I-Regexp
|
|
2327
|
+
* @param {string} pattern - Regular expression pattern to check.
|
|
2328
|
+
* @returns true if _pattern_ is valid, or false otherwise.
|
|
2329
|
+
*/
|
|
2330
|
+
function check(pattern) {
|
|
2331
|
+
try {
|
|
2332
|
+
iregexp.parse(pattern, {});
|
|
2333
|
+
} catch (error) {
|
|
2334
|
+
if (error instanceof iregexp.SyntaxError) {
|
|
2335
|
+
return false;
|
|
2336
|
+
}
|
|
2337
|
+
throw error;
|
|
2338
|
+
}
|
|
2339
|
+
return true;
|
|
2340
|
+
}
|
|
2341
|
+
var check_1 = {
|
|
2342
|
+
check
|
|
2343
|
+
};
|
|
2344
|
+
|
|
2345
|
+
var check$1 = check_1.check;
|
|
2346
|
+
|
|
1086
2347
|
class Match {
|
|
1087
2348
|
argTypes = [FunctionExpressionType.ValueType, FunctionExpressionType.ValueType];
|
|
1088
2349
|
returnType = FunctionExpressionType.LogicalType;
|
|
@@ -1092,8 +2353,11 @@ var json_p3 = (function (exports) {
|
|
|
1092
2353
|
this.options = options;
|
|
1093
2354
|
this.cacheSize = options.cacheSize ?? 10;
|
|
1094
2355
|
this.throwErrors = options.throwErrors ?? false;
|
|
2356
|
+
this.iRegexpCheck = options.iRegexpCheck ?? true;
|
|
1095
2357
|
this.#cache = new LRUCache(this.cacheSize);
|
|
1096
2358
|
}
|
|
2359
|
+
|
|
2360
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
1097
2361
|
call(s, pattern) {
|
|
1098
2362
|
if (this.cacheSize > 0) {
|
|
1099
2363
|
const re = this.#cache.get(pattern);
|
|
@@ -1106,6 +2370,18 @@ var json_p3 = (function (exports) {
|
|
|
1106
2370
|
}
|
|
1107
2371
|
}
|
|
1108
2372
|
}
|
|
2373
|
+
if (!isString(pattern)) {
|
|
2374
|
+
if (this.throwErrors) {
|
|
2375
|
+
throw new IRegexpError(`match() expected a string pattern, found ${pattern}`);
|
|
2376
|
+
}
|
|
2377
|
+
return false;
|
|
2378
|
+
}
|
|
2379
|
+
if (this.iRegexpCheck && !check$1(pattern)) {
|
|
2380
|
+
if (this.throwErrors) {
|
|
2381
|
+
throw new IRegexpError(`pattern ${pattern} is not a valid I-Regexp pattern`);
|
|
2382
|
+
}
|
|
2383
|
+
return false;
|
|
2384
|
+
}
|
|
1109
2385
|
try {
|
|
1110
2386
|
const re = new RegExp(this.fullMatch(pattern), "u");
|
|
1111
2387
|
if (this.cacheSize > 0) this.#cache.set(pattern, re);
|
|
@@ -1117,53 +2393,11 @@ var json_p3 = (function (exports) {
|
|
|
1117
2393
|
}
|
|
1118
2394
|
fullMatch(pattern) {
|
|
1119
2395
|
const parts = [];
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
parts.push(this.mapRegexp(pattern));
|
|
1126
|
-
if (nonCaptureGroup && !pattern.endsWith("$") && !pattern.endsWith(")$")) {
|
|
1127
|
-
parts.push(")$");
|
|
1128
|
-
}
|
|
1129
|
-
return parts.join("");
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
// See https://datatracker.ietf.org/doc/html/rfc9485#name-ecmascript-regexps
|
|
1133
|
-
mapRegexp(pattern) {
|
|
1134
|
-
let escaped = false;
|
|
1135
|
-
let charClass = false;
|
|
1136
|
-
const parts = [];
|
|
1137
|
-
for (const ch of pattern) {
|
|
1138
|
-
switch (ch) {
|
|
1139
|
-
case ".":
|
|
1140
|
-
if (!escaped && !charClass) {
|
|
1141
|
-
parts.push("(?:(?![\r\n])\\P{Cs}|\\p{Cs}\\p{Cs})");
|
|
1142
|
-
} else {
|
|
1143
|
-
parts.push(ch);
|
|
1144
|
-
escaped = false;
|
|
1145
|
-
}
|
|
1146
|
-
break;
|
|
1147
|
-
case "\\":
|
|
1148
|
-
escaped = true;
|
|
1149
|
-
parts.push(ch);
|
|
1150
|
-
break;
|
|
1151
|
-
case "[":
|
|
1152
|
-
charClass = true;
|
|
1153
|
-
escaped = false;
|
|
1154
|
-
parts.push(ch);
|
|
1155
|
-
break;
|
|
1156
|
-
case "]":
|
|
1157
|
-
charClass = false;
|
|
1158
|
-
escaped = false;
|
|
1159
|
-
parts.push(ch);
|
|
1160
|
-
break;
|
|
1161
|
-
default:
|
|
1162
|
-
escaped = false;
|
|
1163
|
-
parts.push(ch);
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
2396
|
+
const explicitCaret = pattern.startsWith("^");
|
|
2397
|
+
const explicitDollar = pattern.endsWith("$");
|
|
2398
|
+
if (!explicitCaret && !explicitDollar) parts.push("^(?:");
|
|
2399
|
+
parts.push(mapRegexp(pattern));
|
|
2400
|
+
if (!explicitCaret && !explicitDollar) parts.push(")$");
|
|
1167
2401
|
return parts.join("");
|
|
1168
2402
|
}
|
|
1169
2403
|
}
|
|
@@ -1177,8 +2411,11 @@ var json_p3 = (function (exports) {
|
|
|
1177
2411
|
this.options = options;
|
|
1178
2412
|
this.cacheSize = options.cacheSize ?? 10;
|
|
1179
2413
|
this.throwErrors = options.throwErrors ?? false;
|
|
2414
|
+
this.iRegexpCheck = options.iRegexpCheck ?? true;
|
|
1180
2415
|
this.#cache = new LRUCache(this.cacheSize);
|
|
1181
2416
|
}
|
|
2417
|
+
|
|
2418
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
1182
2419
|
call(s, pattern) {
|
|
1183
2420
|
if (this.cacheSize > 0) {
|
|
1184
2421
|
const re = this.#cache.get(pattern);
|
|
@@ -1191,8 +2428,20 @@ var json_p3 = (function (exports) {
|
|
|
1191
2428
|
}
|
|
1192
2429
|
}
|
|
1193
2430
|
}
|
|
2431
|
+
if (!isString(pattern)) {
|
|
2432
|
+
if (this.throwErrors) {
|
|
2433
|
+
throw new IRegexpError(`match() expected a string pattern, found ${pattern}`);
|
|
2434
|
+
}
|
|
2435
|
+
return false;
|
|
2436
|
+
}
|
|
2437
|
+
if (this.iRegexpCheck && !check$1(pattern)) {
|
|
2438
|
+
if (this.throwErrors) {
|
|
2439
|
+
throw new IRegexpError(`pattern ${pattern} is not a valid I-Regexp pattern`);
|
|
2440
|
+
}
|
|
2441
|
+
return false;
|
|
2442
|
+
}
|
|
1194
2443
|
try {
|
|
1195
|
-
const re = new RegExp(
|
|
2444
|
+
const re = new RegExp(mapRegexp(pattern), "u");
|
|
1196
2445
|
if (this.cacheSize > 0) this.#cache.set(pattern, re);
|
|
1197
2446
|
return !!s.match(re);
|
|
1198
2447
|
} catch (error) {
|
|
@@ -1200,44 +2449,6 @@ var json_p3 = (function (exports) {
|
|
|
1200
2449
|
return false;
|
|
1201
2450
|
}
|
|
1202
2451
|
}
|
|
1203
|
-
|
|
1204
|
-
// See https://datatracker.ietf.org/doc/html/rfc9485#name-ecmascript-regexps
|
|
1205
|
-
mapRegexp(pattern) {
|
|
1206
|
-
let escaped = false;
|
|
1207
|
-
let charClass = false;
|
|
1208
|
-
const parts = [];
|
|
1209
|
-
for (const ch of pattern) {
|
|
1210
|
-
switch (ch) {
|
|
1211
|
-
case ".":
|
|
1212
|
-
if (!escaped && !charClass) {
|
|
1213
|
-
parts.push("(?:(?![\r\n])\\P{Cs}|\\p{Cs}\\p{Cs})");
|
|
1214
|
-
} else {
|
|
1215
|
-
parts.push(ch);
|
|
1216
|
-
escaped = false;
|
|
1217
|
-
}
|
|
1218
|
-
break;
|
|
1219
|
-
case "\\":
|
|
1220
|
-
escaped = true;
|
|
1221
|
-
parts.push(ch);
|
|
1222
|
-
break;
|
|
1223
|
-
case "[":
|
|
1224
|
-
charClass = true;
|
|
1225
|
-
escaped = false;
|
|
1226
|
-
parts.push(ch);
|
|
1227
|
-
break;
|
|
1228
|
-
case "]":
|
|
1229
|
-
charClass = false;
|
|
1230
|
-
escaped = false;
|
|
1231
|
-
parts.push(ch);
|
|
1232
|
-
break;
|
|
1233
|
-
default:
|
|
1234
|
-
escaped = false;
|
|
1235
|
-
parts.push(ch);
|
|
1236
|
-
break;
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
return parts.join("");
|
|
1240
|
-
}
|
|
1241
2452
|
}
|
|
1242
2453
|
|
|
1243
2454
|
class Value {
|
|
@@ -3767,7 +4978,7 @@ var json_p3 = (function (exports) {
|
|
|
3767
4978
|
apply: apply
|
|
3768
4979
|
});
|
|
3769
4980
|
|
|
3770
|
-
const version = "1.3.
|
|
4981
|
+
const version = "1.3.2";
|
|
3771
4982
|
|
|
3772
4983
|
exports.DEFAULT_ENVIRONMENT = DEFAULT_ENVIRONMENT;
|
|
3773
4984
|
exports.FunctionExpressionType = FunctionExpressionType;
|