167 lines
10 KiB
JavaScript
167 lines
10 KiB
JavaScript
|
var $hlrUL$lezercommon = require("@lezer/common");
|
||
|
var $hlrUL$json5 = require("json5");
|
||
|
var $hlrUL$lezerlr = require("@lezer/lr");
|
||
|
|
||
|
function $parcel$interopDefault(a) {
|
||
|
return a && a.__esModule ? a.default : a;
|
||
|
}
|
||
|
function $parcel$export(e, n, v, s) {
|
||
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
||
|
}
|
||
|
|
||
|
$parcel$export(module.exports, "parse", () => $83c796b2b9543406$export$98e6a39c04603d36);
|
||
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||
|
|
||
|
const $1adaef8fb7bb1497$export$8f49e4af10703ce3 = (0, $hlrUL$lezerlr.LRParser).deserialize({
|
||
|
version: 14,
|
||
|
states: "%QO]QPOOOOQO'#Cd'#CdOtQQO'#CgO!PQPO'#ClOOQO'#Cs'#CsQOQPOOOOQO'#Ci'#CiO!WQPO'#ChO!]QPO'#CuOOQO,59R,59RO!eQPO,59ROOQO'#Cm'#CmO!jQPO'#CyOOQO,59W,59WO!rQPO,59WO]QPO,59SO!wQQO,59aO#SQPO,59aOOQO1G.m1G.mO#[QPO,59eO#cQPO,59eOOQO1G.r1G.rOOQO1G.n1G.nOOQO,59Y,59YO#kQQO1G.{OOQO-E6l-E6lOOQO,59Z,59ZO#vQPO1G/POOQO-E6m-E6mPwQQO'#CnP]QPO'#Co",
|
||
|
stateData: "$R~OfOSPOSQOS~OSSOTSOUSOVSOYQO_ROhPO~OXXOhUOjUO~O^]O~P]Ok_O~Ol`OXiX~OXbO~OlcO^mX~O^eO~OhUOjUOXia~OlhOXia~O^ma~P]OlkO^ma~OhUOjUOXii~O^mi~P]OPQj~",
|
||
|
goto: "!}nPPPPPPPPoPPow!PPPo!V!_!ePPP!kP!wPPP!z]SOR_cknQWQVg`hmXVQ`hmQ[RVjcknQaWRiaQd[RldQTOWZRcknRf_RYQR^R",
|
||
|
nodeNames: "⚠ LineComment BlockComment JsonText True False Null Number String } { Object Property PropertyName ] [ Array ArrayValue",
|
||
|
maxTerm: 29,
|
||
|
nodeProps: [
|
||
|
[
|
||
|
"group",
|
||
|
-7,
|
||
|
4,
|
||
|
5,
|
||
|
6,
|
||
|
7,
|
||
|
8,
|
||
|
11,
|
||
|
16,
|
||
|
"Value"
|
||
|
],
|
||
|
[
|
||
|
"openedBy",
|
||
|
9,
|
||
|
"{",
|
||
|
14,
|
||
|
"["
|
||
|
],
|
||
|
[
|
||
|
"closedBy",
|
||
|
10,
|
||
|
"}",
|
||
|
15,
|
||
|
"]"
|
||
|
]
|
||
|
],
|
||
|
skippedNodes: [
|
||
|
0,
|
||
|
1,
|
||
|
2
|
||
|
],
|
||
|
repeatNodeCount: 2,
|
||
|
tokenData: "!!`~R!OXY$RYZ$RZ[$R[]$R]^$Rpq$Rrs$Wtu.Xwx0b{|2Y|}6p}!O2Y!O!P2l!P!Q6u!Q!R3l!R![5Q![!]8t!c!k.X!k!l8y!l!p.X!p!q@}!q!}.X!}#OB|#O#P/S#P#QCR#R#S.X#T#Y.X#Y#ZCW#Z#b.X#b#cHU#c#h.X#h#iLU#i#o.X#o#p!!U#q#r!!Z$f$g$R$g$IV.X$IV$IW$R$IW$I|.X$I|$I}$R$I}$JO$R$JU;'S.X;'S;=`0[<%l?HT.X?HT?HU$R?HUO.X~$WOf~~$ZXOp$vpq$Wqr$Wrs%`s#O$W#O#P&s#P;'S$W;'S;=`.R<%lO$W~$yVOr$vrs%`s#O$v#O#P%e#P;'S$v;'S;=`&m<%lO$v~%eOh~~%haYZ$v]^$vrs$vwx$v!Q!R$v#O#P$v#T#U$v#U#V$v#Y#Z$v#b#c$v#f#g$v#h#i$v#i#j$v#j#k$v#l#m$v$I|$I}$v$I}$JO$v~&pP;=`<%l$v~&vbYZ$v]^$vrs$Wwx$v!P!Q(O!Q!R$v#O#P$W#T#U$v#U#V$W#Y#Z$W#b#c$W#f#g$W#h#i$W#i#j*c#j#k$v#l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.X#`#aJW#a#o.X$g$IV.X$IW$I|.X$JU;'S.X;'S;=`0[<%l?HT.X?HUO.XRJ]^jQtu.X!Q![.X!c!}.X#O#P/S#R#S.X#T#`.X#`#aKX#a#o.X$g$IV.X$IW$I|.X$JU;'S.X;'S;=`0[<%l?HT.X?HUO.XRK`[UPjQtu.X!Q![.X!c!}.X#O#P/S#R#S.X#T#o.X$g$IV.X$IW$I|.X$JU;'S.X;'S;=`0[<%l?HT.X?HUO.XRLZ^jQtu.X!Q![.X!c!}.X#O#P/S#R#S.X#T#f.X#f#gMV#g#o.X$g$IV.X$IW$I|.X$JU;'S.X;'S;=`0[<%l?HT.X?HUO.XRM[^jQtu.X!Q![.X!c!}.X#O#P/S#R#S.X#T#i.X#i#jNW#j#o.X$g$IV.X$IW$I|.X$JU;'S.X;'S;=`0[<%l?HT.X?HUO.XRN]^jQtu.X!Q![.X!c!}.X#O#P/S#R#S.X#T#X.X#X#Y! X#Y
|
||
|
tokenizers: [
|
||
|
0,
|
||
|
1
|
||
|
],
|
||
|
topRules: {
|
||
|
"JsonText": [
|
||
|
0,
|
||
|
3
|
||
|
]
|
||
|
},
|
||
|
dialects: {
|
||
|
json5: 137
|
||
|
},
|
||
|
tokenPrec: 0
|
||
|
});
|
||
|
|
||
|
|
||
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||
|
const $121152950f502dea$export$e6476262d0d4122e = 1, $121152950f502dea$export$33c356ab5b93be35 = 2, $121152950f502dea$export$8bc1c2b4dd1e923b = 3, $121152950f502dea$export$4bc0976997a4d94e = 4, $121152950f502dea$export$5d3e9aafef2fffbe = 5, $121152950f502dea$export$26c9c3a80cd996ae = 6, $121152950f502dea$export$fffa67e515d04022 = 7, $121152950f502dea$export$89b8e0fa65f6a914 = 8, $121152950f502dea$export$164a3ab98abb171d = 11, $121152950f502dea$export$41b04b3a73e7216d = 12, $121152950f502dea$export$e546d8cfcc0684e2 = 13, $121152950f502dea$export$c4be6576ca6fe4aa = 16, $121152950f502dea$export$f06b0ce79fd44095 = 17, $121152950f502dea$export$386a487b17ea4d92 = 0;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
function $83c796b2b9543406$export$98e6a39c04603d36(input, reviver, { dialect: dialect = "json" , tabWidth: tabWidth = 4 } = {}) {
|
||
|
// Let these parsers throw any errors about invalid input
|
||
|
let data = dialect === "JSON5" ? (0, ($parcel$interopDefault($hlrUL$json5))).parse(input, reviver) : JSON.parse(input, reviver);
|
||
|
let tree = (0, $1adaef8fb7bb1497$export$8f49e4af10703ce3).configure({
|
||
|
strict: true,
|
||
|
dialect: dialect === "JSON5" ? "json5" : "json"
|
||
|
}).parse(input);
|
||
|
let pointers = new Map();
|
||
|
let currentPath = [
|
||
|
""
|
||
|
];
|
||
|
tree.iterate({
|
||
|
enter (node) {
|
||
|
// if (type.isError) {
|
||
|
// let fromPos = posToLineColumn(input, from, tabWidth);
|
||
|
// let error = new SyntaxError(
|
||
|
// `Failed to parse (${fromPos.line}:${fromPos.column})`
|
||
|
// );
|
||
|
// error.lineNumber = fromPos.line;
|
||
|
// error.columnNumber = fromPos.column;
|
||
|
// throw error;
|
||
|
// }
|
||
|
let group = node.type.prop((0, $hlrUL$lezercommon.NodeProp).group);
|
||
|
if (group === null || group === void 0 ? void 0 : group.includes("Value")) $83c796b2b9543406$var$mapMerge(pointers, $83c796b2b9543406$var$toJsonPointer(currentPath), {
|
||
|
value: $83c796b2b9543406$var$posToLineColumn(input, node.from, tabWidth),
|
||
|
valueEnd: $83c796b2b9543406$var$posToLineColumn(input, node.to, tabWidth)
|
||
|
});
|
||
|
if (node.name === "PropertyName") {
|
||
|
let name = input.slice(node.from, node.to);
|
||
|
let quoted = name[0] === `'` || name[0] == `"`;
|
||
|
currentPath.push(quoted ? name.slice(1, -1) : name);
|
||
|
$83c796b2b9543406$var$mapMerge(pointers, $83c796b2b9543406$var$toJsonPointer(currentPath), {
|
||
|
key: $83c796b2b9543406$var$posToLineColumn(input, node.from, tabWidth),
|
||
|
keyEnd: $83c796b2b9543406$var$posToLineColumn(input, node.to, tabWidth)
|
||
|
});
|
||
|
} else if (node.name === "Array") currentPath.push(0);
|
||
|
},
|
||
|
leave (node) {
|
||
|
if (node.name === "Property" || node.name === "Array") currentPath.pop();
|
||
|
else if (node.name === "ArrayValue") // @ts-ignore
|
||
|
currentPath[currentPath.length - 1]++;
|
||
|
}
|
||
|
});
|
||
|
return {
|
||
|
data: data,
|
||
|
pointers: Object.fromEntries(pointers)
|
||
|
};
|
||
|
}
|
||
|
function $83c796b2b9543406$var$mapMerge(map, key, data) {
|
||
|
let value = map.get(key);
|
||
|
value = {
|
||
|
...value,
|
||
|
...data
|
||
|
};
|
||
|
map.set(key, value);
|
||
|
}
|
||
|
function $83c796b2b9543406$var$posToLineColumn(input, pos, tabWidth) {
|
||
|
let line = $83c796b2b9543406$var$countNewLines(input, pos);
|
||
|
let lineStart = input.lastIndexOf("\n", pos - 1) + 1;
|
||
|
let column = $83c796b2b9543406$var$countColumn(input, lineStart, pos, tabWidth);
|
||
|
return {
|
||
|
line: line,
|
||
|
column: column,
|
||
|
pos: pos
|
||
|
};
|
||
|
}
|
||
|
function $83c796b2b9543406$var$countNewLines(str, end) {
|
||
|
let count = 0;
|
||
|
for(let i = 0; i < end; i++)if (str[i] === "\n") count++;
|
||
|
return count;
|
||
|
}
|
||
|
function $83c796b2b9543406$var$countColumn(str, start, end, tabWidth) {
|
||
|
let count = 0;
|
||
|
for(let i = start; i < end; i++)count += str[i] === " " ? tabWidth : 1;
|
||
|
return count;
|
||
|
}
|
||
|
const $83c796b2b9543406$var$ESCAPE_REGEX = /[~/]/g;
|
||
|
function $83c796b2b9543406$var$toJsonPointer(path) {
|
||
|
let str = "";
|
||
|
for (let e of path)if (typeof e === "string") str += e.replace($83c796b2b9543406$var$ESCAPE_REGEX, (v)=>v === "~" ? "~0" : "~1") + "/";
|
||
|
else str += String(e) + "/";
|
||
|
return str.slice(0, -1);
|
||
|
}
|
||
|
|
||
|
|