@player-ui/async-node-plugin 0.7.5--canary.432.14776 → 0.7.5--canary.434.14940
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/AsyncNodePlugin.native.js +3748 -131
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/package.json +2 -2
|
@@ -453,8 +453,8 @@ var AsyncNodePlugin = function() {
|
|
|
453
453
|
try {
|
|
454
454
|
for(var _iterator = Array.from(pairs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
455
455
|
var entry = _step.value;
|
|
456
|
-
var _entry = _sliced_to_array(entry, 2),
|
|
457
|
-
if (dlv_es_default(searchObj,
|
|
456
|
+
var _entry = _sliced_to_array(entry, 2), path2 = _entry[0], value = _entry[1];
|
|
457
|
+
if (dlv_es_default(searchObj, path2) !== value) {
|
|
458
458
|
return false;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
@@ -1030,17 +1030,17 @@ var AsyncNodePlugin = function() {
|
|
|
1030
1030
|
break;
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
|
-
var
|
|
1034
|
-
if (Object.prototype.hasOwnProperty.call(literals,
|
|
1033
|
+
var identifier2 = expr.slice(start, index);
|
|
1034
|
+
if (Object.prototype.hasOwnProperty.call(literals, identifier2)) {
|
|
1035
1035
|
return {
|
|
1036
1036
|
__id: ExpNodeOpaqueIdentifier,
|
|
1037
1037
|
type: "Literal",
|
|
1038
|
-
value: literals[
|
|
1039
|
-
raw:
|
|
1038
|
+
value: literals[identifier2],
|
|
1039
|
+
raw: identifier2,
|
|
1040
1040
|
location: getLocation(start)
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
|
-
if (
|
|
1043
|
+
if (identifier2 === thisStr) {
|
|
1044
1044
|
return {
|
|
1045
1045
|
__id: ExpNodeOpaqueIdentifier,
|
|
1046
1046
|
type: "ThisExpression",
|
|
@@ -1050,7 +1050,7 @@ var AsyncNodePlugin = function() {
|
|
|
1050
1050
|
return {
|
|
1051
1051
|
__id: ExpNodeOpaqueIdentifier,
|
|
1052
1052
|
type: "Identifier",
|
|
1053
|
-
name:
|
|
1053
|
+
name: identifier2,
|
|
1054
1054
|
location: getLocation(start)
|
|
1055
1055
|
};
|
|
1056
1056
|
}
|
|
@@ -1190,19 +1190,19 @@ var AsyncNodePlugin = function() {
|
|
|
1190
1190
|
}
|
|
1191
1191
|
return typeof expr === "object" && expr !== null && !Array.isArray(expr) && "value" in expr;
|
|
1192
1192
|
};
|
|
1193
|
-
var
|
|
1193
|
+
var parse4 = function parse4(schema) {
|
|
1194
1194
|
var _loop = function() {
|
|
1195
1195
|
var next = parseQueue.shift();
|
|
1196
1196
|
if (!next) {
|
|
1197
1197
|
return "break";
|
|
1198
1198
|
}
|
|
1199
|
-
var node = next.node,
|
|
1199
|
+
var node = next.node, path2 = next.path, visited = next.visited;
|
|
1200
1200
|
Object.entries(node).forEach(function(param) {
|
|
1201
1201
|
var _param = _sliced_to_array(param, 2), prop = _param[0], type = _param[1];
|
|
1202
|
-
var
|
|
1202
|
+
var nestedPath2 = _to_consumable_array(path2).concat([
|
|
1203
1203
|
prop
|
|
1204
1204
|
]);
|
|
1205
|
-
var nestedPathStr =
|
|
1205
|
+
var nestedPathStr = nestedPath2.join(".");
|
|
1206
1206
|
if (expandedPaths.has(nestedPathStr)) {
|
|
1207
1207
|
throw new Error("Path has already been processed. There's either a loop somewhere or a bug");
|
|
1208
1208
|
}
|
|
@@ -1211,14 +1211,14 @@ var AsyncNodePlugin = function() {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
expandedPaths.set(nestedPathStr, type);
|
|
1213
1213
|
if (type.isArray) {
|
|
1214
|
-
|
|
1214
|
+
nestedPath2.push("[]");
|
|
1215
1215
|
}
|
|
1216
1216
|
if (type.isRecord) {
|
|
1217
|
-
|
|
1217
|
+
nestedPath2.push("{}");
|
|
1218
1218
|
}
|
|
1219
1219
|
if (type.type && schema[type.type]) {
|
|
1220
1220
|
parseQueue.push({
|
|
1221
|
-
path:
|
|
1221
|
+
path: nestedPath2,
|
|
1222
1222
|
node: schema[type.type],
|
|
1223
1223
|
visited: /* @__PURE__ */ new Set(_to_consumable_array(visited).concat([
|
|
1224
1224
|
type.type
|
|
@@ -1444,7 +1444,7 @@ var AsyncNodePlugin = function() {
|
|
|
1444
1444
|
};
|
|
1445
1445
|
};
|
|
1446
1446
|
var objectToBatchSet = function objectToBatchSet(obj) {
|
|
1447
|
-
var flattenedObj =
|
|
1447
|
+
var flattenedObj = flatten2(obj);
|
|
1448
1448
|
var batchTxn = [];
|
|
1449
1449
|
Object.keys(flattenedObj).forEach(function(key) {
|
|
1450
1450
|
batchTxn.push([
|
|
@@ -1622,6 +1622,3588 @@ var AsyncNodePlugin = function() {
|
|
|
1622
1622
|
exports.toError = toError;
|
|
1623
1623
|
}
|
|
1624
1624
|
});
|
|
1625
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/arr-flatten@1.1.0/node_modules/arr-flatten/index.js
|
|
1626
|
+
var require_arr_flatten = __commonJS({
|
|
1627
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/arr-flatten@1.1.0/node_modules/arr-flatten/index.js": function(exports, module) {
|
|
1628
|
+
"use strict";
|
|
1629
|
+
module.exports = function(arr) {
|
|
1630
|
+
return flat(arr, []);
|
|
1631
|
+
};
|
|
1632
|
+
function flat(arr, res) {
|
|
1633
|
+
var i = 0, cur;
|
|
1634
|
+
var len = arr.length;
|
|
1635
|
+
for(; i < len; i++){
|
|
1636
|
+
cur = arr[i];
|
|
1637
|
+
Array.isArray(cur) ? flat(cur, res) : res.push(cur);
|
|
1638
|
+
}
|
|
1639
|
+
return res;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/parsimmon@1.18.1/node_modules/parsimmon/src/parsimmon.js
|
|
1644
|
+
var require_parsimmon = __commonJS({
|
|
1645
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/parsimmon@1.18.1/node_modules/parsimmon/src/parsimmon.js": function(exports, module) {
|
|
1646
|
+
"use strict";
|
|
1647
|
+
function Parsimmon(action) {
|
|
1648
|
+
if (!_instanceof(this, Parsimmon)) {
|
|
1649
|
+
return new Parsimmon(action);
|
|
1650
|
+
}
|
|
1651
|
+
this._ = action;
|
|
1652
|
+
}
|
|
1653
|
+
var _ = Parsimmon.prototype;
|
|
1654
|
+
function times(n, f) {
|
|
1655
|
+
var i = 0;
|
|
1656
|
+
for(i; i < n; i++){
|
|
1657
|
+
f(i);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
function forEach(f, arr) {
|
|
1661
|
+
times(arr.length, function(i) {
|
|
1662
|
+
f(arr[i], i, arr);
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
function reduce(f, seed, arr) {
|
|
1666
|
+
forEach(function(elem, i, arr2) {
|
|
1667
|
+
seed = f(seed, elem, i, arr2);
|
|
1668
|
+
}, arr);
|
|
1669
|
+
return seed;
|
|
1670
|
+
}
|
|
1671
|
+
function map(f, arr) {
|
|
1672
|
+
return reduce(function(acc, elem, i, a) {
|
|
1673
|
+
return acc.concat([
|
|
1674
|
+
f(elem, i, a)
|
|
1675
|
+
]);
|
|
1676
|
+
}, [], arr);
|
|
1677
|
+
}
|
|
1678
|
+
function lshiftBuffer(input) {
|
|
1679
|
+
var asTwoBytes = reduce(function(a, v, i, b) {
|
|
1680
|
+
return a.concat(i === b.length - 1 ? Buffer.from([
|
|
1681
|
+
v,
|
|
1682
|
+
0
|
|
1683
|
+
]).readUInt16BE(0) : b.readUInt16BE(i));
|
|
1684
|
+
}, [], input);
|
|
1685
|
+
return Buffer.from(map(function(x) {
|
|
1686
|
+
return (x << 1 & 65535) >> 8;
|
|
1687
|
+
}, asTwoBytes));
|
|
1688
|
+
}
|
|
1689
|
+
function consumeBitsFromBuffer(n, input) {
|
|
1690
|
+
var state = {
|
|
1691
|
+
v: 0,
|
|
1692
|
+
buf: input
|
|
1693
|
+
};
|
|
1694
|
+
times(n, function() {
|
|
1695
|
+
state = {
|
|
1696
|
+
v: state.v << 1 | bitPeekBuffer(state.buf),
|
|
1697
|
+
buf: lshiftBuffer(state.buf)
|
|
1698
|
+
};
|
|
1699
|
+
});
|
|
1700
|
+
return state;
|
|
1701
|
+
}
|
|
1702
|
+
function bitPeekBuffer(input) {
|
|
1703
|
+
return input[0] >> 7;
|
|
1704
|
+
}
|
|
1705
|
+
function sum(numArr) {
|
|
1706
|
+
return reduce(function(x, y) {
|
|
1707
|
+
return x + y;
|
|
1708
|
+
}, 0, numArr);
|
|
1709
|
+
}
|
|
1710
|
+
function find2(pred, arr) {
|
|
1711
|
+
return reduce(function(found, elem) {
|
|
1712
|
+
return found || (pred(elem) ? elem : found);
|
|
1713
|
+
}, null, arr);
|
|
1714
|
+
}
|
|
1715
|
+
function bufferExists() {
|
|
1716
|
+
return typeof Buffer !== "undefined";
|
|
1717
|
+
}
|
|
1718
|
+
function setExists() {
|
|
1719
|
+
if (Parsimmon._supportsSet !== void 0) {
|
|
1720
|
+
return Parsimmon._supportsSet;
|
|
1721
|
+
}
|
|
1722
|
+
var exists = typeof Set !== "undefined";
|
|
1723
|
+
Parsimmon._supportsSet = exists;
|
|
1724
|
+
return exists;
|
|
1725
|
+
}
|
|
1726
|
+
function ensureBuffer() {
|
|
1727
|
+
if (!bufferExists()) {
|
|
1728
|
+
throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.");
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function bitSeq(alignments) {
|
|
1732
|
+
ensureBuffer();
|
|
1733
|
+
var totalBits = sum(alignments);
|
|
1734
|
+
if (totalBits % 8 !== 0) {
|
|
1735
|
+
throw new Error("The bits [" + alignments.join(", ") + "] add up to " + totalBits + " which is not an even number of bytes; the total should be divisible by 8");
|
|
1736
|
+
}
|
|
1737
|
+
var bytes = totalBits / 8;
|
|
1738
|
+
var tooBigRange = find2(function(x) {
|
|
1739
|
+
return x > 48;
|
|
1740
|
+
}, alignments);
|
|
1741
|
+
if (tooBigRange) {
|
|
1742
|
+
throw new Error(tooBigRange + " bit range requested exceeds 48 bit (6 byte) Number max.");
|
|
1743
|
+
}
|
|
1744
|
+
return new Parsimmon(function(input, i) {
|
|
1745
|
+
var newPos = bytes + i;
|
|
1746
|
+
if (newPos > input.length) {
|
|
1747
|
+
return makeFailure(i, bytes.toString() + " bytes");
|
|
1748
|
+
}
|
|
1749
|
+
return makeSuccess(newPos, reduce(function(acc, bits) {
|
|
1750
|
+
var state = consumeBitsFromBuffer(bits, acc.buf);
|
|
1751
|
+
return {
|
|
1752
|
+
coll: acc.coll.concat(state.v),
|
|
1753
|
+
buf: state.buf
|
|
1754
|
+
};
|
|
1755
|
+
}, {
|
|
1756
|
+
coll: [],
|
|
1757
|
+
buf: input.slice(i, newPos)
|
|
1758
|
+
}, alignments).coll);
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
function bitSeqObj(namedAlignments) {
|
|
1762
|
+
ensureBuffer();
|
|
1763
|
+
var seenKeys = {};
|
|
1764
|
+
var totalKeys = 0;
|
|
1765
|
+
var fullAlignments = map(function(item) {
|
|
1766
|
+
if (isArray(item)) {
|
|
1767
|
+
var pair = item;
|
|
1768
|
+
if (pair.length !== 2) {
|
|
1769
|
+
throw new Error("[" + pair.join(", ") + "] should be length 2, got length " + pair.length);
|
|
1770
|
+
}
|
|
1771
|
+
assertString(pair[0]);
|
|
1772
|
+
assertNumber(pair[1]);
|
|
1773
|
+
if (Object.prototype.hasOwnProperty.call(seenKeys, pair[0])) {
|
|
1774
|
+
throw new Error("duplicate key in bitSeqObj: " + pair[0]);
|
|
1775
|
+
}
|
|
1776
|
+
seenKeys[pair[0]] = true;
|
|
1777
|
+
totalKeys++;
|
|
1778
|
+
return pair;
|
|
1779
|
+
} else {
|
|
1780
|
+
assertNumber(item);
|
|
1781
|
+
return [
|
|
1782
|
+
null,
|
|
1783
|
+
item
|
|
1784
|
+
];
|
|
1785
|
+
}
|
|
1786
|
+
}, namedAlignments);
|
|
1787
|
+
if (totalKeys < 1) {
|
|
1788
|
+
throw new Error("bitSeqObj expects at least one named pair, got [" + namedAlignments.join(", ") + "]");
|
|
1789
|
+
}
|
|
1790
|
+
var namesOnly = map(function(pair) {
|
|
1791
|
+
return pair[0];
|
|
1792
|
+
}, fullAlignments);
|
|
1793
|
+
var alignmentsOnly = map(function(pair) {
|
|
1794
|
+
return pair[1];
|
|
1795
|
+
}, fullAlignments);
|
|
1796
|
+
return bitSeq(alignmentsOnly).map(function(parsed) {
|
|
1797
|
+
var namedParsed = map(function(name, i) {
|
|
1798
|
+
return [
|
|
1799
|
+
name,
|
|
1800
|
+
parsed[i]
|
|
1801
|
+
];
|
|
1802
|
+
}, namesOnly);
|
|
1803
|
+
return reduce(function(obj, kv) {
|
|
1804
|
+
if (kv[0] !== null) {
|
|
1805
|
+
obj[kv[0]] = kv[1];
|
|
1806
|
+
}
|
|
1807
|
+
return obj;
|
|
1808
|
+
}, {}, namedParsed);
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
function parseBufferFor(other, length) {
|
|
1812
|
+
return new Parsimmon(function(input, i) {
|
|
1813
|
+
ensureBuffer();
|
|
1814
|
+
if (i + length > input.length) {
|
|
1815
|
+
return makeFailure(i, length + " bytes for " + other);
|
|
1816
|
+
}
|
|
1817
|
+
return makeSuccess(i + length, input.slice(i, i + length));
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
function parseBuffer(length) {
|
|
1821
|
+
return parseBufferFor("buffer", length).map(function(unsafe) {
|
|
1822
|
+
return Buffer.from(unsafe);
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
function encodedString(encoding, length) {
|
|
1826
|
+
return parseBufferFor("string", length).map(function(buff) {
|
|
1827
|
+
return buff.toString(encoding);
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
function isInteger(value) {
|
|
1831
|
+
return typeof value === "number" && Math.floor(value) === value;
|
|
1832
|
+
}
|
|
1833
|
+
function assertValidIntegerByteLengthFor(who, length) {
|
|
1834
|
+
if (!isInteger(length) || length < 0 || length > 6) {
|
|
1835
|
+
throw new Error(who + " requires integer length in range [0, 6].");
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
function uintBE(length) {
|
|
1839
|
+
assertValidIntegerByteLengthFor("uintBE", length);
|
|
1840
|
+
return parseBufferFor("uintBE(" + length + ")", length).map(function(buff) {
|
|
1841
|
+
return buff.readUIntBE(0, length);
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
function uintLE(length) {
|
|
1845
|
+
assertValidIntegerByteLengthFor("uintLE", length);
|
|
1846
|
+
return parseBufferFor("uintLE(" + length + ")", length).map(function(buff) {
|
|
1847
|
+
return buff.readUIntLE(0, length);
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
function intBE(length) {
|
|
1851
|
+
assertValidIntegerByteLengthFor("intBE", length);
|
|
1852
|
+
return parseBufferFor("intBE(" + length + ")", length).map(function(buff) {
|
|
1853
|
+
return buff.readIntBE(0, length);
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
function intLE(length) {
|
|
1857
|
+
assertValidIntegerByteLengthFor("intLE", length);
|
|
1858
|
+
return parseBufferFor("intLE(" + length + ")", length).map(function(buff) {
|
|
1859
|
+
return buff.readIntLE(0, length);
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
function floatBE() {
|
|
1863
|
+
return parseBufferFor("floatBE", 4).map(function(buff) {
|
|
1864
|
+
return buff.readFloatBE(0);
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
function floatLE() {
|
|
1868
|
+
return parseBufferFor("floatLE", 4).map(function(buff) {
|
|
1869
|
+
return buff.readFloatLE(0);
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
function doubleBE() {
|
|
1873
|
+
return parseBufferFor("doubleBE", 8).map(function(buff) {
|
|
1874
|
+
return buff.readDoubleBE(0);
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
function doubleLE() {
|
|
1878
|
+
return parseBufferFor("doubleLE", 8).map(function(buff) {
|
|
1879
|
+
return buff.readDoubleLE(0);
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
function toArray(arrLike) {
|
|
1883
|
+
return Array.prototype.slice.call(arrLike);
|
|
1884
|
+
}
|
|
1885
|
+
function isParser(obj) {
|
|
1886
|
+
return _instanceof(obj, Parsimmon);
|
|
1887
|
+
}
|
|
1888
|
+
function isArray(x) {
|
|
1889
|
+
return ({}).toString.call(x) === "[object Array]";
|
|
1890
|
+
}
|
|
1891
|
+
function isBuffer(x) {
|
|
1892
|
+
return bufferExists() && Buffer.isBuffer(x);
|
|
1893
|
+
}
|
|
1894
|
+
function makeSuccess(index2, value) {
|
|
1895
|
+
return {
|
|
1896
|
+
status: true,
|
|
1897
|
+
index: index2,
|
|
1898
|
+
value: value,
|
|
1899
|
+
furthest: -1,
|
|
1900
|
+
expected: []
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
function makeFailure(index2, expected) {
|
|
1904
|
+
if (!isArray(expected)) {
|
|
1905
|
+
expected = [
|
|
1906
|
+
expected
|
|
1907
|
+
];
|
|
1908
|
+
}
|
|
1909
|
+
return {
|
|
1910
|
+
status: false,
|
|
1911
|
+
index: -1,
|
|
1912
|
+
value: null,
|
|
1913
|
+
furthest: index2,
|
|
1914
|
+
expected: expected
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
function mergeReplies(result, last) {
|
|
1918
|
+
if (!last) {
|
|
1919
|
+
return result;
|
|
1920
|
+
}
|
|
1921
|
+
if (result.furthest > last.furthest) {
|
|
1922
|
+
return result;
|
|
1923
|
+
}
|
|
1924
|
+
var expected = result.furthest === last.furthest ? union(result.expected, last.expected) : last.expected;
|
|
1925
|
+
return {
|
|
1926
|
+
status: result.status,
|
|
1927
|
+
index: result.index,
|
|
1928
|
+
value: result.value,
|
|
1929
|
+
furthest: last.furthest,
|
|
1930
|
+
expected: expected
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
var lineColumnIndex = {};
|
|
1934
|
+
function makeLineColumnIndex(input, i) {
|
|
1935
|
+
if (isBuffer(input)) {
|
|
1936
|
+
return {
|
|
1937
|
+
offset: i,
|
|
1938
|
+
line: -1,
|
|
1939
|
+
column: -1
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
if (!(input in lineColumnIndex)) {
|
|
1943
|
+
lineColumnIndex[input] = {};
|
|
1944
|
+
}
|
|
1945
|
+
var inputIndex = lineColumnIndex[input];
|
|
1946
|
+
var prevLine = 0;
|
|
1947
|
+
var newLines = 0;
|
|
1948
|
+
var lineStart = 0;
|
|
1949
|
+
var j = i;
|
|
1950
|
+
while(j >= 0){
|
|
1951
|
+
if (j in inputIndex) {
|
|
1952
|
+
prevLine = inputIndex[j].line;
|
|
1953
|
+
if (lineStart === 0) {
|
|
1954
|
+
lineStart = inputIndex[j].lineStart;
|
|
1955
|
+
}
|
|
1956
|
+
break;
|
|
1957
|
+
}
|
|
1958
|
+
if (// Unix LF (\n) or Windows CRLF (\r\n) line ending
|
|
1959
|
+
input.charAt(j) === "\n" || // Old Mac CR (\r) line ending
|
|
1960
|
+
input.charAt(j) === "\r" && input.charAt(j + 1) !== "\n") {
|
|
1961
|
+
newLines++;
|
|
1962
|
+
if (lineStart === 0) {
|
|
1963
|
+
lineStart = j + 1;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
j--;
|
|
1967
|
+
}
|
|
1968
|
+
var lineWeAreUpTo = prevLine + newLines;
|
|
1969
|
+
var columnWeAreUpTo = i - lineStart;
|
|
1970
|
+
inputIndex[i] = {
|
|
1971
|
+
line: lineWeAreUpTo,
|
|
1972
|
+
lineStart: lineStart
|
|
1973
|
+
};
|
|
1974
|
+
return {
|
|
1975
|
+
offset: i,
|
|
1976
|
+
line: lineWeAreUpTo + 1,
|
|
1977
|
+
column: columnWeAreUpTo + 1
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
function union(xs, ys) {
|
|
1981
|
+
if (setExists() && Array.from) {
|
|
1982
|
+
var set2 = new Set(xs);
|
|
1983
|
+
for(var y = 0; y < ys.length; y++){
|
|
1984
|
+
set2.add(ys[y]);
|
|
1985
|
+
}
|
|
1986
|
+
var arr = Array.from(set2);
|
|
1987
|
+
arr.sort();
|
|
1988
|
+
return arr;
|
|
1989
|
+
}
|
|
1990
|
+
var obj = {};
|
|
1991
|
+
for(var i = 0; i < xs.length; i++){
|
|
1992
|
+
obj[xs[i]] = true;
|
|
1993
|
+
}
|
|
1994
|
+
for(var j = 0; j < ys.length; j++){
|
|
1995
|
+
obj[ys[j]] = true;
|
|
1996
|
+
}
|
|
1997
|
+
var keys = [];
|
|
1998
|
+
for(var k in obj){
|
|
1999
|
+
if (({}).hasOwnProperty.call(obj, k)) {
|
|
2000
|
+
keys.push(k);
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
keys.sort();
|
|
2004
|
+
return keys;
|
|
2005
|
+
}
|
|
2006
|
+
function assertParser(p) {
|
|
2007
|
+
if (!isParser(p)) {
|
|
2008
|
+
throw new Error("not a parser: " + p);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
function get(input, i) {
|
|
2012
|
+
if (typeof input === "string") {
|
|
2013
|
+
return input.charAt(i);
|
|
2014
|
+
}
|
|
2015
|
+
return input[i];
|
|
2016
|
+
}
|
|
2017
|
+
function assertArray(x) {
|
|
2018
|
+
if (!isArray(x)) {
|
|
2019
|
+
throw new Error("not an array: " + x);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
function assertNumber(x) {
|
|
2023
|
+
if (typeof x !== "number") {
|
|
2024
|
+
throw new Error("not a number: " + x);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
function assertRegexp(x) {
|
|
2028
|
+
if (!_instanceof(x, RegExp)) {
|
|
2029
|
+
throw new Error("not a regexp: " + x);
|
|
2030
|
+
}
|
|
2031
|
+
var f = flags(x);
|
|
2032
|
+
for(var i = 0; i < f.length; i++){
|
|
2033
|
+
var c = f.charAt(i);
|
|
2034
|
+
if (c !== "i" && c !== "m" && c !== "u" && c !== "s") {
|
|
2035
|
+
throw new Error('unsupported regexp flag "' + c + '": ' + x);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function assertFunction(x) {
|
|
2040
|
+
if (typeof x !== "function") {
|
|
2041
|
+
throw new Error("not a function: " + x);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
function assertString(x) {
|
|
2045
|
+
if (typeof x !== "string") {
|
|
2046
|
+
throw new Error("not a string: " + x);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
var linesBeforeStringError = 2;
|
|
2050
|
+
var linesAfterStringError = 3;
|
|
2051
|
+
var bytesPerLine = 8;
|
|
2052
|
+
var bytesBefore = bytesPerLine * 5;
|
|
2053
|
+
var bytesAfter = bytesPerLine * 4;
|
|
2054
|
+
var defaultLinePrefix = " ";
|
|
2055
|
+
function repeat(string2, amount) {
|
|
2056
|
+
return new Array(amount + 1).join(string2);
|
|
2057
|
+
}
|
|
2058
|
+
function formatExpected(expected) {
|
|
2059
|
+
if (expected.length === 1) {
|
|
2060
|
+
return "Expected:\n\n" + expected[0];
|
|
2061
|
+
}
|
|
2062
|
+
return "Expected one of the following: \n\n" + expected.join(", ");
|
|
2063
|
+
}
|
|
2064
|
+
function leftPad(str, pad, char) {
|
|
2065
|
+
var add = pad - str.length;
|
|
2066
|
+
if (add <= 0) {
|
|
2067
|
+
return str;
|
|
2068
|
+
}
|
|
2069
|
+
return repeat(char, add) + str;
|
|
2070
|
+
}
|
|
2071
|
+
function toChunks(arr, chunkSize) {
|
|
2072
|
+
var length = arr.length;
|
|
2073
|
+
var chunks = [];
|
|
2074
|
+
var chunkIndex = 0;
|
|
2075
|
+
if (length <= chunkSize) {
|
|
2076
|
+
return [
|
|
2077
|
+
arr.slice()
|
|
2078
|
+
];
|
|
2079
|
+
}
|
|
2080
|
+
for(var i = 0; i < length; i++){
|
|
2081
|
+
if (!chunks[chunkIndex]) {
|
|
2082
|
+
chunks.push([]);
|
|
2083
|
+
}
|
|
2084
|
+
chunks[chunkIndex].push(arr[i]);
|
|
2085
|
+
if ((i + 1) % chunkSize === 0) {
|
|
2086
|
+
chunkIndex++;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return chunks;
|
|
2090
|
+
}
|
|
2091
|
+
function rangeFromIndexAndOffsets(i, before, after, length) {
|
|
2092
|
+
return {
|
|
2093
|
+
// Guard against the negative upper bound for lines included in the output.
|
|
2094
|
+
from: i - before > 0 ? i - before : 0,
|
|
2095
|
+
to: i + after > length ? length : i + after
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
function byteRangeToRange(byteRange) {
|
|
2099
|
+
if (byteRange.from === 0 && byteRange.to === 1) {
|
|
2100
|
+
return {
|
|
2101
|
+
from: byteRange.from,
|
|
2102
|
+
to: byteRange.to
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
return {
|
|
2106
|
+
from: byteRange.from / bytesPerLine,
|
|
2107
|
+
// Round `to`, so we don't get float if the amount of bytes is not divisible by `bytesPerLine`
|
|
2108
|
+
to: Math.floor(byteRange.to / bytesPerLine)
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
function formatGot(input, error) {
|
|
2112
|
+
var index2 = error.index;
|
|
2113
|
+
var i = index2.offset;
|
|
2114
|
+
var verticalMarkerLength = 1;
|
|
2115
|
+
var column;
|
|
2116
|
+
var lineWithErrorIndex;
|
|
2117
|
+
var lines;
|
|
2118
|
+
var lineRange;
|
|
2119
|
+
var lastLineNumberLabelLength;
|
|
2120
|
+
if (i === input.length) {
|
|
2121
|
+
return "Got the end of the input";
|
|
2122
|
+
}
|
|
2123
|
+
if (isBuffer(input)) {
|
|
2124
|
+
var byteLineWithErrorIndex = i - i % bytesPerLine;
|
|
2125
|
+
var columnByteIndex = i - byteLineWithErrorIndex;
|
|
2126
|
+
var byteRange = rangeFromIndexAndOffsets(byteLineWithErrorIndex, bytesBefore, bytesAfter + bytesPerLine, input.length);
|
|
2127
|
+
var bytes = input.slice(byteRange.from, byteRange.to);
|
|
2128
|
+
var bytesInChunks = toChunks(bytes.toJSON().data, bytesPerLine);
|
|
2129
|
+
var byteLines = map(function(byteRow) {
|
|
2130
|
+
return map(function(byteValue) {
|
|
2131
|
+
return leftPad(byteValue.toString(16), 2, "0");
|
|
2132
|
+
}, byteRow);
|
|
2133
|
+
}, bytesInChunks);
|
|
2134
|
+
lineRange = byteRangeToRange(byteRange);
|
|
2135
|
+
lineWithErrorIndex = byteLineWithErrorIndex / bytesPerLine;
|
|
2136
|
+
column = columnByteIndex * 3;
|
|
2137
|
+
if (columnByteIndex >= 4) {
|
|
2138
|
+
column += 1;
|
|
2139
|
+
}
|
|
2140
|
+
verticalMarkerLength = 2;
|
|
2141
|
+
lines = map(function(byteLine) {
|
|
2142
|
+
return byteLine.length <= 4 ? byteLine.join(" ") : byteLine.slice(0, 4).join(" ") + " " + byteLine.slice(4).join(" ");
|
|
2143
|
+
}, byteLines);
|
|
2144
|
+
lastLineNumberLabelLength = ((lineRange.to > 0 ? lineRange.to - 1 : lineRange.to) * 8).toString(16).length;
|
|
2145
|
+
if (lastLineNumberLabelLength < 2) {
|
|
2146
|
+
lastLineNumberLabelLength = 2;
|
|
2147
|
+
}
|
|
2148
|
+
} else {
|
|
2149
|
+
var inputLines = input.split(/\r\n|[\n\r\u2028\u2029]/);
|
|
2150
|
+
column = index2.column - 1;
|
|
2151
|
+
lineWithErrorIndex = index2.line - 1;
|
|
2152
|
+
lineRange = rangeFromIndexAndOffsets(lineWithErrorIndex, linesBeforeStringError, linesAfterStringError, inputLines.length);
|
|
2153
|
+
lines = inputLines.slice(lineRange.from, lineRange.to);
|
|
2154
|
+
lastLineNumberLabelLength = lineRange.to.toString().length;
|
|
2155
|
+
}
|
|
2156
|
+
var lineWithErrorCurrentIndex = lineWithErrorIndex - lineRange.from;
|
|
2157
|
+
if (isBuffer(input)) {
|
|
2158
|
+
lastLineNumberLabelLength = ((lineRange.to > 0 ? lineRange.to - 1 : lineRange.to) * 8).toString(16).length;
|
|
2159
|
+
if (lastLineNumberLabelLength < 2) {
|
|
2160
|
+
lastLineNumberLabelLength = 2;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
var linesWithLineNumbers = reduce(function(acc, lineSource, index3) {
|
|
2164
|
+
var isLineWithError = index3 === lineWithErrorCurrentIndex;
|
|
2165
|
+
var prefix = isLineWithError ? "> " : defaultLinePrefix;
|
|
2166
|
+
var lineNumberLabel;
|
|
2167
|
+
if (isBuffer(input)) {
|
|
2168
|
+
lineNumberLabel = leftPad(((lineRange.from + index3) * 8).toString(16), lastLineNumberLabelLength, "0");
|
|
2169
|
+
} else {
|
|
2170
|
+
lineNumberLabel = leftPad((lineRange.from + index3 + 1).toString(), lastLineNumberLabelLength, " ");
|
|
2171
|
+
}
|
|
2172
|
+
return [].concat(acc, [
|
|
2173
|
+
prefix + lineNumberLabel + " | " + lineSource
|
|
2174
|
+
], isLineWithError ? [
|
|
2175
|
+
defaultLinePrefix + repeat(" ", lastLineNumberLabelLength) + " | " + leftPad("", column, " ") + repeat("^", verticalMarkerLength)
|
|
2176
|
+
] : []);
|
|
2177
|
+
}, [], lines);
|
|
2178
|
+
return linesWithLineNumbers.join("\n");
|
|
2179
|
+
}
|
|
2180
|
+
function formatError(input, error) {
|
|
2181
|
+
return [
|
|
2182
|
+
"\n",
|
|
2183
|
+
"-- PARSING FAILED " + repeat("-", 50),
|
|
2184
|
+
"\n\n",
|
|
2185
|
+
formatGot(input, error),
|
|
2186
|
+
"\n\n",
|
|
2187
|
+
formatExpected(error.expected),
|
|
2188
|
+
"\n"
|
|
2189
|
+
].join("");
|
|
2190
|
+
}
|
|
2191
|
+
function flags(re) {
|
|
2192
|
+
if (re.flags !== void 0) {
|
|
2193
|
+
return re.flags;
|
|
2194
|
+
}
|
|
2195
|
+
return [
|
|
2196
|
+
re.global ? "g" : "",
|
|
2197
|
+
re.ignoreCase ? "i" : "",
|
|
2198
|
+
re.multiline ? "m" : "",
|
|
2199
|
+
re.unicode ? "u" : "",
|
|
2200
|
+
re.sticky ? "y" : ""
|
|
2201
|
+
].join("");
|
|
2202
|
+
}
|
|
2203
|
+
function anchoredRegexp(re) {
|
|
2204
|
+
return RegExp("^(?:" + re.source + ")", flags(re));
|
|
2205
|
+
}
|
|
2206
|
+
function seq() {
|
|
2207
|
+
var parsers = [].slice.call(arguments);
|
|
2208
|
+
var numParsers = parsers.length;
|
|
2209
|
+
for(var j = 0; j < numParsers; j += 1){
|
|
2210
|
+
assertParser(parsers[j]);
|
|
2211
|
+
}
|
|
2212
|
+
return Parsimmon(function(input, i) {
|
|
2213
|
+
var result;
|
|
2214
|
+
var accum = new Array(numParsers);
|
|
2215
|
+
for(var j2 = 0; j2 < numParsers; j2 += 1){
|
|
2216
|
+
result = mergeReplies(parsers[j2]._(input, i), result);
|
|
2217
|
+
if (!result.status) {
|
|
2218
|
+
return result;
|
|
2219
|
+
}
|
|
2220
|
+
accum[j2] = result.value;
|
|
2221
|
+
i = result.index;
|
|
2222
|
+
}
|
|
2223
|
+
return mergeReplies(makeSuccess(i, accum), result);
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
function seqObj() {
|
|
2227
|
+
var seenKeys = {};
|
|
2228
|
+
var totalKeys = 0;
|
|
2229
|
+
var parsers = toArray(arguments);
|
|
2230
|
+
var numParsers = parsers.length;
|
|
2231
|
+
for(var j = 0; j < numParsers; j += 1){
|
|
2232
|
+
var p = parsers[j];
|
|
2233
|
+
if (isParser(p)) {
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
if (isArray(p)) {
|
|
2237
|
+
var isWellFormed = p.length === 2 && typeof p[0] === "string" && isParser(p[1]);
|
|
2238
|
+
if (isWellFormed) {
|
|
2239
|
+
var key = p[0];
|
|
2240
|
+
if (Object.prototype.hasOwnProperty.call(seenKeys, key)) {
|
|
2241
|
+
throw new Error("seqObj: duplicate key " + key);
|
|
2242
|
+
}
|
|
2243
|
+
seenKeys[key] = true;
|
|
2244
|
+
totalKeys++;
|
|
2245
|
+
continue;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.");
|
|
2249
|
+
}
|
|
2250
|
+
if (totalKeys === 0) {
|
|
2251
|
+
throw new Error("seqObj expects at least one named parser, found zero");
|
|
2252
|
+
}
|
|
2253
|
+
return Parsimmon(function(input, i) {
|
|
2254
|
+
var result;
|
|
2255
|
+
var accum = {};
|
|
2256
|
+
for(var j2 = 0; j2 < numParsers; j2 += 1){
|
|
2257
|
+
var name;
|
|
2258
|
+
var parser2;
|
|
2259
|
+
if (isArray(parsers[j2])) {
|
|
2260
|
+
name = parsers[j2][0];
|
|
2261
|
+
parser2 = parsers[j2][1];
|
|
2262
|
+
} else {
|
|
2263
|
+
name = null;
|
|
2264
|
+
parser2 = parsers[j2];
|
|
2265
|
+
}
|
|
2266
|
+
result = mergeReplies(parser2._(input, i), result);
|
|
2267
|
+
if (!result.status) {
|
|
2268
|
+
return result;
|
|
2269
|
+
}
|
|
2270
|
+
if (name) {
|
|
2271
|
+
accum[name] = result.value;
|
|
2272
|
+
}
|
|
2273
|
+
i = result.index;
|
|
2274
|
+
}
|
|
2275
|
+
return mergeReplies(makeSuccess(i, accum), result);
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
function seqMap() {
|
|
2279
|
+
var args = [].slice.call(arguments);
|
|
2280
|
+
if (args.length === 0) {
|
|
2281
|
+
throw new Error("seqMap needs at least one argument");
|
|
2282
|
+
}
|
|
2283
|
+
var mapper = args.pop();
|
|
2284
|
+
assertFunction(mapper);
|
|
2285
|
+
return seq.apply(null, args).map(function(results) {
|
|
2286
|
+
return mapper.apply(null, results);
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
function createLanguage(parsers) {
|
|
2290
|
+
var language = {};
|
|
2291
|
+
for(var key in parsers){
|
|
2292
|
+
if (({}).hasOwnProperty.call(parsers, key)) {
|
|
2293
|
+
(function(key2) {
|
|
2294
|
+
var func = function func() {
|
|
2295
|
+
return parsers[key2](language);
|
|
2296
|
+
};
|
|
2297
|
+
language[key2] = lazy(func);
|
|
2298
|
+
})(key);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
return language;
|
|
2302
|
+
}
|
|
2303
|
+
function alt() {
|
|
2304
|
+
var parsers = [].slice.call(arguments);
|
|
2305
|
+
var numParsers = parsers.length;
|
|
2306
|
+
if (numParsers === 0) {
|
|
2307
|
+
return fail("zero alternates");
|
|
2308
|
+
}
|
|
2309
|
+
for(var j = 0; j < numParsers; j += 1){
|
|
2310
|
+
assertParser(parsers[j]);
|
|
2311
|
+
}
|
|
2312
|
+
return Parsimmon(function(input, i) {
|
|
2313
|
+
var result;
|
|
2314
|
+
for(var j2 = 0; j2 < parsers.length; j2 += 1){
|
|
2315
|
+
result = mergeReplies(parsers[j2]._(input, i), result);
|
|
2316
|
+
if (result.status) {
|
|
2317
|
+
return result;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
return result;
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
function sepBy(parser2, separator) {
|
|
2324
|
+
return sepBy1(parser2, separator).or(succeed([]));
|
|
2325
|
+
}
|
|
2326
|
+
function sepBy1(parser2, separator) {
|
|
2327
|
+
assertParser(parser2);
|
|
2328
|
+
assertParser(separator);
|
|
2329
|
+
var pairs = separator.then(parser2).many();
|
|
2330
|
+
return seqMap(parser2, pairs, function(r, rs) {
|
|
2331
|
+
return [
|
|
2332
|
+
r
|
|
2333
|
+
].concat(rs);
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
_.parse = function(input) {
|
|
2337
|
+
if (typeof input !== "string" && !isBuffer(input)) {
|
|
2338
|
+
throw new Error(".parse must be called with a string or Buffer as its argument");
|
|
2339
|
+
}
|
|
2340
|
+
var parseResult = this.skip(eof)._(input, 0);
|
|
2341
|
+
var result;
|
|
2342
|
+
if (parseResult.status) {
|
|
2343
|
+
result = {
|
|
2344
|
+
status: true,
|
|
2345
|
+
value: parseResult.value
|
|
2346
|
+
};
|
|
2347
|
+
} else {
|
|
2348
|
+
result = {
|
|
2349
|
+
status: false,
|
|
2350
|
+
index: makeLineColumnIndex(input, parseResult.furthest),
|
|
2351
|
+
expected: parseResult.expected
|
|
2352
|
+
};
|
|
2353
|
+
}
|
|
2354
|
+
delete lineColumnIndex[input];
|
|
2355
|
+
return result;
|
|
2356
|
+
};
|
|
2357
|
+
_.tryParse = function(str) {
|
|
2358
|
+
var result = this.parse(str);
|
|
2359
|
+
if (result.status) {
|
|
2360
|
+
return result.value;
|
|
2361
|
+
} else {
|
|
2362
|
+
var msg = formatError(str, result);
|
|
2363
|
+
var err = new Error(msg);
|
|
2364
|
+
err.type = "ParsimmonError";
|
|
2365
|
+
err.result = result;
|
|
2366
|
+
throw err;
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
_.assert = function(condition, errorMessage) {
|
|
2370
|
+
return this.chain(function(value) {
|
|
2371
|
+
return condition(value) ? succeed(value) : fail(errorMessage);
|
|
2372
|
+
});
|
|
2373
|
+
};
|
|
2374
|
+
_.or = function(alternative) {
|
|
2375
|
+
return alt(this, alternative);
|
|
2376
|
+
};
|
|
2377
|
+
_.trim = function(parser2) {
|
|
2378
|
+
return this.wrap(parser2, parser2);
|
|
2379
|
+
};
|
|
2380
|
+
_.wrap = function(leftParser, rightParser) {
|
|
2381
|
+
return seqMap(leftParser, this, rightParser, function(left, middle) {
|
|
2382
|
+
return middle;
|
|
2383
|
+
});
|
|
2384
|
+
};
|
|
2385
|
+
_.thru = function(wrapper) {
|
|
2386
|
+
return wrapper(this);
|
|
2387
|
+
};
|
|
2388
|
+
_.then = function(next) {
|
|
2389
|
+
assertParser(next);
|
|
2390
|
+
return seq(this, next).map(function(results) {
|
|
2391
|
+
return results[1];
|
|
2392
|
+
});
|
|
2393
|
+
};
|
|
2394
|
+
_.many = function() {
|
|
2395
|
+
var self = this;
|
|
2396
|
+
return Parsimmon(function(input, i) {
|
|
2397
|
+
var accum = [];
|
|
2398
|
+
var result = void 0;
|
|
2399
|
+
for(;;){
|
|
2400
|
+
result = mergeReplies(self._(input, i), result);
|
|
2401
|
+
if (result.status) {
|
|
2402
|
+
if (i === result.index) {
|
|
2403
|
+
throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
|
|
2404
|
+
}
|
|
2405
|
+
i = result.index;
|
|
2406
|
+
accum.push(result.value);
|
|
2407
|
+
} else {
|
|
2408
|
+
return mergeReplies(makeSuccess(i, accum), result);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
};
|
|
2413
|
+
_.tieWith = function(separator) {
|
|
2414
|
+
assertString(separator);
|
|
2415
|
+
return this.map(function(args) {
|
|
2416
|
+
assertArray(args);
|
|
2417
|
+
if (args.length) {
|
|
2418
|
+
assertString(args[0]);
|
|
2419
|
+
var s = args[0];
|
|
2420
|
+
for(var i = 1; i < args.length; i++){
|
|
2421
|
+
assertString(args[i]);
|
|
2422
|
+
s += separator + args[i];
|
|
2423
|
+
}
|
|
2424
|
+
return s;
|
|
2425
|
+
} else {
|
|
2426
|
+
return "";
|
|
2427
|
+
}
|
|
2428
|
+
});
|
|
2429
|
+
};
|
|
2430
|
+
_.tie = function() {
|
|
2431
|
+
return this.tieWith("");
|
|
2432
|
+
};
|
|
2433
|
+
_.times = function(min, max) {
|
|
2434
|
+
var self = this;
|
|
2435
|
+
if (arguments.length < 2) {
|
|
2436
|
+
max = min;
|
|
2437
|
+
}
|
|
2438
|
+
assertNumber(min);
|
|
2439
|
+
assertNumber(max);
|
|
2440
|
+
return Parsimmon(function(input, i) {
|
|
2441
|
+
var accum = [];
|
|
2442
|
+
var result = void 0;
|
|
2443
|
+
var prevResult = void 0;
|
|
2444
|
+
for(var times2 = 0; times2 < min; times2 += 1){
|
|
2445
|
+
result = self._(input, i);
|
|
2446
|
+
prevResult = mergeReplies(result, prevResult);
|
|
2447
|
+
if (result.status) {
|
|
2448
|
+
i = result.index;
|
|
2449
|
+
accum.push(result.value);
|
|
2450
|
+
} else {
|
|
2451
|
+
return prevResult;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
for(; times2 < max; times2 += 1){
|
|
2455
|
+
result = self._(input, i);
|
|
2456
|
+
prevResult = mergeReplies(result, prevResult);
|
|
2457
|
+
if (result.status) {
|
|
2458
|
+
i = result.index;
|
|
2459
|
+
accum.push(result.value);
|
|
2460
|
+
} else {
|
|
2461
|
+
break;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
return mergeReplies(makeSuccess(i, accum), prevResult);
|
|
2465
|
+
});
|
|
2466
|
+
};
|
|
2467
|
+
_.result = function(res) {
|
|
2468
|
+
return this.map(function() {
|
|
2469
|
+
return res;
|
|
2470
|
+
});
|
|
2471
|
+
};
|
|
2472
|
+
_.atMost = function(n) {
|
|
2473
|
+
return this.times(0, n);
|
|
2474
|
+
};
|
|
2475
|
+
_.atLeast = function(n) {
|
|
2476
|
+
return seqMap(this.times(n), this.many(), function(init, rest) {
|
|
2477
|
+
return init.concat(rest);
|
|
2478
|
+
});
|
|
2479
|
+
};
|
|
2480
|
+
_.map = function(fn) {
|
|
2481
|
+
assertFunction(fn);
|
|
2482
|
+
var self = this;
|
|
2483
|
+
return Parsimmon(function(input, i) {
|
|
2484
|
+
var result = self._(input, i);
|
|
2485
|
+
if (!result.status) {
|
|
2486
|
+
return result;
|
|
2487
|
+
}
|
|
2488
|
+
return mergeReplies(makeSuccess(result.index, fn(result.value)), result);
|
|
2489
|
+
});
|
|
2490
|
+
};
|
|
2491
|
+
_.contramap = function(fn) {
|
|
2492
|
+
assertFunction(fn);
|
|
2493
|
+
var self = this;
|
|
2494
|
+
return Parsimmon(function(input, i) {
|
|
2495
|
+
var result = self.parse(fn(input.slice(i)));
|
|
2496
|
+
if (!result.status) {
|
|
2497
|
+
return result;
|
|
2498
|
+
}
|
|
2499
|
+
return makeSuccess(i + input.length, result.value);
|
|
2500
|
+
});
|
|
2501
|
+
};
|
|
2502
|
+
_.promap = function(f, g) {
|
|
2503
|
+
assertFunction(f);
|
|
2504
|
+
assertFunction(g);
|
|
2505
|
+
return this.contramap(f).map(g);
|
|
2506
|
+
};
|
|
2507
|
+
_.skip = function(next) {
|
|
2508
|
+
return seq(this, next).map(function(results) {
|
|
2509
|
+
return results[0];
|
|
2510
|
+
});
|
|
2511
|
+
};
|
|
2512
|
+
_.mark = function() {
|
|
2513
|
+
return seqMap(index, this, index, function(start, value, end2) {
|
|
2514
|
+
return {
|
|
2515
|
+
start: start,
|
|
2516
|
+
value: value,
|
|
2517
|
+
end: end2
|
|
2518
|
+
};
|
|
2519
|
+
});
|
|
2520
|
+
};
|
|
2521
|
+
_.node = function(name) {
|
|
2522
|
+
return seqMap(index, this, index, function(start, value, end2) {
|
|
2523
|
+
return {
|
|
2524
|
+
name: name,
|
|
2525
|
+
value: value,
|
|
2526
|
+
start: start,
|
|
2527
|
+
end: end2
|
|
2528
|
+
};
|
|
2529
|
+
});
|
|
2530
|
+
};
|
|
2531
|
+
_.sepBy = function(separator) {
|
|
2532
|
+
return sepBy(this, separator);
|
|
2533
|
+
};
|
|
2534
|
+
_.sepBy1 = function(separator) {
|
|
2535
|
+
return sepBy1(this, separator);
|
|
2536
|
+
};
|
|
2537
|
+
_.lookahead = function(x) {
|
|
2538
|
+
return this.skip(lookahead(x));
|
|
2539
|
+
};
|
|
2540
|
+
_.notFollowedBy = function(x) {
|
|
2541
|
+
return this.skip(notFollowedBy(x));
|
|
2542
|
+
};
|
|
2543
|
+
_.desc = function(expected) {
|
|
2544
|
+
if (!isArray(expected)) {
|
|
2545
|
+
expected = [
|
|
2546
|
+
expected
|
|
2547
|
+
];
|
|
2548
|
+
}
|
|
2549
|
+
var self = this;
|
|
2550
|
+
return Parsimmon(function(input, i) {
|
|
2551
|
+
var reply = self._(input, i);
|
|
2552
|
+
if (!reply.status) {
|
|
2553
|
+
reply.expected = expected;
|
|
2554
|
+
}
|
|
2555
|
+
return reply;
|
|
2556
|
+
});
|
|
2557
|
+
};
|
|
2558
|
+
_.fallback = function(result) {
|
|
2559
|
+
return this.or(succeed(result));
|
|
2560
|
+
};
|
|
2561
|
+
_.ap = function(other) {
|
|
2562
|
+
return seqMap(other, this, function(f, x) {
|
|
2563
|
+
return f(x);
|
|
2564
|
+
});
|
|
2565
|
+
};
|
|
2566
|
+
_.chain = function(f) {
|
|
2567
|
+
var self = this;
|
|
2568
|
+
return Parsimmon(function(input, i) {
|
|
2569
|
+
var result = self._(input, i);
|
|
2570
|
+
if (!result.status) {
|
|
2571
|
+
return result;
|
|
2572
|
+
}
|
|
2573
|
+
var nextParser = f(result.value);
|
|
2574
|
+
return mergeReplies(nextParser._(input, result.index), result);
|
|
2575
|
+
});
|
|
2576
|
+
};
|
|
2577
|
+
function string(str) {
|
|
2578
|
+
assertString(str);
|
|
2579
|
+
var expected = "'" + str + "'";
|
|
2580
|
+
return Parsimmon(function(input, i) {
|
|
2581
|
+
var j = i + str.length;
|
|
2582
|
+
var head = input.slice(i, j);
|
|
2583
|
+
if (head === str) {
|
|
2584
|
+
return makeSuccess(j, head);
|
|
2585
|
+
} else {
|
|
2586
|
+
return makeFailure(i, expected);
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
}
|
|
2590
|
+
function byte(b) {
|
|
2591
|
+
ensureBuffer();
|
|
2592
|
+
assertNumber(b);
|
|
2593
|
+
if (b > 255) {
|
|
2594
|
+
throw new Error("Value specified to byte constructor (" + b + "=0x" + b.toString(16) + ") is larger in value than a single byte.");
|
|
2595
|
+
}
|
|
2596
|
+
var expected = (b > 15 ? "0x" : "0x0") + b.toString(16);
|
|
2597
|
+
return Parsimmon(function(input, i) {
|
|
2598
|
+
var head = get(input, i);
|
|
2599
|
+
if (head === b) {
|
|
2600
|
+
return makeSuccess(i + 1, head);
|
|
2601
|
+
} else {
|
|
2602
|
+
return makeFailure(i, expected);
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
function regexp(re, group) {
|
|
2607
|
+
assertRegexp(re);
|
|
2608
|
+
if (arguments.length >= 2) {
|
|
2609
|
+
assertNumber(group);
|
|
2610
|
+
} else {
|
|
2611
|
+
group = 0;
|
|
2612
|
+
}
|
|
2613
|
+
var anchored = anchoredRegexp(re);
|
|
2614
|
+
var expected = "" + re;
|
|
2615
|
+
return Parsimmon(function(input, i) {
|
|
2616
|
+
var match = anchored.exec(input.slice(i));
|
|
2617
|
+
if (match) {
|
|
2618
|
+
if (0 <= group && group <= match.length) {
|
|
2619
|
+
var fullMatch = match[0];
|
|
2620
|
+
var groupMatch = match[group];
|
|
2621
|
+
return makeSuccess(i + fullMatch.length, groupMatch);
|
|
2622
|
+
}
|
|
2623
|
+
var message = "valid match group (0 to " + match.length + ") in " + expected;
|
|
2624
|
+
return makeFailure(i, message);
|
|
2625
|
+
}
|
|
2626
|
+
return makeFailure(i, expected);
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
function succeed(value) {
|
|
2630
|
+
return Parsimmon(function(input, i) {
|
|
2631
|
+
return makeSuccess(i, value);
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
function fail(expected) {
|
|
2635
|
+
return Parsimmon(function(input, i) {
|
|
2636
|
+
return makeFailure(i, expected);
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
function lookahead(x) {
|
|
2640
|
+
if (isParser(x)) {
|
|
2641
|
+
return Parsimmon(function(input, i) {
|
|
2642
|
+
var result = x._(input, i);
|
|
2643
|
+
result.index = i;
|
|
2644
|
+
result.value = "";
|
|
2645
|
+
return result;
|
|
2646
|
+
});
|
|
2647
|
+
} else if (typeof x === "string") {
|
|
2648
|
+
return lookahead(string(x));
|
|
2649
|
+
} else if (_instanceof(x, RegExp)) {
|
|
2650
|
+
return lookahead(regexp(x));
|
|
2651
|
+
}
|
|
2652
|
+
throw new Error("not a string, regexp, or parser: " + x);
|
|
2653
|
+
}
|
|
2654
|
+
function notFollowedBy(parser2) {
|
|
2655
|
+
assertParser(parser2);
|
|
2656
|
+
return Parsimmon(function(input, i) {
|
|
2657
|
+
var result = parser2._(input, i);
|
|
2658
|
+
var text = input.slice(i, result.index);
|
|
2659
|
+
return result.status ? makeFailure(i, 'not "' + text + '"') : makeSuccess(i, null);
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
function test(predicate) {
|
|
2663
|
+
assertFunction(predicate);
|
|
2664
|
+
return Parsimmon(function(input, i) {
|
|
2665
|
+
var char = get(input, i);
|
|
2666
|
+
if (i < input.length && predicate(char)) {
|
|
2667
|
+
return makeSuccess(i + 1, char);
|
|
2668
|
+
} else {
|
|
2669
|
+
return makeFailure(i, "a character/byte matching " + predicate);
|
|
2670
|
+
}
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
function oneOf(str) {
|
|
2674
|
+
var expected = str.split("");
|
|
2675
|
+
for(var idx = 0; idx < expected.length; idx++){
|
|
2676
|
+
expected[idx] = "'" + expected[idx] + "'";
|
|
2677
|
+
}
|
|
2678
|
+
return test(function(ch) {
|
|
2679
|
+
return str.indexOf(ch) >= 0;
|
|
2680
|
+
}).desc(expected);
|
|
2681
|
+
}
|
|
2682
|
+
function noneOf(str) {
|
|
2683
|
+
return test(function(ch) {
|
|
2684
|
+
return str.indexOf(ch) < 0;
|
|
2685
|
+
}).desc("none of '" + str + "'");
|
|
2686
|
+
}
|
|
2687
|
+
function custom(parsingFunction) {
|
|
2688
|
+
return Parsimmon(parsingFunction(makeSuccess, makeFailure));
|
|
2689
|
+
}
|
|
2690
|
+
function range(begin, end2) {
|
|
2691
|
+
return test(function(ch) {
|
|
2692
|
+
return begin <= ch && ch <= end2;
|
|
2693
|
+
}).desc(begin + "-" + end2);
|
|
2694
|
+
}
|
|
2695
|
+
function takeWhile(predicate) {
|
|
2696
|
+
assertFunction(predicate);
|
|
2697
|
+
return Parsimmon(function(input, i) {
|
|
2698
|
+
var j = i;
|
|
2699
|
+
while(j < input.length && predicate(get(input, j))){
|
|
2700
|
+
j++;
|
|
2701
|
+
}
|
|
2702
|
+
return makeSuccess(j, input.slice(i, j));
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
function lazy(desc, f) {
|
|
2706
|
+
if (arguments.length < 2) {
|
|
2707
|
+
f = desc;
|
|
2708
|
+
desc = void 0;
|
|
2709
|
+
}
|
|
2710
|
+
var parser2 = Parsimmon(function(input, i) {
|
|
2711
|
+
parser2._ = f()._;
|
|
2712
|
+
return parser2._(input, i);
|
|
2713
|
+
});
|
|
2714
|
+
if (desc) {
|
|
2715
|
+
return parser2.desc(desc);
|
|
2716
|
+
} else {
|
|
2717
|
+
return parser2;
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
function empty() {
|
|
2721
|
+
return fail("fantasy-land/empty");
|
|
2722
|
+
}
|
|
2723
|
+
_.concat = _.or;
|
|
2724
|
+
_.empty = empty;
|
|
2725
|
+
_.of = succeed;
|
|
2726
|
+
_["fantasy-land/ap"] = _.ap;
|
|
2727
|
+
_["fantasy-land/chain"] = _.chain;
|
|
2728
|
+
_["fantasy-land/concat"] = _.concat;
|
|
2729
|
+
_["fantasy-land/empty"] = _.empty;
|
|
2730
|
+
_["fantasy-land/of"] = _.of;
|
|
2731
|
+
_["fantasy-land/map"] = _.map;
|
|
2732
|
+
var index = Parsimmon(function(input, i) {
|
|
2733
|
+
return makeSuccess(i, makeLineColumnIndex(input, i));
|
|
2734
|
+
});
|
|
2735
|
+
var any = Parsimmon(function(input, i) {
|
|
2736
|
+
if (i >= input.length) {
|
|
2737
|
+
return makeFailure(i, "any character/byte");
|
|
2738
|
+
}
|
|
2739
|
+
return makeSuccess(i + 1, get(input, i));
|
|
2740
|
+
});
|
|
2741
|
+
var all = Parsimmon(function(input, i) {
|
|
2742
|
+
return makeSuccess(input.length, input.slice(i));
|
|
2743
|
+
});
|
|
2744
|
+
var eof = Parsimmon(function(input, i) {
|
|
2745
|
+
if (i < input.length) {
|
|
2746
|
+
return makeFailure(i, "EOF");
|
|
2747
|
+
}
|
|
2748
|
+
return makeSuccess(i, null);
|
|
2749
|
+
});
|
|
2750
|
+
var digit = regexp(/[0-9]/).desc("a digit");
|
|
2751
|
+
var digits = regexp(/[0-9]*/).desc("optional digits");
|
|
2752
|
+
var letter = regexp(/[a-z]/i).desc("a letter");
|
|
2753
|
+
var letters = regexp(/[a-z]*/i).desc("optional letters");
|
|
2754
|
+
var optWhitespace = regexp(/\s*/).desc("optional whitespace");
|
|
2755
|
+
var whitespace = regexp(/\s+/).desc("whitespace");
|
|
2756
|
+
var cr = string("\r");
|
|
2757
|
+
var lf = string("\n");
|
|
2758
|
+
var crlf = string("\r\n");
|
|
2759
|
+
var newline = alt(crlf, lf, cr).desc("newline");
|
|
2760
|
+
var end = alt(newline, eof);
|
|
2761
|
+
Parsimmon.all = all;
|
|
2762
|
+
Parsimmon.alt = alt;
|
|
2763
|
+
Parsimmon.any = any;
|
|
2764
|
+
Parsimmon.cr = cr;
|
|
2765
|
+
Parsimmon.createLanguage = createLanguage;
|
|
2766
|
+
Parsimmon.crlf = crlf;
|
|
2767
|
+
Parsimmon.custom = custom;
|
|
2768
|
+
Parsimmon.digit = digit;
|
|
2769
|
+
Parsimmon.digits = digits;
|
|
2770
|
+
Parsimmon.empty = empty;
|
|
2771
|
+
Parsimmon.end = end;
|
|
2772
|
+
Parsimmon.eof = eof;
|
|
2773
|
+
Parsimmon.fail = fail;
|
|
2774
|
+
Parsimmon.formatError = formatError;
|
|
2775
|
+
Parsimmon.index = index;
|
|
2776
|
+
Parsimmon.isParser = isParser;
|
|
2777
|
+
Parsimmon.lazy = lazy;
|
|
2778
|
+
Parsimmon.letter = letter;
|
|
2779
|
+
Parsimmon.letters = letters;
|
|
2780
|
+
Parsimmon.lf = lf;
|
|
2781
|
+
Parsimmon.lookahead = lookahead;
|
|
2782
|
+
Parsimmon.makeFailure = makeFailure;
|
|
2783
|
+
Parsimmon.makeSuccess = makeSuccess;
|
|
2784
|
+
Parsimmon.newline = newline;
|
|
2785
|
+
Parsimmon.noneOf = noneOf;
|
|
2786
|
+
Parsimmon.notFollowedBy = notFollowedBy;
|
|
2787
|
+
Parsimmon.of = succeed;
|
|
2788
|
+
Parsimmon.oneOf = oneOf;
|
|
2789
|
+
Parsimmon.optWhitespace = optWhitespace;
|
|
2790
|
+
Parsimmon.Parser = Parsimmon;
|
|
2791
|
+
Parsimmon.range = range;
|
|
2792
|
+
Parsimmon.regex = regexp;
|
|
2793
|
+
Parsimmon.regexp = regexp;
|
|
2794
|
+
Parsimmon.sepBy = sepBy;
|
|
2795
|
+
Parsimmon.sepBy1 = sepBy1;
|
|
2796
|
+
Parsimmon.seq = seq;
|
|
2797
|
+
Parsimmon.seqMap = seqMap;
|
|
2798
|
+
Parsimmon.seqObj = seqObj;
|
|
2799
|
+
Parsimmon.string = string;
|
|
2800
|
+
Parsimmon.succeed = succeed;
|
|
2801
|
+
Parsimmon.takeWhile = takeWhile;
|
|
2802
|
+
Parsimmon.test = test;
|
|
2803
|
+
Parsimmon.whitespace = whitespace;
|
|
2804
|
+
Parsimmon["fantasy-land/empty"] = empty;
|
|
2805
|
+
Parsimmon["fantasy-land/of"] = succeed;
|
|
2806
|
+
Parsimmon.Binary = {
|
|
2807
|
+
bitSeq: bitSeq,
|
|
2808
|
+
bitSeqObj: bitSeqObj,
|
|
2809
|
+
byte: byte,
|
|
2810
|
+
buffer: parseBuffer,
|
|
2811
|
+
encodedString: encodedString,
|
|
2812
|
+
uintBE: uintBE,
|
|
2813
|
+
uint8BE: uintBE(1),
|
|
2814
|
+
uint16BE: uintBE(2),
|
|
2815
|
+
uint32BE: uintBE(4),
|
|
2816
|
+
uintLE: uintLE,
|
|
2817
|
+
uint8LE: uintLE(1),
|
|
2818
|
+
uint16LE: uintLE(2),
|
|
2819
|
+
uint32LE: uintLE(4),
|
|
2820
|
+
intBE: intBE,
|
|
2821
|
+
int8BE: intBE(1),
|
|
2822
|
+
int16BE: intBE(2),
|
|
2823
|
+
int32BE: intBE(4),
|
|
2824
|
+
intLE: intLE,
|
|
2825
|
+
int8LE: intLE(1),
|
|
2826
|
+
int16LE: intLE(2),
|
|
2827
|
+
int32LE: intLE(4),
|
|
2828
|
+
floatBE: floatBE(),
|
|
2829
|
+
floatLE: floatLE(),
|
|
2830
|
+
doubleBE: doubleBE(),
|
|
2831
|
+
doubleLE: doubleLE()
|
|
2832
|
+
};
|
|
2833
|
+
module.exports = Parsimmon;
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/TokenError.js
|
|
2837
|
+
var require_TokenError = __commonJS({
|
|
2838
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/TokenError.js": function(exports) {
|
|
2839
|
+
"use strict";
|
|
2840
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2841
|
+
value: true
|
|
2842
|
+
});
|
|
2843
|
+
exports.TokenError = void 0;
|
|
2844
|
+
var TokenError = /*#__PURE__*/ function(Error1) {
|
|
2845
|
+
_inherits(TokenError, Error1);
|
|
2846
|
+
var _super = _create_super(TokenError);
|
|
2847
|
+
function TokenError(message, token) {
|
|
2848
|
+
_class_call_check(this, TokenError);
|
|
2849
|
+
var _this;
|
|
2850
|
+
_this = _super.call(this, message);
|
|
2851
|
+
_this.message = message;
|
|
2852
|
+
_this.token = token;
|
|
2853
|
+
if (token && token.errors) token.errors.push(_assert_this_initialized(_this));
|
|
2854
|
+
else throw _assert_this_initialized(_this);
|
|
2855
|
+
return _this;
|
|
2856
|
+
}
|
|
2857
|
+
_create_class(TokenError, [
|
|
2858
|
+
{
|
|
2859
|
+
key: "inspect",
|
|
2860
|
+
value: function inspect() {
|
|
2861
|
+
return "SyntaxError: " + this.message;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
]);
|
|
2865
|
+
return TokenError;
|
|
2866
|
+
}(_wrap_native_super(Error));
|
|
2867
|
+
exports.TokenError = TokenError;
|
|
2868
|
+
}
|
|
2869
|
+
});
|
|
2870
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Parser.js
|
|
2871
|
+
var require_Parser = __commonJS({
|
|
2872
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Parser.js": function(exports) {
|
|
2873
|
+
"use strict";
|
|
2874
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2875
|
+
value: true
|
|
2876
|
+
});
|
|
2877
|
+
exports.Parser = exports.findRuleByName = exports.parseRuleName = exports.escapeRegExp = exports.readToken = void 0;
|
|
2878
|
+
var UPPER_SNAKE_RE = /^[A-Z0-9_]+$/;
|
|
2879
|
+
var decorationRE = /(\?|\+|\*)$/;
|
|
2880
|
+
var preDecorationRE = /^(@|&|!)/;
|
|
2881
|
+
var WS_RULE = "WS";
|
|
2882
|
+
var TokenError_1 = require_TokenError();
|
|
2883
|
+
function readToken(txt, expr) {
|
|
2884
|
+
var result = expr.exec(txt);
|
|
2885
|
+
if (result && result.index == 0) {
|
|
2886
|
+
if (result[0].length == 0 && expr.source.length > 0) return null;
|
|
2887
|
+
return {
|
|
2888
|
+
type: null,
|
|
2889
|
+
text: result[0],
|
|
2890
|
+
rest: txt.substr(result[0].length),
|
|
2891
|
+
start: 0,
|
|
2892
|
+
end: result[0].length - 1,
|
|
2893
|
+
fullText: result[0],
|
|
2894
|
+
errors: [],
|
|
2895
|
+
children: [],
|
|
2896
|
+
parent: null
|
|
2897
|
+
};
|
|
2898
|
+
}
|
|
2899
|
+
return null;
|
|
2900
|
+
}
|
|
2901
|
+
exports.readToken = readToken;
|
|
2902
|
+
function escapeRegExp(str) {
|
|
2903
|
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
2904
|
+
}
|
|
2905
|
+
exports.escapeRegExp = escapeRegExp;
|
|
2906
|
+
function fixRest(token) {
|
|
2907
|
+
token.rest = "";
|
|
2908
|
+
token.children && token.children.forEach(function(c) {
|
|
2909
|
+
return fixRest(c);
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
function fixPositions(token, start) {
|
|
2913
|
+
token.start += start;
|
|
2914
|
+
token.end += start;
|
|
2915
|
+
token.children && token.children.forEach(function(c) {
|
|
2916
|
+
return fixPositions(c, token.start);
|
|
2917
|
+
});
|
|
2918
|
+
}
|
|
2919
|
+
function agregateErrors(errors, token) {
|
|
2920
|
+
if (token.errors && token.errors.length) token.errors.forEach(function(err) {
|
|
2921
|
+
return errors.push(err);
|
|
2922
|
+
});
|
|
2923
|
+
token.children && token.children.forEach(function(tok) {
|
|
2924
|
+
return agregateErrors(errors, tok);
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
function parseRuleName(name) {
|
|
2928
|
+
var postDecoration = decorationRE.exec(name);
|
|
2929
|
+
var preDecoration = preDecorationRE.exec(name);
|
|
2930
|
+
var postDecorationText = postDecoration && postDecoration[0] || "";
|
|
2931
|
+
var preDecorationText = preDecoration && preDecoration[0] || "";
|
|
2932
|
+
var out = {
|
|
2933
|
+
raw: name,
|
|
2934
|
+
name: name.replace(decorationRE, "").replace(preDecorationRE, ""),
|
|
2935
|
+
isOptional: postDecorationText == "?" || postDecorationText == "*",
|
|
2936
|
+
allowRepetition: postDecorationText == "+" || postDecorationText == "*",
|
|
2937
|
+
atLeastOne: postDecorationText == "+",
|
|
2938
|
+
lookupPositive: preDecorationText == "&",
|
|
2939
|
+
lookupNegative: preDecorationText == "!",
|
|
2940
|
+
pinned: preDecorationText == "@",
|
|
2941
|
+
lookup: false,
|
|
2942
|
+
isLiteral: false
|
|
2943
|
+
};
|
|
2944
|
+
out.isLiteral = out.name[0] == "'" || out.name[0] == '"';
|
|
2945
|
+
out.lookup = out.lookupNegative || out.lookupPositive;
|
|
2946
|
+
return out;
|
|
2947
|
+
}
|
|
2948
|
+
exports.parseRuleName = parseRuleName;
|
|
2949
|
+
function findRuleByName(name, parser2) {
|
|
2950
|
+
var parsed = parseRuleName(name);
|
|
2951
|
+
return parser2.cachedRules[parsed.name] || null;
|
|
2952
|
+
}
|
|
2953
|
+
exports.findRuleByName = findRuleByName;
|
|
2954
|
+
function stripRules(token, re) {
|
|
2955
|
+
if (token.children) {
|
|
2956
|
+
var localRules = token.children.filter(function(x) {
|
|
2957
|
+
return x.type && re.test(x.type);
|
|
2958
|
+
});
|
|
2959
|
+
for(var i = 0; i < localRules.length; i++){
|
|
2960
|
+
var indexOnChildren = token.children.indexOf(localRules[i]);
|
|
2961
|
+
if (indexOnChildren != -1) {
|
|
2962
|
+
token.children.splice(indexOnChildren, 1);
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
token.children.forEach(function(c) {
|
|
2966
|
+
return stripRules(c, re);
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
var ignoreMissingRules = [
|
|
2971
|
+
"EOF"
|
|
2972
|
+
];
|
|
2973
|
+
var Parser2 = /*#__PURE__*/ function() {
|
|
2974
|
+
function Parser2(grammarRules, options) {
|
|
2975
|
+
var _this = this;
|
|
2976
|
+
_class_call_check(this, Parser2);
|
|
2977
|
+
this.grammarRules = grammarRules;
|
|
2978
|
+
this.options = options;
|
|
2979
|
+
this.cachedRules = {};
|
|
2980
|
+
this.debug = options ? options.debug === true : false;
|
|
2981
|
+
var errors = [];
|
|
2982
|
+
var neededRules = [];
|
|
2983
|
+
grammarRules.forEach(function(rule) {
|
|
2984
|
+
var parsedName = parseRuleName(rule.name);
|
|
2985
|
+
if (parsedName.name in _this.cachedRules) {
|
|
2986
|
+
errors.push("Duplicated rule " + parsedName.name);
|
|
2987
|
+
return;
|
|
2988
|
+
} else {
|
|
2989
|
+
_this.cachedRules[parsedName.name] = rule;
|
|
2990
|
+
}
|
|
2991
|
+
if (!rule.bnf || !rule.bnf.length) {
|
|
2992
|
+
var error = "Missing rule content, rule: " + rule.name;
|
|
2993
|
+
if (errors.indexOf(error) == -1) errors.push(error);
|
|
2994
|
+
} else {
|
|
2995
|
+
rule.bnf.forEach(function(options2) {
|
|
2996
|
+
if (typeof options2[0] === "string") {
|
|
2997
|
+
var parsed = parseRuleName(options2[0]);
|
|
2998
|
+
if (parsed.name == rule.name) {
|
|
2999
|
+
var error = "Left recursion is not allowed, rule: " + rule.name;
|
|
3000
|
+
if (errors.indexOf(error) == -1) errors.push(error);
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
options2.forEach(function(option) {
|
|
3004
|
+
if (typeof option == "string") {
|
|
3005
|
+
var name = parseRuleName(option);
|
|
3006
|
+
if (!name.isLiteral && neededRules.indexOf(name.name) == -1 && ignoreMissingRules.indexOf(name.name) == -1) neededRules.push(name.name);
|
|
3007
|
+
}
|
|
3008
|
+
});
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
if (WS_RULE == rule.name) rule.implicitWs = false;
|
|
3012
|
+
if (rule.implicitWs) {
|
|
3013
|
+
if (neededRules.indexOf(WS_RULE) == -1) neededRules.push(WS_RULE);
|
|
3014
|
+
}
|
|
3015
|
+
if (rule.recover) {
|
|
3016
|
+
if (neededRules.indexOf(rule.recover) == -1) neededRules.push(rule.recover);
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
neededRules.forEach(function(ruleName) {
|
|
3020
|
+
if (!(ruleName in _this.cachedRules)) {
|
|
3021
|
+
errors.push("Missing rule " + ruleName);
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
if (errors.length) throw new Error(errors.join("\n"));
|
|
3025
|
+
}
|
|
3026
|
+
_create_class(Parser2, [
|
|
3027
|
+
{
|
|
3028
|
+
key: "getAST",
|
|
3029
|
+
value: function getAST(txt, target) {
|
|
3030
|
+
if (!target) {
|
|
3031
|
+
target = this.grammarRules.filter(function(x) {
|
|
3032
|
+
return !x.fragment && x.name.indexOf("%") != 0;
|
|
3033
|
+
})[0].name;
|
|
3034
|
+
}
|
|
3035
|
+
var result = this.parse(txt, target);
|
|
3036
|
+
if (result) {
|
|
3037
|
+
agregateErrors(result.errors, result);
|
|
3038
|
+
fixPositions(result, 0);
|
|
3039
|
+
stripRules(result, /^%/);
|
|
3040
|
+
if (!this.options || !this.options.keepUpperRules) stripRules(result, UPPER_SNAKE_RE);
|
|
3041
|
+
var rest = result.rest;
|
|
3042
|
+
if (rest) {
|
|
3043
|
+
new TokenError_1.TokenError("Unexpected end of input: \n" + rest, result);
|
|
3044
|
+
}
|
|
3045
|
+
fixRest(result);
|
|
3046
|
+
result.rest = rest;
|
|
3047
|
+
}
|
|
3048
|
+
return result;
|
|
3049
|
+
}
|
|
3050
|
+
},
|
|
3051
|
+
{
|
|
3052
|
+
key: "emitSource",
|
|
3053
|
+
value: function emitSource() {
|
|
3054
|
+
return "CANNOT EMIT SOURCE FROM BASE Parser";
|
|
3055
|
+
}
|
|
3056
|
+
},
|
|
3057
|
+
{
|
|
3058
|
+
key: "parse",
|
|
3059
|
+
value: function parse(txt, target) {
|
|
3060
|
+
var _this = this;
|
|
3061
|
+
var recursion = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
|
|
3062
|
+
var out = null;
|
|
3063
|
+
var type = parseRuleName(target);
|
|
3064
|
+
var expr;
|
|
3065
|
+
var printable = this.debug && /*!isLiteral &*/ !UPPER_SNAKE_RE.test(type.name);
|
|
3066
|
+
printable && console.log(new Array(recursion).join("\u2502 ") + "Trying to get " + target + " from " + JSON.stringify(txt.split("\n")[0]));
|
|
3067
|
+
var realType = type.name;
|
|
3068
|
+
var targetLex = findRuleByName(type.name, this);
|
|
3069
|
+
if (type.name == "EOF") {
|
|
3070
|
+
if (txt.length) {
|
|
3071
|
+
return null;
|
|
3072
|
+
} else if (txt.length == 0) {
|
|
3073
|
+
return {
|
|
3074
|
+
type: "EOF",
|
|
3075
|
+
text: "",
|
|
3076
|
+
rest: "",
|
|
3077
|
+
start: 0,
|
|
3078
|
+
end: 0,
|
|
3079
|
+
fullText: "",
|
|
3080
|
+
errors: [],
|
|
3081
|
+
children: [],
|
|
3082
|
+
parent: null
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
try {
|
|
3087
|
+
if (!targetLex && type.isLiteral) {
|
|
3088
|
+
var src = type.name.trim();
|
|
3089
|
+
if (src.startsWith('"')) {
|
|
3090
|
+
src = JSON.parse(src);
|
|
3091
|
+
} else if (src.startsWith("'")) {
|
|
3092
|
+
src = src.replace(/^'(.+)'$/, "$1").replace(/\\'/g, "'");
|
|
3093
|
+
}
|
|
3094
|
+
if (src === "") {
|
|
3095
|
+
return {
|
|
3096
|
+
type: "%%EMPTY%%",
|
|
3097
|
+
text: "",
|
|
3098
|
+
rest: txt,
|
|
3099
|
+
start: 0,
|
|
3100
|
+
end: 0,
|
|
3101
|
+
fullText: "",
|
|
3102
|
+
errors: [],
|
|
3103
|
+
children: [],
|
|
3104
|
+
parent: null
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
expr = new RegExp(escapeRegExp(src));
|
|
3108
|
+
realType = null;
|
|
3109
|
+
}
|
|
3110
|
+
} catch (e) {
|
|
3111
|
+
if (_instanceof(e, ReferenceError)) {
|
|
3112
|
+
console.error(e);
|
|
3113
|
+
}
|
|
3114
|
+
return null;
|
|
3115
|
+
}
|
|
3116
|
+
if (expr) {
|
|
3117
|
+
var result = readToken(txt, expr);
|
|
3118
|
+
if (result) {
|
|
3119
|
+
result.type = realType;
|
|
3120
|
+
return result;
|
|
3121
|
+
}
|
|
3122
|
+
} else {
|
|
3123
|
+
var options = targetLex.bnf;
|
|
3124
|
+
if (_instanceof(options, Array)) {
|
|
3125
|
+
options.forEach(function(phases) {
|
|
3126
|
+
var _loop = function(i) {
|
|
3127
|
+
if (typeof phases[i] == "string") {
|
|
3128
|
+
var _loop = function() {
|
|
3129
|
+
got = null;
|
|
3130
|
+
if (targetLex.implicitWs) {
|
|
3131
|
+
got = _this.parse(tmpTxt, localTarget.name, recursion + 1);
|
|
3132
|
+
if (!got) {
|
|
3133
|
+
var WS = void 0;
|
|
3134
|
+
do {
|
|
3135
|
+
WS = _this.parse(tmpTxt, WS_RULE, recursion + 1);
|
|
3136
|
+
if (WS) {
|
|
3137
|
+
tmp.text = tmp.text + WS.text;
|
|
3138
|
+
tmp.end = tmp.text.length;
|
|
3139
|
+
WS.parent = tmp;
|
|
3140
|
+
tmp.children.push(WS);
|
|
3141
|
+
tmpTxt = tmpTxt.substr(WS.text.length);
|
|
3142
|
+
position += WS.text.length;
|
|
3143
|
+
} else {
|
|
3144
|
+
break;
|
|
3145
|
+
}
|
|
3146
|
+
}while (WS && WS.text.length);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
got = got || _this.parse(tmpTxt, localTarget.name, recursion + 1);
|
|
3150
|
+
if (localTarget.lookupNegative) {
|
|
3151
|
+
if (got) return {
|
|
3152
|
+
v: void void 0
|
|
3153
|
+
};
|
|
3154
|
+
return "break";
|
|
3155
|
+
}
|
|
3156
|
+
if (localTarget.lookupPositive) {
|
|
3157
|
+
if (!got) return {
|
|
3158
|
+
v: void void 0
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
if (!got) {
|
|
3162
|
+
if (localTarget.isOptional) return "break";
|
|
3163
|
+
if (localTarget.atLeastOne && foundAtLeastOne) return "break";
|
|
3164
|
+
}
|
|
3165
|
+
if (got && targetLex.pinned == i + 1) {
|
|
3166
|
+
pinned = got;
|
|
3167
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "\u2514\u2500 " + got.type + " PINNED");
|
|
3168
|
+
}
|
|
3169
|
+
if (!got) got = _this.parseRecovery(targetLex, tmpTxt, recursion + 1);
|
|
3170
|
+
if (!got) {
|
|
3171
|
+
if (pinned) {
|
|
3172
|
+
out = tmp;
|
|
3173
|
+
got = {
|
|
3174
|
+
type: "SyntaxError",
|
|
3175
|
+
text: tmpTxt,
|
|
3176
|
+
children: [],
|
|
3177
|
+
end: tmpTxt.length,
|
|
3178
|
+
errors: [],
|
|
3179
|
+
fullText: "",
|
|
3180
|
+
parent: null,
|
|
3181
|
+
start: 0,
|
|
3182
|
+
rest: ""
|
|
3183
|
+
};
|
|
3184
|
+
if (tmpTxt.length) {
|
|
3185
|
+
new TokenError_1.TokenError("Unexpected end of input. Expecting ".concat(localTarget.name, " Got: ").concat(tmpTxt), got);
|
|
3186
|
+
} else {
|
|
3187
|
+
new TokenError_1.TokenError("Unexpected end of input. Missing ".concat(localTarget.name), got);
|
|
3188
|
+
}
|
|
3189
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "\u2514\u2500 " + got.type + " " + JSON.stringify(got.text));
|
|
3190
|
+
} else {
|
|
3191
|
+
return {
|
|
3192
|
+
v: void void 0
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
foundAtLeastOne = true;
|
|
3197
|
+
foundSomething = true;
|
|
3198
|
+
if (got.type == "%%EMPTY%%") {
|
|
3199
|
+
return "break";
|
|
3200
|
+
}
|
|
3201
|
+
got.start += position;
|
|
3202
|
+
got.end += position;
|
|
3203
|
+
if (!localTarget.lookupPositive && got.type) {
|
|
3204
|
+
if (got.fragment) {
|
|
3205
|
+
got.children && got.children.forEach(function(x) {
|
|
3206
|
+
x.start += position;
|
|
3207
|
+
x.end += position;
|
|
3208
|
+
x.parent = tmp;
|
|
3209
|
+
tmp.children.push(x);
|
|
3210
|
+
});
|
|
3211
|
+
} else {
|
|
3212
|
+
got.parent = tmp;
|
|
3213
|
+
tmp.children.push(got);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
if (localTarget.lookup) got.lookup = true;
|
|
3217
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "\u2514\u2500 " + got.type + " " + JSON.stringify(got.text));
|
|
3218
|
+
if (!localTarget.lookup && !got.lookup) {
|
|
3219
|
+
tmp.text = tmp.text + got.text;
|
|
3220
|
+
tmp.end = tmp.text.length;
|
|
3221
|
+
tmpTxt = tmpTxt.substr(got.text.length);
|
|
3222
|
+
position += got.text.length;
|
|
3223
|
+
}
|
|
3224
|
+
tmp.rest = tmpTxt;
|
|
3225
|
+
};
|
|
3226
|
+
var localTarget = parseRuleName(phases[i]);
|
|
3227
|
+
allOptional = allOptional && localTarget.isOptional;
|
|
3228
|
+
var got = void 0;
|
|
3229
|
+
var foundAtLeastOne = false;
|
|
3230
|
+
do {
|
|
3231
|
+
var _ret = _loop();
|
|
3232
|
+
if (_type_of(_ret) === "object") return {
|
|
3233
|
+
v: _ret.v
|
|
3234
|
+
};
|
|
3235
|
+
if (_ret === "break") break;
|
|
3236
|
+
}while (got && localTarget.allowRepetition && tmpTxt.length && !got.lookup);
|
|
3237
|
+
} else {
|
|
3238
|
+
var got1 = readToken(tmpTxt, phases[i]);
|
|
3239
|
+
if (!got1) {
|
|
3240
|
+
return {
|
|
3241
|
+
v: void void 0
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "\u2514> " + JSON.stringify(got1.text) + phases[i].source);
|
|
3245
|
+
foundSomething = true;
|
|
3246
|
+
got1.start += position;
|
|
3247
|
+
got1.end += position;
|
|
3248
|
+
tmp.text = tmp.text + got1.text;
|
|
3249
|
+
tmp.end = tmp.text.length;
|
|
3250
|
+
tmpTxt = tmpTxt.substr(got1.text.length);
|
|
3251
|
+
position += got1.text.length;
|
|
3252
|
+
tmp.rest = tmpTxt;
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
if (out) return;
|
|
3256
|
+
var pinned = null;
|
|
3257
|
+
var tmp = {
|
|
3258
|
+
type: type.name,
|
|
3259
|
+
text: "",
|
|
3260
|
+
children: [],
|
|
3261
|
+
end: 0,
|
|
3262
|
+
errors: [],
|
|
3263
|
+
fullText: "",
|
|
3264
|
+
parent: null,
|
|
3265
|
+
start: 0,
|
|
3266
|
+
rest: txt
|
|
3267
|
+
};
|
|
3268
|
+
if (targetLex.fragment) tmp.fragment = true;
|
|
3269
|
+
var tmpTxt = txt;
|
|
3270
|
+
var position = 0;
|
|
3271
|
+
var allOptional = phases.length > 0;
|
|
3272
|
+
var foundSomething = false;
|
|
3273
|
+
for(var i = 0; i < phases.length; i++){
|
|
3274
|
+
var _ret = _loop(i);
|
|
3275
|
+
if (_type_of(_ret) === "object") return _ret.v;
|
|
3276
|
+
}
|
|
3277
|
+
if (foundSomething) {
|
|
3278
|
+
out = tmp;
|
|
3279
|
+
printable && console.log(new Array(recursion).join("\u2502 ") + "\u251C<\u2500\u2534< PUSHING " + out.type + " " + JSON.stringify(out.text));
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
if (out && targetLex.simplifyWhenOneChildren && out.children.length == 1) {
|
|
3284
|
+
out = out.children[0];
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
if (!out) {
|
|
3288
|
+
printable && console.log(target + " NOT RESOLVED FROM " + txt);
|
|
3289
|
+
}
|
|
3290
|
+
return out;
|
|
3291
|
+
}
|
|
3292
|
+
},
|
|
3293
|
+
{
|
|
3294
|
+
key: "parseRecovery",
|
|
3295
|
+
value: function parseRecovery(recoverableToken, tmpTxt, recursion) {
|
|
3296
|
+
if (recoverableToken.recover && tmpTxt.length) {
|
|
3297
|
+
var printable = this.debug;
|
|
3298
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "Trying to recover until token " + recoverableToken.recover + " from " + JSON.stringify(tmpTxt.split("\n")[0] + tmpTxt.split("\n")[1]));
|
|
3299
|
+
var tmp = {
|
|
3300
|
+
type: "SyntaxError",
|
|
3301
|
+
text: "",
|
|
3302
|
+
children: [],
|
|
3303
|
+
end: 0,
|
|
3304
|
+
errors: [],
|
|
3305
|
+
fullText: "",
|
|
3306
|
+
parent: null,
|
|
3307
|
+
start: 0,
|
|
3308
|
+
rest: ""
|
|
3309
|
+
};
|
|
3310
|
+
var got;
|
|
3311
|
+
do {
|
|
3312
|
+
got = this.parse(tmpTxt, recoverableToken.recover, recursion + 1);
|
|
3313
|
+
if (got) {
|
|
3314
|
+
new TokenError_1.TokenError('Unexpected input: "' + tmp.text + '" Expecting: '.concat(recoverableToken.name), tmp);
|
|
3315
|
+
break;
|
|
3316
|
+
} else {
|
|
3317
|
+
tmp.text = tmp.text + tmpTxt[0];
|
|
3318
|
+
tmp.end = tmp.text.length;
|
|
3319
|
+
tmpTxt = tmpTxt.substr(1);
|
|
3320
|
+
}
|
|
3321
|
+
}while (!got && tmpTxt.length > 0);
|
|
3322
|
+
if (tmp.text.length > 0 && got) {
|
|
3323
|
+
printable && console.log(new Array(recursion + 1).join("\u2502 ") + "Recovered text: " + JSON.stringify(tmp.text));
|
|
3324
|
+
return tmp;
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
return null;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
]);
|
|
3331
|
+
return Parser2;
|
|
3332
|
+
}();
|
|
3333
|
+
exports.Parser = Parser2;
|
|
3334
|
+
exports.default = Parser2;
|
|
3335
|
+
}
|
|
3336
|
+
});
|
|
3337
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/SemanticHelpers.js
|
|
3338
|
+
var require_SemanticHelpers = __commonJS({
|
|
3339
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/SemanticHelpers.js": function(exports) {
|
|
3340
|
+
"use strict";
|
|
3341
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3342
|
+
value: true
|
|
3343
|
+
});
|
|
3344
|
+
exports.findChildrenByType = void 0;
|
|
3345
|
+
function findChildrenByType(token, type) {
|
|
3346
|
+
return token.children ? token.children.filter(function(x) {
|
|
3347
|
+
return x.type == type;
|
|
3348
|
+
}) : [];
|
|
3349
|
+
}
|
|
3350
|
+
exports.findChildrenByType = findChildrenByType;
|
|
3351
|
+
}
|
|
3352
|
+
});
|
|
3353
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/BNF.js
|
|
3354
|
+
var require_BNF = __commonJS({
|
|
3355
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/BNF.js": function(exports) {
|
|
3356
|
+
"use strict";
|
|
3357
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3358
|
+
value: true
|
|
3359
|
+
});
|
|
3360
|
+
var SemanticHelpers_1 = require_SemanticHelpers();
|
|
3361
|
+
var Parser_1 = require_Parser();
|
|
3362
|
+
var BNF;
|
|
3363
|
+
(function(BNF2) {
|
|
3364
|
+
BNF2.RULES = [
|
|
3365
|
+
{
|
|
3366
|
+
name: "syntax",
|
|
3367
|
+
bnf: [
|
|
3368
|
+
[
|
|
3369
|
+
"RULE_EOL*",
|
|
3370
|
+
"rule+"
|
|
3371
|
+
]
|
|
3372
|
+
]
|
|
3373
|
+
},
|
|
3374
|
+
{
|
|
3375
|
+
name: "rule",
|
|
3376
|
+
bnf: [
|
|
3377
|
+
[
|
|
3378
|
+
'" "*',
|
|
3379
|
+
'"<"',
|
|
3380
|
+
"rule-name",
|
|
3381
|
+
'">"',
|
|
3382
|
+
'" "*',
|
|
3383
|
+
'"::="',
|
|
3384
|
+
"firstExpression",
|
|
3385
|
+
"otherExpression*",
|
|
3386
|
+
'" "*',
|
|
3387
|
+
"RULE_EOL+",
|
|
3388
|
+
'" "*'
|
|
3389
|
+
]
|
|
3390
|
+
]
|
|
3391
|
+
},
|
|
3392
|
+
{
|
|
3393
|
+
name: "firstExpression",
|
|
3394
|
+
bnf: [
|
|
3395
|
+
[
|
|
3396
|
+
'" "*',
|
|
3397
|
+
"list"
|
|
3398
|
+
]
|
|
3399
|
+
]
|
|
3400
|
+
},
|
|
3401
|
+
{
|
|
3402
|
+
name: "otherExpression",
|
|
3403
|
+
bnf: [
|
|
3404
|
+
[
|
|
3405
|
+
'" "*',
|
|
3406
|
+
'"|"',
|
|
3407
|
+
'" "*',
|
|
3408
|
+
"list"
|
|
3409
|
+
]
|
|
3410
|
+
]
|
|
3411
|
+
},
|
|
3412
|
+
{
|
|
3413
|
+
name: "RULE_EOL",
|
|
3414
|
+
bnf: [
|
|
3415
|
+
[
|
|
3416
|
+
'"\\r"'
|
|
3417
|
+
],
|
|
3418
|
+
[
|
|
3419
|
+
'"\\n"'
|
|
3420
|
+
]
|
|
3421
|
+
]
|
|
3422
|
+
},
|
|
3423
|
+
{
|
|
3424
|
+
name: "list",
|
|
3425
|
+
bnf: [
|
|
3426
|
+
[
|
|
3427
|
+
"term",
|
|
3428
|
+
'" "*',
|
|
3429
|
+
"list"
|
|
3430
|
+
],
|
|
3431
|
+
[
|
|
3432
|
+
"term"
|
|
3433
|
+
]
|
|
3434
|
+
]
|
|
3435
|
+
},
|
|
3436
|
+
{
|
|
3437
|
+
name: "term",
|
|
3438
|
+
bnf: [
|
|
3439
|
+
[
|
|
3440
|
+
"literal"
|
|
3441
|
+
],
|
|
3442
|
+
[
|
|
3443
|
+
'"<"',
|
|
3444
|
+
"rule-name",
|
|
3445
|
+
'">"'
|
|
3446
|
+
]
|
|
3447
|
+
]
|
|
3448
|
+
},
|
|
3449
|
+
{
|
|
3450
|
+
name: "literal",
|
|
3451
|
+
bnf: [
|
|
3452
|
+
[
|
|
3453
|
+
"'\"'",
|
|
3454
|
+
"RULE_CHARACTER1*",
|
|
3455
|
+
"'\"'"
|
|
3456
|
+
],
|
|
3457
|
+
[
|
|
3458
|
+
'"\'"',
|
|
3459
|
+
"RULE_CHARACTER2*",
|
|
3460
|
+
'"\'"'
|
|
3461
|
+
]
|
|
3462
|
+
]
|
|
3463
|
+
},
|
|
3464
|
+
{
|
|
3465
|
+
name: "RULE_CHARACTER",
|
|
3466
|
+
bnf: [
|
|
3467
|
+
[
|
|
3468
|
+
'" "'
|
|
3469
|
+
],
|
|
3470
|
+
[
|
|
3471
|
+
"RULE_LETTER"
|
|
3472
|
+
],
|
|
3473
|
+
[
|
|
3474
|
+
"RULE_DIGIT"
|
|
3475
|
+
],
|
|
3476
|
+
[
|
|
3477
|
+
"RULE_SYMBOL"
|
|
3478
|
+
]
|
|
3479
|
+
]
|
|
3480
|
+
},
|
|
3481
|
+
{
|
|
3482
|
+
name: "RULE_LETTER",
|
|
3483
|
+
bnf: [
|
|
3484
|
+
[
|
|
3485
|
+
'"A"'
|
|
3486
|
+
],
|
|
3487
|
+
[
|
|
3488
|
+
'"B"'
|
|
3489
|
+
],
|
|
3490
|
+
[
|
|
3491
|
+
'"C"'
|
|
3492
|
+
],
|
|
3493
|
+
[
|
|
3494
|
+
'"D"'
|
|
3495
|
+
],
|
|
3496
|
+
[
|
|
3497
|
+
'"E"'
|
|
3498
|
+
],
|
|
3499
|
+
[
|
|
3500
|
+
'"F"'
|
|
3501
|
+
],
|
|
3502
|
+
[
|
|
3503
|
+
'"G"'
|
|
3504
|
+
],
|
|
3505
|
+
[
|
|
3506
|
+
'"H"'
|
|
3507
|
+
],
|
|
3508
|
+
[
|
|
3509
|
+
'"I"'
|
|
3510
|
+
],
|
|
3511
|
+
[
|
|
3512
|
+
'"J"'
|
|
3513
|
+
],
|
|
3514
|
+
[
|
|
3515
|
+
'"K"'
|
|
3516
|
+
],
|
|
3517
|
+
[
|
|
3518
|
+
'"L"'
|
|
3519
|
+
],
|
|
3520
|
+
[
|
|
3521
|
+
'"M"'
|
|
3522
|
+
],
|
|
3523
|
+
[
|
|
3524
|
+
'"N"'
|
|
3525
|
+
],
|
|
3526
|
+
[
|
|
3527
|
+
'"O"'
|
|
3528
|
+
],
|
|
3529
|
+
[
|
|
3530
|
+
'"P"'
|
|
3531
|
+
],
|
|
3532
|
+
[
|
|
3533
|
+
'"Q"'
|
|
3534
|
+
],
|
|
3535
|
+
[
|
|
3536
|
+
'"R"'
|
|
3537
|
+
],
|
|
3538
|
+
[
|
|
3539
|
+
'"S"'
|
|
3540
|
+
],
|
|
3541
|
+
[
|
|
3542
|
+
'"T"'
|
|
3543
|
+
],
|
|
3544
|
+
[
|
|
3545
|
+
'"U"'
|
|
3546
|
+
],
|
|
3547
|
+
[
|
|
3548
|
+
'"V"'
|
|
3549
|
+
],
|
|
3550
|
+
[
|
|
3551
|
+
'"W"'
|
|
3552
|
+
],
|
|
3553
|
+
[
|
|
3554
|
+
'"X"'
|
|
3555
|
+
],
|
|
3556
|
+
[
|
|
3557
|
+
'"Y"'
|
|
3558
|
+
],
|
|
3559
|
+
[
|
|
3560
|
+
'"Z"'
|
|
3561
|
+
],
|
|
3562
|
+
[
|
|
3563
|
+
'"a"'
|
|
3564
|
+
],
|
|
3565
|
+
[
|
|
3566
|
+
'"b"'
|
|
3567
|
+
],
|
|
3568
|
+
[
|
|
3569
|
+
'"c"'
|
|
3570
|
+
],
|
|
3571
|
+
[
|
|
3572
|
+
'"d"'
|
|
3573
|
+
],
|
|
3574
|
+
[
|
|
3575
|
+
'"e"'
|
|
3576
|
+
],
|
|
3577
|
+
[
|
|
3578
|
+
'"f"'
|
|
3579
|
+
],
|
|
3580
|
+
[
|
|
3581
|
+
'"g"'
|
|
3582
|
+
],
|
|
3583
|
+
[
|
|
3584
|
+
'"h"'
|
|
3585
|
+
],
|
|
3586
|
+
[
|
|
3587
|
+
'"i"'
|
|
3588
|
+
],
|
|
3589
|
+
[
|
|
3590
|
+
'"j"'
|
|
3591
|
+
],
|
|
3592
|
+
[
|
|
3593
|
+
'"k"'
|
|
3594
|
+
],
|
|
3595
|
+
[
|
|
3596
|
+
'"l"'
|
|
3597
|
+
],
|
|
3598
|
+
[
|
|
3599
|
+
'"m"'
|
|
3600
|
+
],
|
|
3601
|
+
[
|
|
3602
|
+
'"n"'
|
|
3603
|
+
],
|
|
3604
|
+
[
|
|
3605
|
+
'"o"'
|
|
3606
|
+
],
|
|
3607
|
+
[
|
|
3608
|
+
'"p"'
|
|
3609
|
+
],
|
|
3610
|
+
[
|
|
3611
|
+
'"q"'
|
|
3612
|
+
],
|
|
3613
|
+
[
|
|
3614
|
+
'"r"'
|
|
3615
|
+
],
|
|
3616
|
+
[
|
|
3617
|
+
'"s"'
|
|
3618
|
+
],
|
|
3619
|
+
[
|
|
3620
|
+
'"t"'
|
|
3621
|
+
],
|
|
3622
|
+
[
|
|
3623
|
+
'"u"'
|
|
3624
|
+
],
|
|
3625
|
+
[
|
|
3626
|
+
'"v"'
|
|
3627
|
+
],
|
|
3628
|
+
[
|
|
3629
|
+
'"w"'
|
|
3630
|
+
],
|
|
3631
|
+
[
|
|
3632
|
+
'"x"'
|
|
3633
|
+
],
|
|
3634
|
+
[
|
|
3635
|
+
'"y"'
|
|
3636
|
+
],
|
|
3637
|
+
[
|
|
3638
|
+
'"z"'
|
|
3639
|
+
]
|
|
3640
|
+
]
|
|
3641
|
+
},
|
|
3642
|
+
{
|
|
3643
|
+
name: "RULE_DIGIT",
|
|
3644
|
+
bnf: [
|
|
3645
|
+
[
|
|
3646
|
+
'"0"'
|
|
3647
|
+
],
|
|
3648
|
+
[
|
|
3649
|
+
'"1"'
|
|
3650
|
+
],
|
|
3651
|
+
[
|
|
3652
|
+
'"2"'
|
|
3653
|
+
],
|
|
3654
|
+
[
|
|
3655
|
+
'"3"'
|
|
3656
|
+
],
|
|
3657
|
+
[
|
|
3658
|
+
'"4"'
|
|
3659
|
+
],
|
|
3660
|
+
[
|
|
3661
|
+
'"5"'
|
|
3662
|
+
],
|
|
3663
|
+
[
|
|
3664
|
+
'"6"'
|
|
3665
|
+
],
|
|
3666
|
+
[
|
|
3667
|
+
'"7"'
|
|
3668
|
+
],
|
|
3669
|
+
[
|
|
3670
|
+
'"8"'
|
|
3671
|
+
],
|
|
3672
|
+
[
|
|
3673
|
+
'"9"'
|
|
3674
|
+
]
|
|
3675
|
+
]
|
|
3676
|
+
},
|
|
3677
|
+
{
|
|
3678
|
+
name: "RULE_SYMBOL",
|
|
3679
|
+
bnf: [
|
|
3680
|
+
[
|
|
3681
|
+
'"-"'
|
|
3682
|
+
],
|
|
3683
|
+
[
|
|
3684
|
+
'"_"'
|
|
3685
|
+
],
|
|
3686
|
+
[
|
|
3687
|
+
'"!"'
|
|
3688
|
+
],
|
|
3689
|
+
[
|
|
3690
|
+
'"#"'
|
|
3691
|
+
],
|
|
3692
|
+
[
|
|
3693
|
+
'"$"'
|
|
3694
|
+
],
|
|
3695
|
+
[
|
|
3696
|
+
'"%"'
|
|
3697
|
+
],
|
|
3698
|
+
[
|
|
3699
|
+
'"&"'
|
|
3700
|
+
],
|
|
3701
|
+
[
|
|
3702
|
+
'"("'
|
|
3703
|
+
],
|
|
3704
|
+
[
|
|
3705
|
+
'")"'
|
|
3706
|
+
],
|
|
3707
|
+
[
|
|
3708
|
+
'"*"'
|
|
3709
|
+
],
|
|
3710
|
+
[
|
|
3711
|
+
'"+"'
|
|
3712
|
+
],
|
|
3713
|
+
[
|
|
3714
|
+
'","'
|
|
3715
|
+
],
|
|
3716
|
+
[
|
|
3717
|
+
'"-"'
|
|
3718
|
+
],
|
|
3719
|
+
[
|
|
3720
|
+
'"."'
|
|
3721
|
+
],
|
|
3722
|
+
[
|
|
3723
|
+
'"/"'
|
|
3724
|
+
],
|
|
3725
|
+
[
|
|
3726
|
+
'":"'
|
|
3727
|
+
],
|
|
3728
|
+
[
|
|
3729
|
+
'";"'
|
|
3730
|
+
],
|
|
3731
|
+
[
|
|
3732
|
+
'"<"'
|
|
3733
|
+
],
|
|
3734
|
+
[
|
|
3735
|
+
'"="'
|
|
3736
|
+
],
|
|
3737
|
+
[
|
|
3738
|
+
'">"'
|
|
3739
|
+
],
|
|
3740
|
+
[
|
|
3741
|
+
'"?"'
|
|
3742
|
+
],
|
|
3743
|
+
[
|
|
3744
|
+
'"@"'
|
|
3745
|
+
],
|
|
3746
|
+
[
|
|
3747
|
+
'"["'
|
|
3748
|
+
],
|
|
3749
|
+
[
|
|
3750
|
+
'"\\"'
|
|
3751
|
+
],
|
|
3752
|
+
[
|
|
3753
|
+
'"]"'
|
|
3754
|
+
],
|
|
3755
|
+
[
|
|
3756
|
+
'"^"'
|
|
3757
|
+
],
|
|
3758
|
+
[
|
|
3759
|
+
'"_"'
|
|
3760
|
+
],
|
|
3761
|
+
[
|
|
3762
|
+
'"`"'
|
|
3763
|
+
],
|
|
3764
|
+
[
|
|
3765
|
+
'"{"'
|
|
3766
|
+
],
|
|
3767
|
+
[
|
|
3768
|
+
'"|"'
|
|
3769
|
+
],
|
|
3770
|
+
[
|
|
3771
|
+
'"}"'
|
|
3772
|
+
],
|
|
3773
|
+
[
|
|
3774
|
+
'"~"'
|
|
3775
|
+
]
|
|
3776
|
+
]
|
|
3777
|
+
},
|
|
3778
|
+
{
|
|
3779
|
+
name: "RULE_CHARACTER1",
|
|
3780
|
+
bnf: [
|
|
3781
|
+
[
|
|
3782
|
+
"RULE_CHARACTER"
|
|
3783
|
+
],
|
|
3784
|
+
[
|
|
3785
|
+
'"\'"'
|
|
3786
|
+
]
|
|
3787
|
+
]
|
|
3788
|
+
},
|
|
3789
|
+
{
|
|
3790
|
+
name: "RULE_CHARACTER2",
|
|
3791
|
+
bnf: [
|
|
3792
|
+
[
|
|
3793
|
+
"RULE_CHARACTER"
|
|
3794
|
+
],
|
|
3795
|
+
[
|
|
3796
|
+
"'\"'"
|
|
3797
|
+
]
|
|
3798
|
+
]
|
|
3799
|
+
},
|
|
3800
|
+
{
|
|
3801
|
+
name: "rule-name",
|
|
3802
|
+
bnf: [
|
|
3803
|
+
[
|
|
3804
|
+
"RULE_LETTER",
|
|
3805
|
+
"RULE_CHAR*"
|
|
3806
|
+
]
|
|
3807
|
+
]
|
|
3808
|
+
},
|
|
3809
|
+
{
|
|
3810
|
+
name: "RULE_CHAR",
|
|
3811
|
+
bnf: [
|
|
3812
|
+
[
|
|
3813
|
+
"RULE_LETTER"
|
|
3814
|
+
],
|
|
3815
|
+
[
|
|
3816
|
+
"RULE_DIGIT"
|
|
3817
|
+
],
|
|
3818
|
+
[
|
|
3819
|
+
'"_"'
|
|
3820
|
+
],
|
|
3821
|
+
[
|
|
3822
|
+
'"-"'
|
|
3823
|
+
]
|
|
3824
|
+
]
|
|
3825
|
+
}
|
|
3826
|
+
];
|
|
3827
|
+
BNF2.defaultParser = new Parser_1.Parser(BNF2.RULES, {
|
|
3828
|
+
debug: false
|
|
3829
|
+
});
|
|
3830
|
+
function getAllTerms(expr) {
|
|
3831
|
+
var terms = SemanticHelpers_1.findChildrenByType(expr, "term").map(function(term) {
|
|
3832
|
+
return SemanticHelpers_1.findChildrenByType(term, "literal").concat(SemanticHelpers_1.findChildrenByType(term, "rule-name"))[0].text;
|
|
3833
|
+
});
|
|
3834
|
+
SemanticHelpers_1.findChildrenByType(expr, "list").forEach(function(expr2) {
|
|
3835
|
+
terms = terms.concat(getAllTerms(expr2));
|
|
3836
|
+
});
|
|
3837
|
+
return terms;
|
|
3838
|
+
}
|
|
3839
|
+
function getRules(source) {
|
|
3840
|
+
var parser2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
3841
|
+
var ast = parser2.getAST(source);
|
|
3842
|
+
if (!ast) throw new Error("Could not parse " + source);
|
|
3843
|
+
if (ast.errors && ast.errors.length) {
|
|
3844
|
+
throw ast.errors[0];
|
|
3845
|
+
}
|
|
3846
|
+
var rules = SemanticHelpers_1.findChildrenByType(ast, "rule");
|
|
3847
|
+
var ret = rules.map(function(rule) {
|
|
3848
|
+
var name = SemanticHelpers_1.findChildrenByType(rule, "rule-name")[0].text;
|
|
3849
|
+
var expressions = SemanticHelpers_1.findChildrenByType(rule, "firstExpression").concat(SemanticHelpers_1.findChildrenByType(rule, "otherExpression"));
|
|
3850
|
+
var bnf = [];
|
|
3851
|
+
expressions.forEach(function(expr) {
|
|
3852
|
+
bnf.push(getAllTerms(expr));
|
|
3853
|
+
});
|
|
3854
|
+
return {
|
|
3855
|
+
name: name,
|
|
3856
|
+
bnf: bnf
|
|
3857
|
+
};
|
|
3858
|
+
});
|
|
3859
|
+
if (!ret.some(function(x) {
|
|
3860
|
+
return x.name == "EOL";
|
|
3861
|
+
})) {
|
|
3862
|
+
ret.push({
|
|
3863
|
+
name: "EOL",
|
|
3864
|
+
bnf: [
|
|
3865
|
+
[
|
|
3866
|
+
'"\\r\\n"',
|
|
3867
|
+
'"\\r"',
|
|
3868
|
+
'"\\n"'
|
|
3869
|
+
]
|
|
3870
|
+
]
|
|
3871
|
+
});
|
|
3872
|
+
}
|
|
3873
|
+
return ret;
|
|
3874
|
+
}
|
|
3875
|
+
BNF2.getRules = getRules;
|
|
3876
|
+
function Transform(source) {
|
|
3877
|
+
var subParser = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
3878
|
+
return getRules(source.join(""), subParser);
|
|
3879
|
+
}
|
|
3880
|
+
BNF2.Transform = Transform;
|
|
3881
|
+
var Parser2 = /*#__PURE__*/ function(_Parser_1_Parser) {
|
|
3882
|
+
_inherits(Parser2, _Parser_1_Parser);
|
|
3883
|
+
var _super = _create_super(Parser2);
|
|
3884
|
+
function Parser2(source, options) {
|
|
3885
|
+
_class_call_check(this, Parser2);
|
|
3886
|
+
var _this;
|
|
3887
|
+
var subParser = options && options.debugRulesParser === true ? new Parser_1.Parser(BNF2.RULES, {
|
|
3888
|
+
debug: true
|
|
3889
|
+
}) : BNF2.defaultParser;
|
|
3890
|
+
_this = _super.call(this, getRules(source, subParser), options);
|
|
3891
|
+
_this.source = source;
|
|
3892
|
+
return _this;
|
|
3893
|
+
}
|
|
3894
|
+
_create_class(Parser2, [
|
|
3895
|
+
{
|
|
3896
|
+
key: "emitSource",
|
|
3897
|
+
value: function emitSource() {
|
|
3898
|
+
return this.source;
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
]);
|
|
3902
|
+
return Parser2;
|
|
3903
|
+
}(Parser_1.Parser);
|
|
3904
|
+
BNF2.Parser = Parser2;
|
|
3905
|
+
})(BNF || (BNF = {}));
|
|
3906
|
+
exports.default = BNF;
|
|
3907
|
+
}
|
|
3908
|
+
});
|
|
3909
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/W3CEBNF.js
|
|
3910
|
+
var require_W3CEBNF = __commonJS({
|
|
3911
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/W3CEBNF.js": function(exports) {
|
|
3912
|
+
"use strict";
|
|
3913
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3914
|
+
value: true
|
|
3915
|
+
});
|
|
3916
|
+
var Parser_1 = require_Parser();
|
|
3917
|
+
var BNF;
|
|
3918
|
+
(function(BNF2) {
|
|
3919
|
+
BNF2.RULES = [
|
|
3920
|
+
{
|
|
3921
|
+
name: "Grammar",
|
|
3922
|
+
bnf: [
|
|
3923
|
+
[
|
|
3924
|
+
"RULE_S*",
|
|
3925
|
+
"%Atomic*",
|
|
3926
|
+
"EOF"
|
|
3927
|
+
]
|
|
3928
|
+
]
|
|
3929
|
+
},
|
|
3930
|
+
{
|
|
3931
|
+
name: "%Atomic",
|
|
3932
|
+
bnf: [
|
|
3933
|
+
[
|
|
3934
|
+
"Production",
|
|
3935
|
+
"RULE_S*"
|
|
3936
|
+
]
|
|
3937
|
+
],
|
|
3938
|
+
fragment: true
|
|
3939
|
+
},
|
|
3940
|
+
{
|
|
3941
|
+
name: "Production",
|
|
3942
|
+
bnf: [
|
|
3943
|
+
[
|
|
3944
|
+
"NCName",
|
|
3945
|
+
"RULE_S*",
|
|
3946
|
+
'"::="',
|
|
3947
|
+
"RULE_WHITESPACE*",
|
|
3948
|
+
"Choice",
|
|
3949
|
+
"RULE_WHITESPACE*",
|
|
3950
|
+
"RULE_EOL+",
|
|
3951
|
+
"RULE_S*"
|
|
3952
|
+
]
|
|
3953
|
+
]
|
|
3954
|
+
},
|
|
3955
|
+
{
|
|
3956
|
+
name: "NCName",
|
|
3957
|
+
bnf: [
|
|
3958
|
+
[
|
|
3959
|
+
/[a-zA-Z][a-zA-Z_0-9]*/
|
|
3960
|
+
]
|
|
3961
|
+
]
|
|
3962
|
+
},
|
|
3963
|
+
{
|
|
3964
|
+
name: "Choice",
|
|
3965
|
+
bnf: [
|
|
3966
|
+
[
|
|
3967
|
+
"SequenceOrDifference",
|
|
3968
|
+
"%_Choice_1*"
|
|
3969
|
+
]
|
|
3970
|
+
],
|
|
3971
|
+
fragment: true
|
|
3972
|
+
},
|
|
3973
|
+
{
|
|
3974
|
+
name: "%_Choice_1",
|
|
3975
|
+
bnf: [
|
|
3976
|
+
[
|
|
3977
|
+
"RULE_WHITESPACE*",
|
|
3978
|
+
'"|"',
|
|
3979
|
+
"RULE_WHITESPACE*",
|
|
3980
|
+
"SequenceOrDifference"
|
|
3981
|
+
]
|
|
3982
|
+
],
|
|
3983
|
+
fragment: true
|
|
3984
|
+
},
|
|
3985
|
+
{
|
|
3986
|
+
name: "SequenceOrDifference",
|
|
3987
|
+
bnf: [
|
|
3988
|
+
[
|
|
3989
|
+
"Item",
|
|
3990
|
+
"RULE_WHITESPACE*",
|
|
3991
|
+
"%_Item_1?"
|
|
3992
|
+
]
|
|
3993
|
+
]
|
|
3994
|
+
},
|
|
3995
|
+
{
|
|
3996
|
+
name: "%_Item_1",
|
|
3997
|
+
bnf: [
|
|
3998
|
+
[
|
|
3999
|
+
"Minus",
|
|
4000
|
+
"Item"
|
|
4001
|
+
],
|
|
4002
|
+
[
|
|
4003
|
+
"Item*"
|
|
4004
|
+
]
|
|
4005
|
+
],
|
|
4006
|
+
fragment: true
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
name: "Minus",
|
|
4010
|
+
bnf: [
|
|
4011
|
+
[
|
|
4012
|
+
'"-"'
|
|
4013
|
+
]
|
|
4014
|
+
]
|
|
4015
|
+
},
|
|
4016
|
+
{
|
|
4017
|
+
name: "Item",
|
|
4018
|
+
bnf: [
|
|
4019
|
+
[
|
|
4020
|
+
"RULE_WHITESPACE*",
|
|
4021
|
+
"%Primary",
|
|
4022
|
+
"PrimaryDecoration?"
|
|
4023
|
+
]
|
|
4024
|
+
],
|
|
4025
|
+
fragment: true
|
|
4026
|
+
},
|
|
4027
|
+
{
|
|
4028
|
+
name: "PrimaryDecoration",
|
|
4029
|
+
bnf: [
|
|
4030
|
+
[
|
|
4031
|
+
'"?"'
|
|
4032
|
+
],
|
|
4033
|
+
[
|
|
4034
|
+
'"*"'
|
|
4035
|
+
],
|
|
4036
|
+
[
|
|
4037
|
+
'"+"'
|
|
4038
|
+
]
|
|
4039
|
+
]
|
|
4040
|
+
},
|
|
4041
|
+
{
|
|
4042
|
+
name: "DecorationName",
|
|
4043
|
+
bnf: [
|
|
4044
|
+
[
|
|
4045
|
+
'"ebnf://"',
|
|
4046
|
+
/[^\x5D#]+/
|
|
4047
|
+
]
|
|
4048
|
+
]
|
|
4049
|
+
},
|
|
4050
|
+
{
|
|
4051
|
+
name: "%Primary",
|
|
4052
|
+
bnf: [
|
|
4053
|
+
[
|
|
4054
|
+
"NCName"
|
|
4055
|
+
],
|
|
4056
|
+
[
|
|
4057
|
+
"StringLiteral"
|
|
4058
|
+
],
|
|
4059
|
+
[
|
|
4060
|
+
"CharCode"
|
|
4061
|
+
],
|
|
4062
|
+
[
|
|
4063
|
+
"CharClass"
|
|
4064
|
+
],
|
|
4065
|
+
[
|
|
4066
|
+
"SubItem"
|
|
4067
|
+
]
|
|
4068
|
+
],
|
|
4069
|
+
fragment: true
|
|
4070
|
+
},
|
|
4071
|
+
{
|
|
4072
|
+
name: "SubItem",
|
|
4073
|
+
bnf: [
|
|
4074
|
+
[
|
|
4075
|
+
'"("',
|
|
4076
|
+
"RULE_WHITESPACE*",
|
|
4077
|
+
"Choice",
|
|
4078
|
+
"RULE_WHITESPACE*",
|
|
4079
|
+
'")"'
|
|
4080
|
+
]
|
|
4081
|
+
]
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
name: "StringLiteral",
|
|
4085
|
+
bnf: [
|
|
4086
|
+
[
|
|
4087
|
+
"'\"'",
|
|
4088
|
+
/[^"]*/,
|
|
4089
|
+
"'\"'"
|
|
4090
|
+
],
|
|
4091
|
+
[
|
|
4092
|
+
'"\'"',
|
|
4093
|
+
/[^']*/,
|
|
4094
|
+
'"\'"'
|
|
4095
|
+
]
|
|
4096
|
+
],
|
|
4097
|
+
pinned: 1
|
|
4098
|
+
},
|
|
4099
|
+
{
|
|
4100
|
+
name: "CharCode",
|
|
4101
|
+
bnf: [
|
|
4102
|
+
[
|
|
4103
|
+
'"#x"',
|
|
4104
|
+
/[0-9a-zA-Z]+/
|
|
4105
|
+
]
|
|
4106
|
+
]
|
|
4107
|
+
},
|
|
4108
|
+
{
|
|
4109
|
+
name: "CharClass",
|
|
4110
|
+
bnf: [
|
|
4111
|
+
[
|
|
4112
|
+
"'['",
|
|
4113
|
+
"'^'?",
|
|
4114
|
+
"%RULE_CharClass_1+",
|
|
4115
|
+
'"]"'
|
|
4116
|
+
]
|
|
4117
|
+
]
|
|
4118
|
+
},
|
|
4119
|
+
{
|
|
4120
|
+
name: "%RULE_CharClass_1",
|
|
4121
|
+
bnf: [
|
|
4122
|
+
[
|
|
4123
|
+
"CharCodeRange"
|
|
4124
|
+
],
|
|
4125
|
+
[
|
|
4126
|
+
"CharRange"
|
|
4127
|
+
],
|
|
4128
|
+
[
|
|
4129
|
+
"CharCode"
|
|
4130
|
+
],
|
|
4131
|
+
[
|
|
4132
|
+
"RULE_Char"
|
|
4133
|
+
]
|
|
4134
|
+
],
|
|
4135
|
+
fragment: true
|
|
4136
|
+
},
|
|
4137
|
+
{
|
|
4138
|
+
name: "RULE_Char",
|
|
4139
|
+
bnf: [
|
|
4140
|
+
[
|
|
4141
|
+
/\x09/
|
|
4142
|
+
],
|
|
4143
|
+
[
|
|
4144
|
+
/\x0A/
|
|
4145
|
+
],
|
|
4146
|
+
[
|
|
4147
|
+
/\x0D/
|
|
4148
|
+
],
|
|
4149
|
+
[
|
|
4150
|
+
/[\x20-\x5c]/
|
|
4151
|
+
],
|
|
4152
|
+
[
|
|
4153
|
+
/[\x5e-\uD7FF]/
|
|
4154
|
+
],
|
|
4155
|
+
[
|
|
4156
|
+
/[\uE000-\uFFFD]/
|
|
4157
|
+
]
|
|
4158
|
+
]
|
|
4159
|
+
},
|
|
4160
|
+
{
|
|
4161
|
+
name: "CharRange",
|
|
4162
|
+
bnf: [
|
|
4163
|
+
[
|
|
4164
|
+
"RULE_Char",
|
|
4165
|
+
'"-"',
|
|
4166
|
+
"RULE_Char"
|
|
4167
|
+
]
|
|
4168
|
+
]
|
|
4169
|
+
},
|
|
4170
|
+
{
|
|
4171
|
+
name: "CharCodeRange",
|
|
4172
|
+
bnf: [
|
|
4173
|
+
[
|
|
4174
|
+
"CharCode",
|
|
4175
|
+
'"-"',
|
|
4176
|
+
"CharCode"
|
|
4177
|
+
]
|
|
4178
|
+
]
|
|
4179
|
+
},
|
|
4180
|
+
{
|
|
4181
|
+
name: "RULE_WHITESPACE",
|
|
4182
|
+
bnf: [
|
|
4183
|
+
[
|
|
4184
|
+
"%RULE_WHITESPACE_CHAR*"
|
|
4185
|
+
],
|
|
4186
|
+
[
|
|
4187
|
+
"Comment",
|
|
4188
|
+
"RULE_WHITESPACE*"
|
|
4189
|
+
]
|
|
4190
|
+
]
|
|
4191
|
+
},
|
|
4192
|
+
{
|
|
4193
|
+
name: "RULE_S",
|
|
4194
|
+
bnf: [
|
|
4195
|
+
[
|
|
4196
|
+
"RULE_WHITESPACE",
|
|
4197
|
+
"RULE_S*"
|
|
4198
|
+
],
|
|
4199
|
+
[
|
|
4200
|
+
"RULE_EOL",
|
|
4201
|
+
"RULE_S*"
|
|
4202
|
+
]
|
|
4203
|
+
]
|
|
4204
|
+
},
|
|
4205
|
+
{
|
|
4206
|
+
name: "%RULE_WHITESPACE_CHAR",
|
|
4207
|
+
bnf: [
|
|
4208
|
+
[
|
|
4209
|
+
/\x09/
|
|
4210
|
+
],
|
|
4211
|
+
[
|
|
4212
|
+
/\x20/
|
|
4213
|
+
]
|
|
4214
|
+
],
|
|
4215
|
+
fragment: true
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
name: "Comment",
|
|
4219
|
+
bnf: [
|
|
4220
|
+
[
|
|
4221
|
+
'"/*"',
|
|
4222
|
+
"%RULE_Comment_Body*",
|
|
4223
|
+
'"*/"'
|
|
4224
|
+
]
|
|
4225
|
+
]
|
|
4226
|
+
},
|
|
4227
|
+
{
|
|
4228
|
+
name: "%RULE_Comment_Body",
|
|
4229
|
+
bnf: [
|
|
4230
|
+
[
|
|
4231
|
+
'!"*/"',
|
|
4232
|
+
/[^*]/
|
|
4233
|
+
]
|
|
4234
|
+
],
|
|
4235
|
+
fragment: true
|
|
4236
|
+
},
|
|
4237
|
+
{
|
|
4238
|
+
name: "RULE_EOL",
|
|
4239
|
+
bnf: [
|
|
4240
|
+
[
|
|
4241
|
+
/\x0D/,
|
|
4242
|
+
/\x0A/
|
|
4243
|
+
],
|
|
4244
|
+
[
|
|
4245
|
+
/\x0A/
|
|
4246
|
+
],
|
|
4247
|
+
[
|
|
4248
|
+
/\x0D/
|
|
4249
|
+
]
|
|
4250
|
+
]
|
|
4251
|
+
},
|
|
4252
|
+
{
|
|
4253
|
+
name: "Link",
|
|
4254
|
+
bnf: [
|
|
4255
|
+
[
|
|
4256
|
+
"'['",
|
|
4257
|
+
"Url",
|
|
4258
|
+
"']'"
|
|
4259
|
+
]
|
|
4260
|
+
]
|
|
4261
|
+
},
|
|
4262
|
+
{
|
|
4263
|
+
name: "Url",
|
|
4264
|
+
bnf: [
|
|
4265
|
+
[
|
|
4266
|
+
/[^\x5D:/?#]/,
|
|
4267
|
+
'"://"',
|
|
4268
|
+
/[^\x5D#]+/,
|
|
4269
|
+
"%Url1?"
|
|
4270
|
+
]
|
|
4271
|
+
]
|
|
4272
|
+
},
|
|
4273
|
+
{
|
|
4274
|
+
name: "%Url1",
|
|
4275
|
+
bnf: [
|
|
4276
|
+
[
|
|
4277
|
+
'"#"',
|
|
4278
|
+
"NCName"
|
|
4279
|
+
]
|
|
4280
|
+
],
|
|
4281
|
+
fragment: true
|
|
4282
|
+
}
|
|
4283
|
+
];
|
|
4284
|
+
BNF2.defaultParser = new Parser_1.Parser(BNF2.RULES, {
|
|
4285
|
+
debug: false
|
|
4286
|
+
});
|
|
4287
|
+
var preDecorationRE = /^(!|&)/;
|
|
4288
|
+
var decorationRE = /(\?|\+|\*)$/;
|
|
4289
|
+
var subExpressionRE = /^%/;
|
|
4290
|
+
function getBNFRule(name, parser2) {
|
|
4291
|
+
if (typeof name == "string") {
|
|
4292
|
+
if (preDecorationRE.test(name)) return "";
|
|
4293
|
+
var subexpression = subExpressionRE.test(name);
|
|
4294
|
+
if (subexpression) {
|
|
4295
|
+
var decoration = decorationRE.exec(name);
|
|
4296
|
+
var decorationText = decoration ? decoration[0] + " " : "";
|
|
4297
|
+
var lonely = isLonelyRule(name, parser2);
|
|
4298
|
+
if (lonely) return getBNFBody(name, parser2) + decorationText;
|
|
4299
|
+
return "(" + getBNFBody(name, parser2) + ")" + decorationText;
|
|
4300
|
+
}
|
|
4301
|
+
return name;
|
|
4302
|
+
} else {
|
|
4303
|
+
return name.source.replace(/\\(?:x|u)([a-zA-Z0-9]+)/g, "#x$1").replace(/\[\\(?:x|u)([a-zA-Z0-9]+)-\\(?:x|u)([a-zA-Z0-9]+)\]/g, "[#x$1-#x$2]");
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
function isLonelyRule(name, parser2) {
|
|
4307
|
+
var rule = Parser_1.findRuleByName(name, parser2);
|
|
4308
|
+
return rule && rule.bnf.length == 1 && rule.bnf[0].length == 1 && (_instanceof(rule.bnf[0][0], RegExp) || rule.bnf[0][0][0] == '"' || rule.bnf[0][0][0] == "'");
|
|
4309
|
+
}
|
|
4310
|
+
function getBNFChoice(rules, parser2) {
|
|
4311
|
+
return rules.map(function(x) {
|
|
4312
|
+
return getBNFRule(x, parser2);
|
|
4313
|
+
}).join(" ");
|
|
4314
|
+
}
|
|
4315
|
+
function getBNFBody(name, parser2) {
|
|
4316
|
+
var rule = Parser_1.findRuleByName(name, parser2);
|
|
4317
|
+
if (rule) return rule.bnf.map(function(x) {
|
|
4318
|
+
return getBNFChoice(x, parser2);
|
|
4319
|
+
}).join(" | ");
|
|
4320
|
+
return "RULE_NOT_FOUND {" + name + "}";
|
|
4321
|
+
}
|
|
4322
|
+
function emit(parser2) {
|
|
4323
|
+
var acumulator = [];
|
|
4324
|
+
parser2.grammarRules.forEach(function(l) {
|
|
4325
|
+
if (!/^%/.test(l.name)) {
|
|
4326
|
+
var recover = l.recover ? " /* { recoverUntil=" + l.recover + " } */" : "";
|
|
4327
|
+
acumulator.push(l.name + " ::= " + getBNFBody(l.name, parser2) + recover);
|
|
4328
|
+
}
|
|
4329
|
+
});
|
|
4330
|
+
return acumulator.join("\n");
|
|
4331
|
+
}
|
|
4332
|
+
BNF2.emit = emit;
|
|
4333
|
+
var subitems = 0;
|
|
4334
|
+
function restar(total, resta) {
|
|
4335
|
+
console.log("reberia restar " + resta + " a " + total);
|
|
4336
|
+
throw new Error("Difference not supported yet");
|
|
4337
|
+
}
|
|
4338
|
+
function convertRegex(txt) {
|
|
4339
|
+
return new RegExp(txt.replace(/#x([a-zA-Z0-9]{4})/g, "\\u$1").replace(/#x([a-zA-Z0-9]{3})/g, "\\u0$1").replace(/#x([a-zA-Z0-9]{2})/g, "\\x$1").replace(/#x([a-zA-Z0-9]{1})/g, "\\x0$1"));
|
|
4340
|
+
}
|
|
4341
|
+
function getSubItems(tmpRules, seq, parentName) {
|
|
4342
|
+
var anterior = null;
|
|
4343
|
+
var bnfSeq = [];
|
|
4344
|
+
seq.children.forEach(function(x, i) {
|
|
4345
|
+
if (x.type == "Minus") {
|
|
4346
|
+
restar(anterior, x);
|
|
4347
|
+
} else {}
|
|
4348
|
+
var decoration = seq.children[i + 1];
|
|
4349
|
+
decoration = decoration && decoration.type == "PrimaryDecoration" && decoration.text || "";
|
|
4350
|
+
var preDecoration = "";
|
|
4351
|
+
switch(x.type){
|
|
4352
|
+
case "SubItem":
|
|
4353
|
+
var name = "%" + (parentName + subitems++);
|
|
4354
|
+
createRule(tmpRules, x, name);
|
|
4355
|
+
bnfSeq.push(preDecoration + name + decoration);
|
|
4356
|
+
break;
|
|
4357
|
+
case "NCName":
|
|
4358
|
+
case "StringLiteral":
|
|
4359
|
+
bnfSeq.push(preDecoration + x.text + decoration);
|
|
4360
|
+
break;
|
|
4361
|
+
case "CharCode":
|
|
4362
|
+
case "CharClass":
|
|
4363
|
+
if (decoration || preDecoration) {
|
|
4364
|
+
var newRule = {
|
|
4365
|
+
name: "%" + (parentName + subitems++),
|
|
4366
|
+
bnf: [
|
|
4367
|
+
[
|
|
4368
|
+
convertRegex(x.text)
|
|
4369
|
+
]
|
|
4370
|
+
]
|
|
4371
|
+
};
|
|
4372
|
+
tmpRules.push(newRule);
|
|
4373
|
+
bnfSeq.push(preDecoration + newRule.name + decoration);
|
|
4374
|
+
} else {
|
|
4375
|
+
bnfSeq.push(convertRegex(x.text));
|
|
4376
|
+
}
|
|
4377
|
+
break;
|
|
4378
|
+
case "PrimaryDecoration":
|
|
4379
|
+
break;
|
|
4380
|
+
default:
|
|
4381
|
+
throw new Error(" HOW SHOULD I PARSE THIS? " + x.type + " -> " + JSON.stringify(x.text));
|
|
4382
|
+
}
|
|
4383
|
+
anterior = x;
|
|
4384
|
+
});
|
|
4385
|
+
return bnfSeq;
|
|
4386
|
+
}
|
|
4387
|
+
function createRule(tmpRules, token, name) {
|
|
4388
|
+
var bnf = token.children.filter(function(x) {
|
|
4389
|
+
return x.type == "SequenceOrDifference";
|
|
4390
|
+
}).map(function(s) {
|
|
4391
|
+
return getSubItems(tmpRules, s, name);
|
|
4392
|
+
});
|
|
4393
|
+
var rule = {
|
|
4394
|
+
name: name,
|
|
4395
|
+
bnf: bnf
|
|
4396
|
+
};
|
|
4397
|
+
var recover = null;
|
|
4398
|
+
bnf.forEach(function(x) {
|
|
4399
|
+
recover = recover || x["recover"];
|
|
4400
|
+
delete x["recover"];
|
|
4401
|
+
});
|
|
4402
|
+
if (name.indexOf("%") == 0) rule.fragment = true;
|
|
4403
|
+
if (recover) rule.recover = recover;
|
|
4404
|
+
tmpRules.push(rule);
|
|
4405
|
+
}
|
|
4406
|
+
function getRules(source) {
|
|
4407
|
+
var parser2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
4408
|
+
var ast = parser2.getAST(source);
|
|
4409
|
+
if (!ast) throw new Error("Could not parse " + source);
|
|
4410
|
+
if (ast.errors && ast.errors.length) {
|
|
4411
|
+
throw ast.errors[0];
|
|
4412
|
+
}
|
|
4413
|
+
var tmpRules = [];
|
|
4414
|
+
ast.children.filter(function(x) {
|
|
4415
|
+
return x.type == "Production";
|
|
4416
|
+
}).map(function(x) {
|
|
4417
|
+
var name = x.children.filter(function(x2) {
|
|
4418
|
+
return x2.type == "NCName";
|
|
4419
|
+
})[0].text;
|
|
4420
|
+
createRule(tmpRules, x, name);
|
|
4421
|
+
});
|
|
4422
|
+
return tmpRules;
|
|
4423
|
+
}
|
|
4424
|
+
BNF2.getRules = getRules;
|
|
4425
|
+
function Transform(source) {
|
|
4426
|
+
var subParser = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
4427
|
+
return getRules(source.join(""), subParser);
|
|
4428
|
+
}
|
|
4429
|
+
BNF2.Transform = Transform;
|
|
4430
|
+
var Parser2 = /*#__PURE__*/ function(_Parser_1_Parser) {
|
|
4431
|
+
_inherits(Parser2, _Parser_1_Parser);
|
|
4432
|
+
var _super = _create_super(Parser2);
|
|
4433
|
+
function Parser2(source, options) {
|
|
4434
|
+
_class_call_check(this, Parser2);
|
|
4435
|
+
var subParser = options && options.debugRulesParser === true ? new Parser_1.Parser(BNF2.RULES, {
|
|
4436
|
+
debug: true
|
|
4437
|
+
}) : BNF2.defaultParser;
|
|
4438
|
+
return _super.call(this, getRules(source, subParser), options);
|
|
4439
|
+
}
|
|
4440
|
+
_create_class(Parser2, [
|
|
4441
|
+
{
|
|
4442
|
+
key: "emitSource",
|
|
4443
|
+
value: function emitSource() {
|
|
4444
|
+
return emit(this);
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
]);
|
|
4448
|
+
return Parser2;
|
|
4449
|
+
}(Parser_1.Parser);
|
|
4450
|
+
BNF2.Parser = Parser2;
|
|
4451
|
+
})(BNF || (BNF = {}));
|
|
4452
|
+
exports.default = BNF;
|
|
4453
|
+
}
|
|
4454
|
+
});
|
|
4455
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/Custom.js
|
|
4456
|
+
var require_Custom = __commonJS({
|
|
4457
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/Custom.js": function(exports) {
|
|
4458
|
+
"use strict";
|
|
4459
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4460
|
+
value: true
|
|
4461
|
+
});
|
|
4462
|
+
var TokenError_1 = require_TokenError();
|
|
4463
|
+
var Parser_1 = require_Parser();
|
|
4464
|
+
var BNF;
|
|
4465
|
+
(function(BNF2) {
|
|
4466
|
+
BNF2.RULES = [
|
|
4467
|
+
{
|
|
4468
|
+
name: "Grammar",
|
|
4469
|
+
bnf: [
|
|
4470
|
+
[
|
|
4471
|
+
"RULE_S*",
|
|
4472
|
+
"Attributes?",
|
|
4473
|
+
"RULE_S*",
|
|
4474
|
+
"%Atomic*",
|
|
4475
|
+
"EOF"
|
|
4476
|
+
]
|
|
4477
|
+
]
|
|
4478
|
+
},
|
|
4479
|
+
{
|
|
4480
|
+
name: "%Atomic",
|
|
4481
|
+
bnf: [
|
|
4482
|
+
[
|
|
4483
|
+
"Production",
|
|
4484
|
+
"RULE_S*"
|
|
4485
|
+
]
|
|
4486
|
+
],
|
|
4487
|
+
fragment: true
|
|
4488
|
+
},
|
|
4489
|
+
{
|
|
4490
|
+
name: "Production",
|
|
4491
|
+
bnf: [
|
|
4492
|
+
[
|
|
4493
|
+
"NCName",
|
|
4494
|
+
"RULE_S*",
|
|
4495
|
+
'"::="',
|
|
4496
|
+
"RULE_WHITESPACE*",
|
|
4497
|
+
"%Choice",
|
|
4498
|
+
"RULE_WHITESPACE*",
|
|
4499
|
+
"Attributes?",
|
|
4500
|
+
"RULE_EOL+",
|
|
4501
|
+
"RULE_S*"
|
|
4502
|
+
]
|
|
4503
|
+
]
|
|
4504
|
+
},
|
|
4505
|
+
{
|
|
4506
|
+
name: "NCName",
|
|
4507
|
+
bnf: [
|
|
4508
|
+
[
|
|
4509
|
+
/[a-zA-Z][a-zA-Z_0-9]*/
|
|
4510
|
+
]
|
|
4511
|
+
]
|
|
4512
|
+
},
|
|
4513
|
+
{
|
|
4514
|
+
name: "Attributes",
|
|
4515
|
+
bnf: [
|
|
4516
|
+
[
|
|
4517
|
+
'"{"',
|
|
4518
|
+
"Attribute",
|
|
4519
|
+
"%Attributes*",
|
|
4520
|
+
"RULE_S*",
|
|
4521
|
+
'"}"'
|
|
4522
|
+
]
|
|
4523
|
+
]
|
|
4524
|
+
},
|
|
4525
|
+
{
|
|
4526
|
+
name: "%Attributes",
|
|
4527
|
+
bnf: [
|
|
4528
|
+
[
|
|
4529
|
+
"RULE_S*",
|
|
4530
|
+
'","',
|
|
4531
|
+
"Attribute"
|
|
4532
|
+
]
|
|
4533
|
+
],
|
|
4534
|
+
fragment: true
|
|
4535
|
+
},
|
|
4536
|
+
{
|
|
4537
|
+
name: "Attribute",
|
|
4538
|
+
bnf: [
|
|
4539
|
+
[
|
|
4540
|
+
"RULE_S*",
|
|
4541
|
+
"NCName",
|
|
4542
|
+
"RULE_WHITESPACE*",
|
|
4543
|
+
'"="',
|
|
4544
|
+
"RULE_WHITESPACE*",
|
|
4545
|
+
"AttributeValue"
|
|
4546
|
+
]
|
|
4547
|
+
]
|
|
4548
|
+
},
|
|
4549
|
+
{
|
|
4550
|
+
name: "AttributeValue",
|
|
4551
|
+
bnf: [
|
|
4552
|
+
[
|
|
4553
|
+
"NCName"
|
|
4554
|
+
],
|
|
4555
|
+
[
|
|
4556
|
+
/[1-9][0-9]*/
|
|
4557
|
+
]
|
|
4558
|
+
]
|
|
4559
|
+
},
|
|
4560
|
+
{
|
|
4561
|
+
name: "%Choice",
|
|
4562
|
+
bnf: [
|
|
4563
|
+
[
|
|
4564
|
+
"SequenceOrDifference",
|
|
4565
|
+
"%_Choice_1*"
|
|
4566
|
+
]
|
|
4567
|
+
],
|
|
4568
|
+
fragment: true
|
|
4569
|
+
},
|
|
4570
|
+
{
|
|
4571
|
+
name: "%_Choice_1",
|
|
4572
|
+
bnf: [
|
|
4573
|
+
[
|
|
4574
|
+
"RULE_S*",
|
|
4575
|
+
'"|"',
|
|
4576
|
+
"RULE_S*",
|
|
4577
|
+
"SequenceOrDifference"
|
|
4578
|
+
]
|
|
4579
|
+
],
|
|
4580
|
+
fragment: true
|
|
4581
|
+
},
|
|
4582
|
+
{
|
|
4583
|
+
name: "SequenceOrDifference",
|
|
4584
|
+
bnf: [
|
|
4585
|
+
[
|
|
4586
|
+
"%Item",
|
|
4587
|
+
"RULE_WHITESPACE*",
|
|
4588
|
+
"%_Item_1?"
|
|
4589
|
+
]
|
|
4590
|
+
]
|
|
4591
|
+
},
|
|
4592
|
+
{
|
|
4593
|
+
name: "%_Item_1",
|
|
4594
|
+
bnf: [
|
|
4595
|
+
[
|
|
4596
|
+
"Minus",
|
|
4597
|
+
"%Item"
|
|
4598
|
+
],
|
|
4599
|
+
[
|
|
4600
|
+
"%Item*"
|
|
4601
|
+
]
|
|
4602
|
+
],
|
|
4603
|
+
fragment: true
|
|
4604
|
+
},
|
|
4605
|
+
{
|
|
4606
|
+
name: "Minus",
|
|
4607
|
+
bnf: [
|
|
4608
|
+
[
|
|
4609
|
+
'"-"'
|
|
4610
|
+
]
|
|
4611
|
+
]
|
|
4612
|
+
},
|
|
4613
|
+
{
|
|
4614
|
+
name: "%Item",
|
|
4615
|
+
bnf: [
|
|
4616
|
+
[
|
|
4617
|
+
"RULE_WHITESPACE*",
|
|
4618
|
+
"PrimaryPreDecoration?",
|
|
4619
|
+
"%Primary",
|
|
4620
|
+
"PrimaryDecoration?"
|
|
4621
|
+
]
|
|
4622
|
+
],
|
|
4623
|
+
fragment: true
|
|
4624
|
+
},
|
|
4625
|
+
{
|
|
4626
|
+
name: "PrimaryDecoration",
|
|
4627
|
+
bnf: [
|
|
4628
|
+
[
|
|
4629
|
+
'"?"'
|
|
4630
|
+
],
|
|
4631
|
+
[
|
|
4632
|
+
'"*"'
|
|
4633
|
+
],
|
|
4634
|
+
[
|
|
4635
|
+
'"+"'
|
|
4636
|
+
]
|
|
4637
|
+
]
|
|
4638
|
+
},
|
|
4639
|
+
{
|
|
4640
|
+
name: "PrimaryPreDecoration",
|
|
4641
|
+
bnf: [
|
|
4642
|
+
[
|
|
4643
|
+
'"&"'
|
|
4644
|
+
],
|
|
4645
|
+
[
|
|
4646
|
+
'"!"'
|
|
4647
|
+
],
|
|
4648
|
+
[
|
|
4649
|
+
'"~"'
|
|
4650
|
+
]
|
|
4651
|
+
]
|
|
4652
|
+
},
|
|
4653
|
+
{
|
|
4654
|
+
name: "%Primary",
|
|
4655
|
+
bnf: [
|
|
4656
|
+
[
|
|
4657
|
+
"NCName"
|
|
4658
|
+
],
|
|
4659
|
+
[
|
|
4660
|
+
"StringLiteral"
|
|
4661
|
+
],
|
|
4662
|
+
[
|
|
4663
|
+
"CharCode"
|
|
4664
|
+
],
|
|
4665
|
+
[
|
|
4666
|
+
"CharClass"
|
|
4667
|
+
],
|
|
4668
|
+
[
|
|
4669
|
+
"SubItem"
|
|
4670
|
+
]
|
|
4671
|
+
],
|
|
4672
|
+
fragment: true
|
|
4673
|
+
},
|
|
4674
|
+
{
|
|
4675
|
+
name: "SubItem",
|
|
4676
|
+
bnf: [
|
|
4677
|
+
[
|
|
4678
|
+
'"("',
|
|
4679
|
+
"RULE_S*",
|
|
4680
|
+
"%Choice",
|
|
4681
|
+
"RULE_S*",
|
|
4682
|
+
'")"'
|
|
4683
|
+
]
|
|
4684
|
+
]
|
|
4685
|
+
},
|
|
4686
|
+
{
|
|
4687
|
+
name: "StringLiteral",
|
|
4688
|
+
bnf: [
|
|
4689
|
+
[
|
|
4690
|
+
"'\"'",
|
|
4691
|
+
/[^"]*/,
|
|
4692
|
+
"'\"'"
|
|
4693
|
+
],
|
|
4694
|
+
[
|
|
4695
|
+
'"\'"',
|
|
4696
|
+
/[^']*/,
|
|
4697
|
+
'"\'"'
|
|
4698
|
+
]
|
|
4699
|
+
]
|
|
4700
|
+
},
|
|
4701
|
+
{
|
|
4702
|
+
name: "CharCode",
|
|
4703
|
+
bnf: [
|
|
4704
|
+
[
|
|
4705
|
+
'"#x"',
|
|
4706
|
+
/[0-9a-zA-Z]+/
|
|
4707
|
+
]
|
|
4708
|
+
]
|
|
4709
|
+
},
|
|
4710
|
+
{
|
|
4711
|
+
name: "CharClass",
|
|
4712
|
+
bnf: [
|
|
4713
|
+
[
|
|
4714
|
+
"'['",
|
|
4715
|
+
"'^'?",
|
|
4716
|
+
"%RULE_CharClass_1+",
|
|
4717
|
+
'"]"'
|
|
4718
|
+
]
|
|
4719
|
+
]
|
|
4720
|
+
},
|
|
4721
|
+
{
|
|
4722
|
+
name: "%RULE_CharClass_1",
|
|
4723
|
+
bnf: [
|
|
4724
|
+
[
|
|
4725
|
+
"CharCodeRange"
|
|
4726
|
+
],
|
|
4727
|
+
[
|
|
4728
|
+
"CharRange"
|
|
4729
|
+
],
|
|
4730
|
+
[
|
|
4731
|
+
"CharCode"
|
|
4732
|
+
],
|
|
4733
|
+
[
|
|
4734
|
+
"RULE_Char"
|
|
4735
|
+
]
|
|
4736
|
+
],
|
|
4737
|
+
fragment: true
|
|
4738
|
+
},
|
|
4739
|
+
{
|
|
4740
|
+
name: "RULE_Char",
|
|
4741
|
+
bnf: [
|
|
4742
|
+
[
|
|
4743
|
+
/\x09/
|
|
4744
|
+
],
|
|
4745
|
+
[
|
|
4746
|
+
/\x0A/
|
|
4747
|
+
],
|
|
4748
|
+
[
|
|
4749
|
+
/\x0D/
|
|
4750
|
+
],
|
|
4751
|
+
[
|
|
4752
|
+
/[\x20-\x5c]/
|
|
4753
|
+
],
|
|
4754
|
+
[
|
|
4755
|
+
/[\x5e-\uD7FF]/
|
|
4756
|
+
],
|
|
4757
|
+
[
|
|
4758
|
+
/[\uE000-\uFFFD]/
|
|
4759
|
+
]
|
|
4760
|
+
]
|
|
4761
|
+
},
|
|
4762
|
+
{
|
|
4763
|
+
name: "CharRange",
|
|
4764
|
+
bnf: [
|
|
4765
|
+
[
|
|
4766
|
+
"RULE_Char",
|
|
4767
|
+
'"-"',
|
|
4768
|
+
"RULE_Char"
|
|
4769
|
+
]
|
|
4770
|
+
]
|
|
4771
|
+
},
|
|
4772
|
+
{
|
|
4773
|
+
name: "CharCodeRange",
|
|
4774
|
+
bnf: [
|
|
4775
|
+
[
|
|
4776
|
+
"CharCode",
|
|
4777
|
+
'"-"',
|
|
4778
|
+
"CharCode"
|
|
4779
|
+
]
|
|
4780
|
+
]
|
|
4781
|
+
},
|
|
4782
|
+
{
|
|
4783
|
+
name: "RULE_WHITESPACE",
|
|
4784
|
+
bnf: [
|
|
4785
|
+
[
|
|
4786
|
+
"%RULE_WHITESPACE_CHAR*"
|
|
4787
|
+
],
|
|
4788
|
+
[
|
|
4789
|
+
"Comment",
|
|
4790
|
+
"RULE_WHITESPACE*"
|
|
4791
|
+
]
|
|
4792
|
+
]
|
|
4793
|
+
},
|
|
4794
|
+
{
|
|
4795
|
+
name: "RULE_S",
|
|
4796
|
+
bnf: [
|
|
4797
|
+
[
|
|
4798
|
+
"RULE_WHITESPACE",
|
|
4799
|
+
"RULE_S*"
|
|
4800
|
+
],
|
|
4801
|
+
[
|
|
4802
|
+
"RULE_EOL",
|
|
4803
|
+
"RULE_S*"
|
|
4804
|
+
]
|
|
4805
|
+
]
|
|
4806
|
+
},
|
|
4807
|
+
{
|
|
4808
|
+
name: "%RULE_WHITESPACE_CHAR",
|
|
4809
|
+
bnf: [
|
|
4810
|
+
[
|
|
4811
|
+
/\x09/
|
|
4812
|
+
],
|
|
4813
|
+
[
|
|
4814
|
+
/\x20/
|
|
4815
|
+
]
|
|
4816
|
+
],
|
|
4817
|
+
fragment: true
|
|
4818
|
+
},
|
|
4819
|
+
{
|
|
4820
|
+
name: "Comment",
|
|
4821
|
+
bnf: [
|
|
4822
|
+
[
|
|
4823
|
+
'"/*"',
|
|
4824
|
+
"%RULE_Comment_Body*",
|
|
4825
|
+
'"*/"'
|
|
4826
|
+
]
|
|
4827
|
+
]
|
|
4828
|
+
},
|
|
4829
|
+
{
|
|
4830
|
+
name: "%RULE_Comment_Body",
|
|
4831
|
+
bnf: [
|
|
4832
|
+
[
|
|
4833
|
+
/[^*]/
|
|
4834
|
+
],
|
|
4835
|
+
[
|
|
4836
|
+
'"*"+',
|
|
4837
|
+
/[^/]*/
|
|
4838
|
+
]
|
|
4839
|
+
],
|
|
4840
|
+
fragment: true
|
|
4841
|
+
},
|
|
4842
|
+
{
|
|
4843
|
+
name: "RULE_EOL",
|
|
4844
|
+
bnf: [
|
|
4845
|
+
[
|
|
4846
|
+
/\x0D/,
|
|
4847
|
+
/\x0A/
|
|
4848
|
+
],
|
|
4849
|
+
[
|
|
4850
|
+
/\x0A/
|
|
4851
|
+
],
|
|
4852
|
+
[
|
|
4853
|
+
/\x0D/
|
|
4854
|
+
]
|
|
4855
|
+
]
|
|
4856
|
+
},
|
|
4857
|
+
{
|
|
4858
|
+
name: "Link",
|
|
4859
|
+
bnf: [
|
|
4860
|
+
[
|
|
4861
|
+
"'['",
|
|
4862
|
+
"Url",
|
|
4863
|
+
"']'"
|
|
4864
|
+
]
|
|
4865
|
+
]
|
|
4866
|
+
},
|
|
4867
|
+
{
|
|
4868
|
+
name: "Url",
|
|
4869
|
+
bnf: [
|
|
4870
|
+
[
|
|
4871
|
+
/[^\x5D:/?#]/,
|
|
4872
|
+
'"://"',
|
|
4873
|
+
/[^\x5D#]+/,
|
|
4874
|
+
"%Url1?"
|
|
4875
|
+
]
|
|
4876
|
+
]
|
|
4877
|
+
},
|
|
4878
|
+
{
|
|
4879
|
+
name: "%Url1",
|
|
4880
|
+
bnf: [
|
|
4881
|
+
[
|
|
4882
|
+
'"#"',
|
|
4883
|
+
"NCName"
|
|
4884
|
+
]
|
|
4885
|
+
],
|
|
4886
|
+
fragment: true
|
|
4887
|
+
}
|
|
4888
|
+
];
|
|
4889
|
+
BNF2.defaultParser = new Parser_1.Parser(BNF2.RULES, {
|
|
4890
|
+
debug: false
|
|
4891
|
+
});
|
|
4892
|
+
var preDecorationRE = /^(!|&)/;
|
|
4893
|
+
var decorationRE = /(\?|\+|\*)$/;
|
|
4894
|
+
var subExpressionRE = /^%/;
|
|
4895
|
+
function getBNFRule(name, parser2) {
|
|
4896
|
+
if (typeof name == "string") {
|
|
4897
|
+
var decoration = decorationRE.exec(name);
|
|
4898
|
+
var preDecoration = preDecorationRE.exec(name);
|
|
4899
|
+
var preDecorationText = preDecoration ? preDecoration[0] : "";
|
|
4900
|
+
var decorationText = decoration ? decoration[0] + " " : "";
|
|
4901
|
+
var subexpression = subExpressionRE.test(name);
|
|
4902
|
+
if (subexpression) {
|
|
4903
|
+
var lonely = isLonelyRule(name, parser2);
|
|
4904
|
+
if (lonely) return preDecorationText + getBNFBody(name, parser2) + decorationText;
|
|
4905
|
+
return preDecorationText + "(" + getBNFBody(name, parser2) + ")" + decorationText;
|
|
4906
|
+
}
|
|
4907
|
+
return name.replace(preDecorationRE, preDecorationText);
|
|
4908
|
+
} else {
|
|
4909
|
+
return name.source.replace(/\\(?:x|u)([a-zA-Z0-9]+)/g, "#x$1").replace(/\[\\(?:x|u)([a-zA-Z0-9]+)-\\(?:x|u)([a-zA-Z0-9]+)\]/g, "[#x$1-#x$2]");
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
function isLonelyRule(name, parser2) {
|
|
4913
|
+
var rule = Parser_1.findRuleByName(name, parser2);
|
|
4914
|
+
return rule && rule.bnf.length == 1 && rule.bnf[0].length == 1 && (_instanceof(rule.bnf[0][0], RegExp) || rule.bnf[0][0][0] == '"' || rule.bnf[0][0][0] == "'");
|
|
4915
|
+
}
|
|
4916
|
+
function getBNFChoice(rules, parser2) {
|
|
4917
|
+
return rules.map(function(x) {
|
|
4918
|
+
return getBNFRule(x, parser2);
|
|
4919
|
+
}).join(" ");
|
|
4920
|
+
}
|
|
4921
|
+
function getBNFBody(name, parser2) {
|
|
4922
|
+
var rule = Parser_1.findRuleByName(name, parser2);
|
|
4923
|
+
if (rule) return rule.bnf.map(function(x) {
|
|
4924
|
+
return getBNFChoice(x, parser2);
|
|
4925
|
+
}).join(" | ");
|
|
4926
|
+
return "RULE_NOT_FOUND {" + name + "}";
|
|
4927
|
+
}
|
|
4928
|
+
function emit(parser2) {
|
|
4929
|
+
var acumulator = [];
|
|
4930
|
+
parser2.grammarRules.forEach(function(l) {
|
|
4931
|
+
if (!/^%/.test(l.name)) {
|
|
4932
|
+
var recover = l.recover ? " { recoverUntil=" + l.recover + " }" : "";
|
|
4933
|
+
acumulator.push(l.name + " ::= " + getBNFBody(l.name, parser2) + recover);
|
|
4934
|
+
}
|
|
4935
|
+
});
|
|
4936
|
+
return acumulator.join("\n");
|
|
4937
|
+
}
|
|
4938
|
+
BNF2.emit = emit;
|
|
4939
|
+
var subitems = 0;
|
|
4940
|
+
function restar(total, resta) {
|
|
4941
|
+
console.log("reberia restar " + resta + " a " + total);
|
|
4942
|
+
throw new Error("Difference not supported yet");
|
|
4943
|
+
}
|
|
4944
|
+
function convertRegex(txt) {
|
|
4945
|
+
return new RegExp(txt.replace(/#x([a-zA-Z0-9]{4})/g, "\\u$1").replace(/#x([a-zA-Z0-9]{3})/g, "\\u0$1").replace(/#x([a-zA-Z0-9]{2})/g, "\\x$1").replace(/#x([a-zA-Z0-9]{1})/g, "\\x0$1"));
|
|
4946
|
+
}
|
|
4947
|
+
function getSubItems(tmpRules, seq, parentName, parentAttributes) {
|
|
4948
|
+
var anterior = null;
|
|
4949
|
+
var bnfSeq = [];
|
|
4950
|
+
seq.children.forEach(function(x, i) {
|
|
4951
|
+
if (x.type == "Minus") {
|
|
4952
|
+
restar(anterior, x);
|
|
4953
|
+
} else {}
|
|
4954
|
+
var decoration = seq.children[i + 1];
|
|
4955
|
+
decoration = decoration && decoration.type == "PrimaryDecoration" && decoration.text || "";
|
|
4956
|
+
var preDecoration = "";
|
|
4957
|
+
if (anterior && anterior.type == "PrimaryPreDecoration") {
|
|
4958
|
+
preDecoration = anterior.text;
|
|
4959
|
+
}
|
|
4960
|
+
var pinned = preDecoration == "~" ? 1 : void 0;
|
|
4961
|
+
if (pinned) {
|
|
4962
|
+
preDecoration = "";
|
|
4963
|
+
}
|
|
4964
|
+
switch(x.type){
|
|
4965
|
+
case "SubItem":
|
|
4966
|
+
var name = "%" + (parentName + subitems++);
|
|
4967
|
+
createRule(tmpRules, x, name, parentAttributes);
|
|
4968
|
+
bnfSeq.push(preDecoration + name + decoration);
|
|
4969
|
+
break;
|
|
4970
|
+
case "NCName":
|
|
4971
|
+
bnfSeq.push(preDecoration + x.text + decoration);
|
|
4972
|
+
break;
|
|
4973
|
+
case "StringLiteral":
|
|
4974
|
+
if (decoration || preDecoration || !/^['"/()a-zA-Z0-9&_.:=,+*\-\^\\]+$/.test(x.text)) {
|
|
4975
|
+
bnfSeq.push(preDecoration + x.text + decoration);
|
|
4976
|
+
} else {
|
|
4977
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4978
|
+
try {
|
|
4979
|
+
for(var _iterator = x.text.slice(1, -1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4980
|
+
var c = _step.value;
|
|
4981
|
+
if (parentAttributes && parentAttributes["ignoreCase"] == "true" && /[a-zA-Z]/.test(c)) {
|
|
4982
|
+
bnfSeq.push(new RegExp("[" + c.toUpperCase() + c.toLowerCase() + "]"));
|
|
4983
|
+
} else {
|
|
4984
|
+
bnfSeq.push(new RegExp(Parser_1.escapeRegExp(c)));
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
} catch (err) {
|
|
4988
|
+
_didIteratorError = true;
|
|
4989
|
+
_iteratorError = err;
|
|
4990
|
+
} finally{
|
|
4991
|
+
try {
|
|
4992
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4993
|
+
_iterator.return();
|
|
4994
|
+
}
|
|
4995
|
+
} finally{
|
|
4996
|
+
if (_didIteratorError) {
|
|
4997
|
+
throw _iteratorError;
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
break;
|
|
5003
|
+
case "CharCode":
|
|
5004
|
+
case "CharClass":
|
|
5005
|
+
if (decoration || preDecoration) {
|
|
5006
|
+
var newRule = {
|
|
5007
|
+
name: "%" + (parentName + subitems++),
|
|
5008
|
+
bnf: [
|
|
5009
|
+
[
|
|
5010
|
+
convertRegex(x.text)
|
|
5011
|
+
]
|
|
5012
|
+
],
|
|
5013
|
+
pinned: pinned
|
|
5014
|
+
};
|
|
5015
|
+
tmpRules.push(newRule);
|
|
5016
|
+
bnfSeq.push(preDecoration + newRule.name + decoration);
|
|
5017
|
+
} else {
|
|
5018
|
+
bnfSeq.push(convertRegex(x.text));
|
|
5019
|
+
}
|
|
5020
|
+
break;
|
|
5021
|
+
case "PrimaryPreDecoration":
|
|
5022
|
+
case "PrimaryDecoration":
|
|
5023
|
+
break;
|
|
5024
|
+
default:
|
|
5025
|
+
throw new Error(" HOW SHOULD I PARSE THIS? " + x.type + " -> " + JSON.stringify(x.text));
|
|
5026
|
+
}
|
|
5027
|
+
anterior = x;
|
|
5028
|
+
});
|
|
5029
|
+
return bnfSeq;
|
|
5030
|
+
}
|
|
5031
|
+
function createRule(tmpRules, token, name) {
|
|
5032
|
+
var parentAttributes = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : void 0;
|
|
5033
|
+
var attrNode = token.children.filter(function(x) {
|
|
5034
|
+
return x.type == "Attributes";
|
|
5035
|
+
})[0];
|
|
5036
|
+
var attributes = {};
|
|
5037
|
+
if (attrNode) {
|
|
5038
|
+
attrNode.children.forEach(function(x) {
|
|
5039
|
+
var name2 = x.children.filter(function(x2) {
|
|
5040
|
+
return x2.type == "NCName";
|
|
5041
|
+
})[0].text;
|
|
5042
|
+
if (name2 in attributes) {
|
|
5043
|
+
throw new TokenError_1.TokenError("Duplicated attribute " + name2, x);
|
|
5044
|
+
} else {
|
|
5045
|
+
attributes[name2] = x.children.filter(function(x2) {
|
|
5046
|
+
return x2.type == "AttributeValue";
|
|
5047
|
+
})[0].text;
|
|
5048
|
+
}
|
|
5049
|
+
});
|
|
5050
|
+
}
|
|
5051
|
+
var bnf = token.children.filter(function(x) {
|
|
5052
|
+
return x.type == "SequenceOrDifference";
|
|
5053
|
+
}).map(function(s) {
|
|
5054
|
+
return getSubItems(tmpRules, s, name, parentAttributes ? parentAttributes : attributes);
|
|
5055
|
+
});
|
|
5056
|
+
var rule = {
|
|
5057
|
+
name: name,
|
|
5058
|
+
bnf: bnf
|
|
5059
|
+
};
|
|
5060
|
+
if (name.indexOf("%") == 0) rule.fragment = true;
|
|
5061
|
+
if (attributes["recoverUntil"]) {
|
|
5062
|
+
rule.recover = attributes["recoverUntil"];
|
|
5063
|
+
if (rule.bnf.length > 1) throw new TokenError_1.TokenError("only one-option productions are suitable for error recovering", token);
|
|
5064
|
+
}
|
|
5065
|
+
if ("pin" in attributes) {
|
|
5066
|
+
var num = parseInt(attributes["pin"]);
|
|
5067
|
+
if (!isNaN(num)) {
|
|
5068
|
+
rule.pinned = num;
|
|
5069
|
+
}
|
|
5070
|
+
if (rule.bnf.length > 1) throw new TokenError_1.TokenError("only one-option productions are suitable for pinning", token);
|
|
5071
|
+
}
|
|
5072
|
+
if ("ws" in attributes) {
|
|
5073
|
+
rule.implicitWs = attributes["ws"] != "explicit";
|
|
5074
|
+
} else {
|
|
5075
|
+
rule.implicitWs = null;
|
|
5076
|
+
}
|
|
5077
|
+
rule.fragment = rule.fragment || attributes["fragment"] == "true";
|
|
5078
|
+
rule.simplifyWhenOneChildren = attributes["simplifyWhenOneChildren"] == "true";
|
|
5079
|
+
tmpRules.push(rule);
|
|
5080
|
+
}
|
|
5081
|
+
function getRules(source) {
|
|
5082
|
+
var parser2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
5083
|
+
var ast = parser2.getAST(source);
|
|
5084
|
+
if (!ast) throw new Error("Could not parse " + source);
|
|
5085
|
+
if (ast.errors && ast.errors.length) {
|
|
5086
|
+
throw ast.errors[0];
|
|
5087
|
+
}
|
|
5088
|
+
var implicitWs = null;
|
|
5089
|
+
var attrNode = ast.children.filter(function(x) {
|
|
5090
|
+
return x.type == "Attributes";
|
|
5091
|
+
})[0];
|
|
5092
|
+
var attributes = {};
|
|
5093
|
+
if (attrNode) {
|
|
5094
|
+
attrNode.children.forEach(function(x) {
|
|
5095
|
+
var name = x.children.filter(function(x2) {
|
|
5096
|
+
return x2.type == "NCName";
|
|
5097
|
+
})[0].text;
|
|
5098
|
+
if (name in attributes) {
|
|
5099
|
+
throw new TokenError_1.TokenError("Duplicated attribute " + name, x);
|
|
5100
|
+
} else {
|
|
5101
|
+
attributes[name] = x.children.filter(function(x2) {
|
|
5102
|
+
return x2.type == "AttributeValue";
|
|
5103
|
+
})[0].text;
|
|
5104
|
+
}
|
|
5105
|
+
});
|
|
5106
|
+
}
|
|
5107
|
+
implicitWs = attributes["ws"] == "implicit";
|
|
5108
|
+
var tmpRules = [];
|
|
5109
|
+
ast.children.filter(function(x) {
|
|
5110
|
+
return x.type == "Production";
|
|
5111
|
+
}).map(function(x) {
|
|
5112
|
+
var name = x.children.filter(function(x2) {
|
|
5113
|
+
return x2.type == "NCName";
|
|
5114
|
+
})[0].text;
|
|
5115
|
+
createRule(tmpRules, x, name);
|
|
5116
|
+
});
|
|
5117
|
+
tmpRules.forEach(function(rule) {
|
|
5118
|
+
if (rule.implicitWs === null) rule.implicitWs = implicitWs;
|
|
5119
|
+
});
|
|
5120
|
+
return tmpRules;
|
|
5121
|
+
}
|
|
5122
|
+
BNF2.getRules = getRules;
|
|
5123
|
+
function Transform(source) {
|
|
5124
|
+
var subParser = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : BNF2.defaultParser;
|
|
5125
|
+
return getRules(source.join(""), subParser);
|
|
5126
|
+
}
|
|
5127
|
+
BNF2.Transform = Transform;
|
|
5128
|
+
var Parser2 = /*#__PURE__*/ function(_Parser_1_Parser) {
|
|
5129
|
+
_inherits(Parser2, _Parser_1_Parser);
|
|
5130
|
+
var _super = _create_super(Parser2);
|
|
5131
|
+
function Parser2(source, options) {
|
|
5132
|
+
_class_call_check(this, Parser2);
|
|
5133
|
+
var subParser = options && options.debugRulesParser === true ? new Parser_1.Parser(BNF2.RULES, {
|
|
5134
|
+
debug: true
|
|
5135
|
+
}) : BNF2.defaultParser;
|
|
5136
|
+
return _super.call(this, getRules(source, subParser), options);
|
|
5137
|
+
}
|
|
5138
|
+
_create_class(Parser2, [
|
|
5139
|
+
{
|
|
5140
|
+
key: "emitSource",
|
|
5141
|
+
value: function emitSource() {
|
|
5142
|
+
return emit(this);
|
|
5143
|
+
}
|
|
5144
|
+
}
|
|
5145
|
+
]);
|
|
5146
|
+
return Parser2;
|
|
5147
|
+
}(Parser_1.Parser);
|
|
5148
|
+
BNF2.Parser = Parser2;
|
|
5149
|
+
})(BNF || (BNF = {}));
|
|
5150
|
+
exports.default = BNF;
|
|
5151
|
+
}
|
|
5152
|
+
});
|
|
5153
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/index.js
|
|
5154
|
+
var require_Grammars = __commonJS({
|
|
5155
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/Grammars/index.js": function(exports) {
|
|
5156
|
+
"use strict";
|
|
5157
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5158
|
+
value: true
|
|
5159
|
+
});
|
|
5160
|
+
var BNF_1 = require_BNF();
|
|
5161
|
+
Object.defineProperty(exports, "BNF", {
|
|
5162
|
+
enumerable: true,
|
|
5163
|
+
get: function get() {
|
|
5164
|
+
return BNF_1.default;
|
|
5165
|
+
}
|
|
5166
|
+
});
|
|
5167
|
+
var W3CEBNF_1 = require_W3CEBNF();
|
|
5168
|
+
Object.defineProperty(exports, "W3C", {
|
|
5169
|
+
enumerable: true,
|
|
5170
|
+
get: function get() {
|
|
5171
|
+
return W3CEBNF_1.default;
|
|
5172
|
+
}
|
|
5173
|
+
});
|
|
5174
|
+
var Custom_1 = require_Custom();
|
|
5175
|
+
Object.defineProperty(exports, "Custom", {
|
|
5176
|
+
enumerable: true,
|
|
5177
|
+
get: function get() {
|
|
5178
|
+
return Custom_1.default;
|
|
5179
|
+
}
|
|
5180
|
+
});
|
|
5181
|
+
}
|
|
5182
|
+
});
|
|
5183
|
+
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/index.js
|
|
5184
|
+
var require_dist = __commonJS({
|
|
5185
|
+
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/ebnf@1.9.1/node_modules/ebnf/dist/index.js": function(exports) {
|
|
5186
|
+
"use strict";
|
|
5187
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5188
|
+
value: true
|
|
5189
|
+
});
|
|
5190
|
+
var Parser_1 = require_Parser();
|
|
5191
|
+
Object.defineProperty(exports, "Parser", {
|
|
5192
|
+
enumerable: true,
|
|
5193
|
+
get: function get() {
|
|
5194
|
+
return Parser_1.Parser;
|
|
5195
|
+
}
|
|
5196
|
+
});
|
|
5197
|
+
var TokenError_1 = require_TokenError();
|
|
5198
|
+
Object.defineProperty(exports, "TokenError", {
|
|
5199
|
+
enumerable: true,
|
|
5200
|
+
get: function get() {
|
|
5201
|
+
return TokenError_1.TokenError;
|
|
5202
|
+
}
|
|
5203
|
+
});
|
|
5204
|
+
exports.Grammars = require_Grammars();
|
|
5205
|
+
}
|
|
5206
|
+
});
|
|
1625
5207
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/timm@1.7.1/node_modules/timm/lib/timm.js
|
|
1626
5208
|
var require_timm = __commonJS({
|
|
1627
5209
|
"../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/timm@1.7.1/node_modules/timm/lib/timm.js": function(exports) {
|
|
@@ -1714,14 +5296,14 @@ var AsyncNodePlugin = function() {
|
|
|
1714
5296
|
result[idx] = newItem;
|
|
1715
5297
|
return result;
|
|
1716
5298
|
}
|
|
1717
|
-
function getIn(obj,
|
|
1718
|
-
if (!Array.isArray(
|
|
5299
|
+
function getIn(obj, path2) {
|
|
5300
|
+
if (!Array.isArray(path2)) {
|
|
1719
5301
|
throwStr(IS_DEV ? "A path array should be provided when calling getIn()" : INVALID_ARGS);
|
|
1720
5302
|
}
|
|
1721
5303
|
if (obj == null) return void 0;
|
|
1722
5304
|
var ptr = obj;
|
|
1723
|
-
for(var i = 0; i <
|
|
1724
|
-
var key =
|
|
5305
|
+
for(var i = 0; i < path2.length; i++){
|
|
5306
|
+
var key = path2[i];
|
|
1725
5307
|
ptr = ptr != null ? ptr[key] : void 0;
|
|
1726
5308
|
if (ptr === void 0) return ptr;
|
|
1727
5309
|
}
|
|
@@ -1735,18 +5317,18 @@ var AsyncNodePlugin = function() {
|
|
|
1735
5317
|
obj2[key] = val;
|
|
1736
5318
|
return obj2;
|
|
1737
5319
|
}
|
|
1738
|
-
function setIn8(obj,
|
|
1739
|
-
if (!
|
|
1740
|
-
return doSetIn(obj,
|
|
5320
|
+
function setIn8(obj, path2, val) {
|
|
5321
|
+
if (!path2.length) return val;
|
|
5322
|
+
return doSetIn(obj, path2, val, 0);
|
|
1741
5323
|
}
|
|
1742
|
-
function doSetIn(obj,
|
|
5324
|
+
function doSetIn(obj, path2, val, idx) {
|
|
1743
5325
|
var newValue;
|
|
1744
|
-
var key =
|
|
1745
|
-
if (idx ===
|
|
5326
|
+
var key = path2[idx];
|
|
5327
|
+
if (idx === path2.length - 1) {
|
|
1746
5328
|
newValue = val;
|
|
1747
5329
|
} else {
|
|
1748
|
-
var nestedObj = isObject(obj) && isObject(obj[key]) ? obj[key] : typeof
|
|
1749
|
-
newValue = doSetIn(nestedObj,
|
|
5330
|
+
var nestedObj = isObject(obj) && isObject(obj[key]) ? obj[key] : typeof path2[idx + 1] === "number" ? [] : {};
|
|
5331
|
+
newValue = doSetIn(nestedObj, path2, val, idx + 1);
|
|
1750
5332
|
}
|
|
1751
5333
|
return set2(obj, key, newValue);
|
|
1752
5334
|
}
|
|
@@ -1755,10 +5337,10 @@ var AsyncNodePlugin = function() {
|
|
|
1755
5337
|
var nextVal = fnUpdate(prevVal);
|
|
1756
5338
|
return set2(obj, key, nextVal);
|
|
1757
5339
|
}
|
|
1758
|
-
function updateIn(obj,
|
|
1759
|
-
var prevVal = getIn(obj,
|
|
5340
|
+
function updateIn(obj, path2, fnUpdate) {
|
|
5341
|
+
var prevVal = getIn(obj, path2);
|
|
1760
5342
|
var nextVal = fnUpdate(prevVal);
|
|
1761
|
-
return setIn8(obj,
|
|
5343
|
+
return setIn8(obj, path2, nextVal);
|
|
1762
5344
|
}
|
|
1763
5345
|
function merge(a, b, c, d, e, f) {
|
|
1764
5346
|
for(var _len = arguments.length, rest = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++){
|
|
@@ -1794,11 +5376,11 @@ var AsyncNodePlugin = function() {
|
|
|
1794
5376
|
f
|
|
1795
5377
|
].concat(_to_consumable_array(rest))) : doMerge(false, true, a, b, c, d, e, f);
|
|
1796
5378
|
}
|
|
1797
|
-
function mergeIn(a,
|
|
5379
|
+
function mergeIn(a, path2, b, c, d, e, f) {
|
|
1798
5380
|
for(var _len = arguments.length, rest = new Array(_len > 7 ? _len - 7 : 0), _key = 7; _key < _len; _key++){
|
|
1799
5381
|
rest[_key - 7] = arguments[_key];
|
|
1800
5382
|
}
|
|
1801
|
-
var prevVal = getIn(a,
|
|
5383
|
+
var prevVal = getIn(a, path2);
|
|
1802
5384
|
if (prevVal == null) prevVal = {};
|
|
1803
5385
|
var nextVal;
|
|
1804
5386
|
if (rest.length) {
|
|
@@ -1817,7 +5399,7 @@ var AsyncNodePlugin = function() {
|
|
|
1817
5399
|
} else {
|
|
1818
5400
|
nextVal = doMerge(false, false, prevVal, b, c, d, e, f);
|
|
1819
5401
|
}
|
|
1820
|
-
return setIn8(a,
|
|
5402
|
+
return setIn8(a, path2, nextVal);
|
|
1821
5403
|
}
|
|
1822
5404
|
function omit5(obj, attrs) {
|
|
1823
5405
|
var omitList = Array.isArray(attrs) ? attrs : [
|
|
@@ -2383,6 +5965,9 @@ var AsyncNodePlugin = function() {
|
|
|
2383
5965
|
}(Hook);
|
|
2384
5966
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+player@0.0.0/node_modules/@player-ui/player/dist/index.mjs
|
|
2385
5967
|
var import_ts_nested_error = __toESM(require_nested_error(), 1);
|
|
5968
|
+
var import_arr_flatten = __toESM(require_arr_flatten(), 1);
|
|
5969
|
+
var import_parsimmon = __toESM(require_parsimmon(), 1);
|
|
5970
|
+
var import_ebnf = __toESM(require_dist(), 1);
|
|
2386
5971
|
var import_ts_nested_error2 = __toESM(require_nested_error(), 1);
|
|
2387
5972
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+player@0.0.0/node_modules/@player-ui/player/dist/index.mjs
|
|
2388
5973
|
var import_timm = __toESM(require_timm(), 1);
|
|
@@ -2506,20 +6091,20 @@ var AsyncNodePlugin = function() {
|
|
|
2506
6091
|
// ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/@player-ui+partial-match-registry@0.0.0/node_modules/@player-ui/partial-match-registry/dist/index.mjs
|
|
2507
6092
|
var import_sorted_array = __toESM(require_sorted_array(), 1);
|
|
2508
6093
|
function traverseObj(object) {
|
|
2509
|
-
var
|
|
6094
|
+
var path2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], pairs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Map();
|
|
2510
6095
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2511
6096
|
try {
|
|
2512
6097
|
for(var _iterator = Object.keys(object)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2513
6098
|
var key = _step.value;
|
|
2514
6099
|
"";
|
|
2515
6100
|
var val = object[key];
|
|
2516
|
-
var
|
|
6101
|
+
var nestedPath2 = _to_consumable_array(path2).concat([
|
|
2517
6102
|
key
|
|
2518
6103
|
]);
|
|
2519
6104
|
if (typeof val === "object") {
|
|
2520
|
-
traverseObj(val,
|
|
6105
|
+
traverseObj(val, nestedPath2, pairs);
|
|
2521
6106
|
} else {
|
|
2522
|
-
pairs.set(
|
|
6107
|
+
pairs.set(nestedPath2, val);
|
|
2523
6108
|
}
|
|
2524
6109
|
}
|
|
2525
6110
|
} catch (err) {
|
|
@@ -2567,12 +6152,12 @@ var AsyncNodePlugin = function() {
|
|
|
2567
6152
|
},
|
|
2568
6153
|
{
|
|
2569
6154
|
/** Fetch the best match in the registry */ key: "get",
|
|
2570
|
-
value: function get(
|
|
6155
|
+
value: function get(query2) {
|
|
2571
6156
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2572
6157
|
try {
|
|
2573
6158
|
for(var _iterator = this.store.array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2574
6159
|
var entry = _step.value;
|
|
2575
|
-
if (entry.matcher(
|
|
6160
|
+
if (entry.matcher(query2)) {
|
|
2576
6161
|
return entry.value;
|
|
2577
6162
|
}
|
|
2578
6163
|
}
|
|
@@ -2646,10 +6231,10 @@ var AsyncNodePlugin = function() {
|
|
|
2646
6231
|
value: value
|
|
2647
6232
|
};
|
|
2648
6233
|
};
|
|
2649
|
-
var toPath = function(
|
|
6234
|
+
var toPath = function(path2) {
|
|
2650
6235
|
return {
|
|
2651
6236
|
name: "PathNode",
|
|
2652
|
-
path:
|
|
6237
|
+
path: path2
|
|
2653
6238
|
};
|
|
2654
6239
|
};
|
|
2655
6240
|
var toQuery = function(key, value) {
|
|
@@ -2668,6 +6253,30 @@ var AsyncNodePlugin = function() {
|
|
|
2668
6253
|
value: values
|
|
2669
6254
|
};
|
|
2670
6255
|
};
|
|
6256
|
+
var doubleQuote = import_parsimmon.default.string('"');
|
|
6257
|
+
var singleQuote = import_parsimmon.default.string("'");
|
|
6258
|
+
var backTick = import_parsimmon.default.string("`");
|
|
6259
|
+
var identifier = import_parsimmon.default.regex(/[\w\-@]+/).desc("identifier").map(toValue);
|
|
6260
|
+
var path;
|
|
6261
|
+
var futurePath = import_parsimmon.default.lazy(function() {
|
|
6262
|
+
return path;
|
|
6263
|
+
});
|
|
6264
|
+
var nestedPath = futurePath.trim(import_parsimmon.default.optWhitespace).wrap(import_parsimmon.default.string("{{"), import_parsimmon.default.string("}}")).map(toPath);
|
|
6265
|
+
var nestedExpression = import_parsimmon.default.regex(/[^`]*/).wrap(backTick, backTick).map(toExpression);
|
|
6266
|
+
var segment = import_parsimmon.default.alt(identifier, nestedPath, nestedExpression).atLeast(1).map(import_arr_flatten.default).map(toConcatenatedNode);
|
|
6267
|
+
var optionallyQuotedSegment = import_parsimmon.default.alt(import_parsimmon.default.regex(/[^"]*/).wrap(doubleQuote, doubleQuote).map(toValue), import_parsimmon.default.regex(/[^']*/).wrap(singleQuote, singleQuote).map(toValue), segment);
|
|
6268
|
+
var query = import_parsimmon.default.seq(optionallyQuotedSegment, import_parsimmon.default.string("=").times(1, 3).trim(import_parsimmon.default.optWhitespace), optionallyQuotedSegment).map(function(param) {
|
|
6269
|
+
var _param = _sliced_to_array(param, 3), key = _param[0], value = _param[2];
|
|
6270
|
+
return toQuery(key, value);
|
|
6271
|
+
});
|
|
6272
|
+
var brackets = import_parsimmon.default.alt(query, optionallyQuotedSegment).trim(import_parsimmon.default.optWhitespace).wrap(import_parsimmon.default.string("["), import_parsimmon.default.string("]")).many();
|
|
6273
|
+
var segmentAndBrackets = import_parsimmon.default.seqMap(segment, brackets, function(s, bs) {
|
|
6274
|
+
return [
|
|
6275
|
+
s
|
|
6276
|
+
].concat(_to_consumable_array(bs));
|
|
6277
|
+
});
|
|
6278
|
+
path = import_parsimmon.default.sepBy(segmentAndBrackets, import_parsimmon.default.string(".")).map(import_arr_flatten.default);
|
|
6279
|
+
var parser = new import_ebnf.Grammars.W3C.Parser('\nvalue ::= segment_and_bracket (SEGMENT_SEPARATOR segment_and_bracket)*\nsegment ::= concatenated | expression | modelRef | identifier \nconcatenated ::= (expression | modelRef | identifier)+ \nmodelRef ::= OPEN_CURL OPEN_CURL value CLOSE_CURL CLOSE_CURL \nidentifier ::= [\\w\\-@]+\nquery ::= WHITESPACE* optionally_quoted_segment WHITESPACE* EQUALS EQUALS? EQUALS? WHITESPACE* optionally_quoted_segment WHITESPACE*\nbrackets ::= OPEN_BRACKET WHITESPACE* (query | optionally_quoted_segment) WHITESPACE* CLOSE_BRACKET \nsegment_and_bracket ::= segment brackets*\nquoted_value ::= [^"\']*\noptionally_quoted_segment ::= WHITESPACE* SINGLE_QUOTE quoted_value SINGLE_QUOTE WHITESPACE* | WHITESPACE* DOUBLE_QUOTE quoted_value DOUBLE_QUOTE WHITESPACE* | WHITESPACE* segment WHITESPACE*\nexpression_value ::= [^`]*\nexpression ::= BACK_TICK expression_value BACK_TICK\n\nEQUALS ::= "="\nSEGMENT_SEPARATOR ::= "."\nSINGLE_QUOTE ::= "\'"\nDOUBLE_QUOTE ::= \'"\'\nWHITESPACE ::= " "\nOPEN_CURL ::= "{"\nCLOSE_CURL ::= "}" \nOPEN_BRACKET ::= "[" \nCLOSE_BRACKET ::= "]"\nBACK_TICK ::= "`" \n');
|
|
2671
6280
|
var SEGMENT_SEPARATOR = ".";
|
|
2672
6281
|
var OPEN_CURL = "{";
|
|
2673
6282
|
var CLOSE_CURL = "}";
|
|
@@ -2697,14 +6306,14 @@ var AsyncNodePlugin = function() {
|
|
|
2697
6306
|
charCode === 125;
|
|
2698
6307
|
return !matches;
|
|
2699
6308
|
};
|
|
2700
|
-
var parse = function(
|
|
6309
|
+
var parse = function(path2) {
|
|
2701
6310
|
var index = 1;
|
|
2702
|
-
var ch =
|
|
6311
|
+
var ch = path2.charAt(0);
|
|
2703
6312
|
var next = function(expected) {
|
|
2704
6313
|
if (expected && ch !== expected) {
|
|
2705
6314
|
throw new Error("Expected char: ".concat(expected, " but got: ").concat(ch));
|
|
2706
6315
|
}
|
|
2707
|
-
ch =
|
|
6316
|
+
ch = path2.charAt(index);
|
|
2708
6317
|
index += 1;
|
|
2709
6318
|
return ch;
|
|
2710
6319
|
};
|
|
@@ -2713,7 +6322,7 @@ var AsyncNodePlugin = function() {
|
|
|
2713
6322
|
next();
|
|
2714
6323
|
}
|
|
2715
6324
|
};
|
|
2716
|
-
var
|
|
6325
|
+
var identifier2 = function() {
|
|
2717
6326
|
if (!isIdentifierChar(ch)) {
|
|
2718
6327
|
return;
|
|
2719
6328
|
}
|
|
@@ -2759,7 +6368,7 @@ var AsyncNodePlugin = function() {
|
|
|
2759
6368
|
return toValue(value);
|
|
2760
6369
|
}
|
|
2761
6370
|
};
|
|
2762
|
-
var
|
|
6371
|
+
var nestedPath2 = function() {
|
|
2763
6372
|
if (ch === OPEN_CURL) {
|
|
2764
6373
|
next(OPEN_CURL);
|
|
2765
6374
|
next(OPEN_CURL);
|
|
@@ -2770,10 +6379,10 @@ var AsyncNodePlugin = function() {
|
|
|
2770
6379
|
}
|
|
2771
6380
|
};
|
|
2772
6381
|
var simpleSegment = function() {
|
|
2773
|
-
var
|
|
2774
|
-
return (_ref = (
|
|
6382
|
+
var _nestedPath2, _ref;
|
|
6383
|
+
return (_ref = (_nestedPath2 = nestedPath2()) !== null && _nestedPath2 !== void 0 ? _nestedPath2 : expression()) !== null && _ref !== void 0 ? _ref : identifier2();
|
|
2775
6384
|
};
|
|
2776
|
-
var
|
|
6385
|
+
var segment2 = function() {
|
|
2777
6386
|
var segments = [];
|
|
2778
6387
|
var nextSegment = simpleSegment();
|
|
2779
6388
|
while(nextSegment !== void 0){
|
|
@@ -2785,13 +6394,13 @@ var AsyncNodePlugin = function() {
|
|
|
2785
6394
|
}
|
|
2786
6395
|
return toConcatenatedNode(segments);
|
|
2787
6396
|
};
|
|
2788
|
-
var
|
|
6397
|
+
var optionallyQuotedSegment2 = function() {
|
|
2789
6398
|
whitespace();
|
|
2790
6399
|
if (ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE) {
|
|
2791
|
-
var
|
|
2792
|
-
next(
|
|
6400
|
+
var singleQuote2 = ch === SINGLE_QUOTE;
|
|
6401
|
+
next(singleQuote2 ? SINGLE_QUOTE : DOUBLE_QUOTE);
|
|
2793
6402
|
var id = regex(/[^'"]+/);
|
|
2794
|
-
next(
|
|
6403
|
+
next(singleQuote2 ? SINGLE_QUOTE : DOUBLE_QUOTE);
|
|
2795
6404
|
return id;
|
|
2796
6405
|
}
|
|
2797
6406
|
return simpleSegment();
|
|
@@ -2809,12 +6418,12 @@ var AsyncNodePlugin = function() {
|
|
|
2809
6418
|
if (ch === OPEN_BRACKET) {
|
|
2810
6419
|
next(OPEN_BRACKET);
|
|
2811
6420
|
whitespace();
|
|
2812
|
-
var value =
|
|
6421
|
+
var value = optionallyQuotedSegment2();
|
|
2813
6422
|
if (value) {
|
|
2814
6423
|
whitespace();
|
|
2815
6424
|
if (equals()) {
|
|
2816
6425
|
whitespace();
|
|
2817
|
-
var second =
|
|
6426
|
+
var second = optionallyQuotedSegment2();
|
|
2818
6427
|
value = toQuery(value, second);
|
|
2819
6428
|
whitespace();
|
|
2820
6429
|
}
|
|
@@ -2829,7 +6438,7 @@ var AsyncNodePlugin = function() {
|
|
|
2829
6438
|
};
|
|
2830
6439
|
var parseSegmentAndBrackets = function() {
|
|
2831
6440
|
var parsed = [];
|
|
2832
|
-
var firstSegment =
|
|
6441
|
+
var firstSegment = segment2();
|
|
2833
6442
|
if (firstSegment) {
|
|
2834
6443
|
parsed.push(firstSegment);
|
|
2835
6444
|
var bracketSegment = parseBracket();
|
|
@@ -2877,12 +6486,12 @@ var AsyncNodePlugin = function() {
|
|
|
2877
6486
|
};
|
|
2878
6487
|
_class_call_check(this, _BindingInstance);
|
|
2879
6488
|
var split = Array.isArray(raw) ? raw : raw.split(".");
|
|
2880
|
-
this.split = split.map(function(
|
|
2881
|
-
if (typeof
|
|
2882
|
-
return
|
|
6489
|
+
this.split = split.map(function(segment2) {
|
|
6490
|
+
if (typeof segment2 === "number") {
|
|
6491
|
+
return segment2;
|
|
2883
6492
|
}
|
|
2884
|
-
var tryNum = Number(
|
|
2885
|
-
return isNaN(tryNum) ?
|
|
6493
|
+
var tryNum = Number(segment2);
|
|
6494
|
+
return isNaN(tryNum) ? segment2 : tryNum;
|
|
2886
6495
|
});
|
|
2887
6496
|
Object.freeze(this.split);
|
|
2888
6497
|
this.joined = this.split.join(".");
|
|
@@ -2980,13 +6589,13 @@ var AsyncNodePlugin = function() {
|
|
|
2980
6589
|
}
|
|
2981
6590
|
throw new Error("Unable to resolve value for node: ".concat(node.name));
|
|
2982
6591
|
}
|
|
2983
|
-
function appendPathSegments(
|
|
2984
|
-
if (typeof
|
|
2985
|
-
|
|
6592
|
+
function appendPathSegments(segment2) {
|
|
6593
|
+
if (typeof segment2 === "string" && segment2.indexOf(".") > -1) {
|
|
6594
|
+
segment2.split(".").forEach(function(i) {
|
|
2986
6595
|
context.path.push(maybeConvertToNum(i));
|
|
2987
6596
|
});
|
|
2988
6597
|
} else {
|
|
2989
|
-
context.path.push(
|
|
6598
|
+
context.path.push(segment2);
|
|
2990
6599
|
}
|
|
2991
6600
|
}
|
|
2992
6601
|
function resolveNode(_node) {
|
|
@@ -3064,24 +6673,24 @@ var AsyncNodePlugin = function() {
|
|
|
3064
6673
|
* Takes a binding path, parses it, and returns an equivalent, normalized
|
|
3065
6674
|
* representation of that path.
|
|
3066
6675
|
*/ key: "normalizePath",
|
|
3067
|
-
value: function normalizePath(
|
|
3068
|
-
if (!BINDING_BRACKETS_REGEX.test(
|
|
6676
|
+
value: function normalizePath(path2, resolveOptions) {
|
|
6677
|
+
if (!BINDING_BRACKETS_REGEX.test(path2) && LAZY_BINDING_REGEX.test(path2) && this.hooks.skipOptimization.call(path2) !== true) {
|
|
3069
6678
|
return {
|
|
3070
|
-
path:
|
|
6679
|
+
path: path2.split("."),
|
|
3071
6680
|
updates: void 0
|
|
3072
6681
|
};
|
|
3073
6682
|
}
|
|
3074
|
-
var
|
|
3075
|
-
var ast = (
|
|
3076
|
-
this.parseCache[
|
|
6683
|
+
var _this_parseCache_path2;
|
|
6684
|
+
var ast = (_this_parseCache_path2 = this.parseCache[path2]) !== null && _this_parseCache_path2 !== void 0 ? _this_parseCache_path2 : parse(path2);
|
|
6685
|
+
this.parseCache[path2] = ast;
|
|
3077
6686
|
if (typeof ast !== "object" || !(ast === null || ast === void 0 ? void 0 : ast.status)) {
|
|
3078
6687
|
var _ast_error;
|
|
3079
|
-
throw new TypeError('Cannot normalize path "'.concat(
|
|
6688
|
+
throw new TypeError('Cannot normalize path "'.concat(path2, '": ').concat((_ast_error = ast === null || ast === void 0 ? void 0 : ast.error) !== null && _ast_error !== void 0 ? _ast_error : "Unknown Error."));
|
|
3080
6689
|
}
|
|
3081
6690
|
try {
|
|
3082
6691
|
return resolveBindingAST(ast.path, resolveOptions, this.hooks);
|
|
3083
6692
|
} catch (e) {
|
|
3084
|
-
throw new import_ts_nested_error.NestedError("Cannot resolve binding: ".concat(
|
|
6693
|
+
throw new import_ts_nested_error.NestedError("Cannot resolve binding: ".concat(path2), e);
|
|
3085
6694
|
}
|
|
3086
6695
|
}
|
|
3087
6696
|
},
|
|
@@ -3109,21 +6718,21 @@ var AsyncNodePlugin = function() {
|
|
|
3109
6718
|
var updates = {};
|
|
3110
6719
|
var joined = Array.isArray(rawBinding) ? rawBinding.join(".") : String(rawBinding);
|
|
3111
6720
|
var normalizeConfig = {
|
|
3112
|
-
getValue: function(
|
|
3113
|
-
var normalized2 = _this.normalizePath(
|
|
6721
|
+
getValue: function(path2) {
|
|
6722
|
+
var normalized2 = _this.normalizePath(path2.join("."), normalizeConfig);
|
|
3114
6723
|
return options.get(_this.getBindingForNormalizedResult(normalized2));
|
|
3115
6724
|
},
|
|
3116
6725
|
evaluate: function(exp) {
|
|
3117
6726
|
return options.evaluate(exp);
|
|
3118
6727
|
},
|
|
3119
|
-
convertToPath: function(
|
|
3120
|
-
if (
|
|
6728
|
+
convertToPath: function(path2) {
|
|
6729
|
+
if (path2 === void 0) {
|
|
3121
6730
|
throw new Error("Attempted to convert undefined value to binding path");
|
|
3122
6731
|
}
|
|
3123
|
-
if (typeof
|
|
3124
|
-
throw new Error("Attempting to convert ".concat(typeof
|
|
6732
|
+
if (typeof path2 !== "string" && typeof path2 !== "number" && typeof path2 !== "boolean") {
|
|
6733
|
+
throw new Error("Attempting to convert ".concat(typeof path2 === "undefined" ? "undefined" : _type_of(path2), " to a binding path."));
|
|
3125
6734
|
}
|
|
3126
|
-
var normalized2 = _this.normalizePath(String(
|
|
6735
|
+
var normalized2 = _this.normalizePath(String(path2), normalizeConfig);
|
|
3127
6736
|
if (normalized2.updates) {
|
|
3128
6737
|
updates = _object_spread({}, updates, normalized2.updates);
|
|
3129
6738
|
}
|
|
@@ -4024,7 +7633,7 @@ var AsyncNodePlugin = function() {
|
|
|
4024
7633
|
this.hooks = {
|
|
4025
7634
|
resolveTypeForBinding: new SyncWaterfallHook()
|
|
4026
7635
|
};
|
|
4027
|
-
this.schema = schema ?
|
|
7636
|
+
this.schema = schema ? parse4(schema) : /* @__PURE__ */ new Map();
|
|
4028
7637
|
}
|
|
4029
7638
|
_create_class(SchemaController, [
|
|
4030
7639
|
{
|
|
@@ -4415,7 +8024,7 @@ var AsyncNodePlugin = function() {
|
|
|
4415
8024
|
}
|
|
4416
8025
|
}
|
|
4417
8026
|
var parseLocalObject = function(currentValue, objToParse) {
|
|
4418
|
-
var
|
|
8027
|
+
var path2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
4419
8028
|
if (typeof objToParse !== "object" || objToParse === null) {
|
|
4420
8029
|
return {
|
|
4421
8030
|
value: objToParse,
|
|
@@ -4452,7 +8061,7 @@ var AsyncNodePlugin = function() {
|
|
|
4452
8061
|
return _object_spread_props(_object_spread({}, rest), {
|
|
4453
8062
|
children: _to_consumable_array(children2).concat([
|
|
4454
8063
|
{
|
|
4455
|
-
path: _to_consumable_array(
|
|
8064
|
+
path: _to_consumable_array(path2).concat([
|
|
4456
8065
|
"asset"
|
|
4457
8066
|
]),
|
|
4458
8067
|
value: assetAST
|
|
@@ -4477,7 +8086,7 @@ var AsyncNodePlugin = function() {
|
|
|
4477
8086
|
}
|
|
4478
8087
|
if (templateAST) {
|
|
4479
8088
|
return {
|
|
4480
|
-
path: _to_consumable_array(
|
|
8089
|
+
path: _to_consumable_array(path2).concat([
|
|
4481
8090
|
template.output
|
|
4482
8091
|
]),
|
|
4483
8092
|
value: templateAST
|
|
@@ -4498,7 +8107,7 @@ var AsyncNodePlugin = function() {
|
|
|
4498
8107
|
return _object_spread_props(_object_spread({}, rest), {
|
|
4499
8108
|
children: _to_consumable_array(children2).concat([
|
|
4500
8109
|
{
|
|
4501
|
-
path: _to_consumable_array(
|
|
8110
|
+
path: _to_consumable_array(path2).concat([
|
|
4502
8111
|
localKey
|
|
4503
8112
|
], _to_consumable_array(firstChild.path)),
|
|
4504
8113
|
value: firstChild.value
|
|
@@ -4510,7 +8119,7 @@ var AsyncNodePlugin = function() {
|
|
|
4510
8119
|
return _object_spread_props(_object_spread({}, rest), {
|
|
4511
8120
|
children: _to_consumable_array(children2).concat([
|
|
4512
8121
|
{
|
|
4513
|
-
path: _to_consumable_array(
|
|
8122
|
+
path: _to_consumable_array(path2).concat([
|
|
4514
8123
|
localKey
|
|
4515
8124
|
]),
|
|
4516
8125
|
value: localSwitch
|
|
@@ -4522,7 +8131,7 @@ var AsyncNodePlugin = function() {
|
|
|
4522
8131
|
var localAsync = _this.parseAsync(localValue, "value", options);
|
|
4523
8132
|
if (localAsync) {
|
|
4524
8133
|
children2.push({
|
|
4525
|
-
path: _to_consumable_array(
|
|
8134
|
+
path: _to_consumable_array(path2).concat([
|
|
4526
8135
|
localKey
|
|
4527
8136
|
]),
|
|
4528
8137
|
value: localAsync
|
|
@@ -4549,7 +8158,7 @@ var AsyncNodePlugin = function() {
|
|
|
4549
8158
|
return _object_spread_props(_object_spread({}, rest), {
|
|
4550
8159
|
children: _to_consumable_array(children2).concat([
|
|
4551
8160
|
{
|
|
4552
|
-
path: _to_consumable_array(
|
|
8161
|
+
path: _to_consumable_array(path2).concat([
|
|
4553
8162
|
localKey
|
|
4554
8163
|
]),
|
|
4555
8164
|
value: multiNode
|
|
@@ -4566,7 +8175,7 @@ var AsyncNodePlugin = function() {
|
|
|
4566
8175
|
return _object_spread_props(_object_spread({}, rest), {
|
|
4567
8176
|
children: _to_consumable_array(children2).concat([
|
|
4568
8177
|
{
|
|
4569
|
-
path: _to_consumable_array(
|
|
8178
|
+
path: _to_consumable_array(path2).concat([
|
|
4570
8179
|
localKey
|
|
4571
8180
|
]),
|
|
4572
8181
|
value: parsedNode
|
|
@@ -4575,7 +8184,7 @@ var AsyncNodePlugin = function() {
|
|
|
4575
8184
|
});
|
|
4576
8185
|
}
|
|
4577
8186
|
} else {
|
|
4578
|
-
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(
|
|
8187
|
+
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path2).concat([
|
|
4579
8188
|
localKey
|
|
4580
8189
|
]));
|
|
4581
8190
|
return {
|
|
@@ -4584,7 +8193,7 @@ var AsyncNodePlugin = function() {
|
|
|
4584
8193
|
};
|
|
4585
8194
|
}
|
|
4586
8195
|
} else {
|
|
4587
|
-
var value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(
|
|
8196
|
+
var value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path2).concat([
|
|
4588
8197
|
localKey
|
|
4589
8198
|
]), localValue);
|
|
4590
8199
|
return {
|
|
@@ -4889,17 +8498,17 @@ var AsyncNodePlugin = function() {
|
|
|
4889
8498
|
return Resolver;
|
|
4890
8499
|
}();
|
|
4891
8500
|
var CrossfieldProvider = /*#__PURE__*/ function() {
|
|
4892
|
-
function CrossfieldProvider(initialView,
|
|
8501
|
+
function CrossfieldProvider(initialView, parser2, logger) {
|
|
4893
8502
|
_class_call_check(this, CrossfieldProvider);
|
|
4894
8503
|
this.allValidations = /* @__PURE__ */ new Set();
|
|
4895
8504
|
this.byBinding = /* @__PURE__ */ new Map();
|
|
4896
8505
|
this.logger = logger;
|
|
4897
|
-
this.parse(initialView,
|
|
8506
|
+
this.parse(initialView, parser2);
|
|
4898
8507
|
}
|
|
4899
8508
|
_create_class(CrossfieldProvider, [
|
|
4900
8509
|
{
|
|
4901
8510
|
key: "parse",
|
|
4902
|
-
value: function parse(contentView,
|
|
8511
|
+
value: function parse(contentView, parser2) {
|
|
4903
8512
|
var _this = this;
|
|
4904
8513
|
var xfieldRefs = contentView.validation;
|
|
4905
8514
|
if (xfieldRefs === void 0) {
|
|
@@ -4918,7 +8527,7 @@ var AsyncNodePlugin = function() {
|
|
|
4918
8527
|
_this.allValidations.add(withDefaults);
|
|
4919
8528
|
var ref = vRef.ref;
|
|
4920
8529
|
if (ref) {
|
|
4921
|
-
var parsed =
|
|
8530
|
+
var parsed = parser2(ref);
|
|
4922
8531
|
if (_this.byBinding.has(parsed)) {
|
|
4923
8532
|
var _this_byBinding_get;
|
|
4924
8533
|
(_this_byBinding_get = _this.byBinding.get(parsed)) === null || _this_byBinding_get === void 0 ? void 0 : _this_byBinding_get.push(withDefaults);
|
|
@@ -4979,11 +8588,11 @@ var AsyncNodePlugin = function() {
|
|
|
4979
8588
|
var _this_resolverOptions_logger;
|
|
4980
8589
|
(_this_resolverOptions_logger = this.resolverOptions.logger) === null || _this_resolverOptions_logger === void 0 ? void 0 : _this_resolverOptions_logger.warn("templatePlugin not set for View, legacy templates may not work");
|
|
4981
8590
|
}
|
|
4982
|
-
var
|
|
4983
|
-
this.hooks.parser.call(
|
|
4984
|
-
this.rootNode =
|
|
8591
|
+
var parser2 = new Parser();
|
|
8592
|
+
this.hooks.parser.call(parser2);
|
|
8593
|
+
this.rootNode = parser2.parseView(this.initialView);
|
|
4985
8594
|
this.resolver = new Resolver(this.rootNode, _object_spread_props(_object_spread({}, this.resolverOptions), {
|
|
4986
|
-
parseNode:
|
|
8595
|
+
parseNode: parser2.parseObject.bind(parser2)
|
|
4987
8596
|
}));
|
|
4988
8597
|
this.hooks.resolver.call(this.resolver);
|
|
4989
8598
|
}
|
|
@@ -5081,23 +8690,23 @@ var AsyncNodePlugin = function() {
|
|
|
5081
8690
|
},
|
|
5082
8691
|
{
|
|
5083
8692
|
key: "applyParser",
|
|
5084
|
-
value: function applyParser(
|
|
8693
|
+
value: function applyParser(parser2) {
|
|
5085
8694
|
var _this = this;
|
|
5086
|
-
|
|
8695
|
+
parser2.hooks.onCreateASTNode.tap("template", function(node) {
|
|
5087
8696
|
if (node && node.type === "template" && !node.dynamic) {
|
|
5088
|
-
return _this.parseTemplate(
|
|
8697
|
+
return _this.parseTemplate(parser2.parseObject.bind(parser2), node, _this.options);
|
|
5089
8698
|
}
|
|
5090
8699
|
return node;
|
|
5091
8700
|
});
|
|
5092
|
-
|
|
8701
|
+
parser2.hooks.determineNodeType.tap("template", function(obj) {
|
|
5093
8702
|
if (obj === "template") {
|
|
5094
8703
|
return "template";
|
|
5095
8704
|
}
|
|
5096
8705
|
});
|
|
5097
|
-
|
|
8706
|
+
parser2.hooks.parseNode.tap("template", function(obj, _nodeType, options, determinedNodeType) {
|
|
5098
8707
|
if (determinedNodeType === "template") {
|
|
5099
8708
|
var _options_templateDepth, _obj_dynamic;
|
|
5100
|
-
var templateNode =
|
|
8709
|
+
var templateNode = parser2.createASTNode({
|
|
5101
8710
|
type: "template",
|
|
5102
8711
|
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
5103
8712
|
data: obj.data,
|
|
@@ -5225,8 +8834,8 @@ var AsyncNodePlugin = function() {
|
|
|
5225
8834
|
]);
|
|
5226
8835
|
}
|
|
5227
8836
|
var nodePath = findBasePath(node, resolver);
|
|
5228
|
-
if (nodePath.length > 0 && nodePath.some(function(
|
|
5229
|
-
return propsToSkip.has(
|
|
8837
|
+
if (nodePath.length > 0 && nodePath.some(function(segment2) {
|
|
8838
|
+
return propsToSkip.has(segment2.toString());
|
|
5230
8839
|
})) {
|
|
5231
8840
|
return node.value;
|
|
5232
8841
|
}
|
|
@@ -5268,17 +8877,17 @@ var AsyncNodePlugin = function() {
|
|
|
5268
8877
|
},
|
|
5269
8878
|
{
|
|
5270
8879
|
key: "applyParser",
|
|
5271
|
-
value: function applyParser(
|
|
5272
|
-
|
|
8880
|
+
value: function applyParser(parser2) {
|
|
8881
|
+
parser2.hooks.determineNodeType.tap("applicability", function(obj) {
|
|
5273
8882
|
if (Object.prototype.hasOwnProperty.call(obj, "applicability")) {
|
|
5274
8883
|
return "applicability";
|
|
5275
8884
|
}
|
|
5276
8885
|
});
|
|
5277
|
-
|
|
8886
|
+
parser2.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
|
|
5278
8887
|
if (determinedNodeType === "applicability") {
|
|
5279
|
-
var parsedApplicability =
|
|
8888
|
+
var parsedApplicability = parser2.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
|
|
5280
8889
|
if (parsedApplicability !== null) {
|
|
5281
|
-
var applicabilityNode =
|
|
8890
|
+
var applicabilityNode = parser2.createASTNode({
|
|
5282
8891
|
type: "applicability",
|
|
5283
8892
|
expression: obj.applicability,
|
|
5284
8893
|
value: parsedApplicability
|
|
@@ -5339,20 +8948,20 @@ var AsyncNodePlugin = function() {
|
|
|
5339
8948
|
},
|
|
5340
8949
|
{
|
|
5341
8950
|
key: "applyParser",
|
|
5342
|
-
value: function applyParser(
|
|
8951
|
+
value: function applyParser(parser2) {
|
|
5343
8952
|
var _this = this;
|
|
5344
|
-
|
|
8953
|
+
parser2.hooks.onCreateASTNode.tap("switch", function(node) {
|
|
5345
8954
|
if (node && node.type === "switch" && !node.dynamic) {
|
|
5346
8955
|
return _this.resolveSwitch(node, _this.options);
|
|
5347
8956
|
}
|
|
5348
8957
|
return node;
|
|
5349
8958
|
});
|
|
5350
|
-
|
|
8959
|
+
parser2.hooks.determineNodeType.tap("switch", function(obj) {
|
|
5351
8960
|
if (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch")) {
|
|
5352
8961
|
return "switch";
|
|
5353
8962
|
}
|
|
5354
8963
|
});
|
|
5355
|
-
|
|
8964
|
+
parser2.hooks.parseNode.tap("switch", function(obj, _nodeType, options, determinedNodeType) {
|
|
5356
8965
|
if (determinedNodeType === "switch") {
|
|
5357
8966
|
var dynamic = "dynamicSwitch" in obj;
|
|
5358
8967
|
var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
|
|
@@ -5361,7 +8970,7 @@ var AsyncNodePlugin = function() {
|
|
|
5361
8970
|
var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
|
|
5362
8971
|
"case"
|
|
5363
8972
|
]);
|
|
5364
|
-
var value =
|
|
8973
|
+
var value = parser2.parseObject(switchBody, "value", options);
|
|
5365
8974
|
if (value) {
|
|
5366
8975
|
cases.push({
|
|
5367
8976
|
case: switchCaseExpr,
|
|
@@ -5369,7 +8978,7 @@ var AsyncNodePlugin = function() {
|
|
|
5369
8978
|
});
|
|
5370
8979
|
}
|
|
5371
8980
|
});
|
|
5372
|
-
var switchAST =
|
|
8981
|
+
var switchAST = parser2.hooks.onCreateASTNode.call({
|
|
5373
8982
|
type: "switch",
|
|
5374
8983
|
dynamic: dynamic,
|
|
5375
8984
|
cases: cases
|
|
@@ -6390,11 +9999,11 @@ var AsyncNodePlugin = function() {
|
|
|
6390
9999
|
},
|
|
6391
10000
|
{
|
|
6392
10001
|
key: "forView",
|
|
6393
|
-
value: function forView(
|
|
10002
|
+
value: function forView(parser2) {
|
|
6394
10003
|
var _this = this;
|
|
6395
10004
|
return {
|
|
6396
10005
|
_getValidationForBinding: function(binding) {
|
|
6397
|
-
return _this.getValidationForBinding(isBinding(binding) ? binding :
|
|
10006
|
+
return _this.getValidationForBinding(isBinding(binding) ? binding : parser2(binding));
|
|
6398
10007
|
},
|
|
6399
10008
|
getAll: function() {
|
|
6400
10009
|
var bindings = _this.getBindings();
|
|
@@ -6430,7 +10039,7 @@ var AsyncNodePlugin = function() {
|
|
|
6430
10039
|
throw new Error("Section functionality should be provided by the view plugin");
|
|
6431
10040
|
},
|
|
6432
10041
|
type: function(binding) {
|
|
6433
|
-
return _this.schema.getType(isBinding(binding) ? binding :
|
|
10042
|
+
return _this.schema.getType(isBinding(binding) ? binding : parser2(binding));
|
|
6434
10043
|
}
|
|
6435
10044
|
};
|
|
6436
10045
|
}
|
|
@@ -6930,11 +10539,11 @@ var AsyncNodePlugin = function() {
|
|
|
6930
10539
|
]);
|
|
6931
10540
|
return DataController;
|
|
6932
10541
|
}();
|
|
6933
|
-
function
|
|
10542
|
+
function flatten2(obj) {
|
|
6934
10543
|
var roots = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], sep = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
6935
10544
|
return Object.keys(obj).reduce(function(memo, prop) {
|
|
6936
10545
|
return _object_spread({}, memo, Object.prototype.toString.call(obj[prop]) === "[object Object]" ? // keep working if value is an object
|
|
6937
|
-
|
|
10546
|
+
flatten2(obj[prop], roots.concat([
|
|
6938
10547
|
prop
|
|
6939
10548
|
])) : _define_property({}, roots.concat([
|
|
6940
10549
|
prop
|
|
@@ -6963,9 +10572,9 @@ var AsyncNodePlugin = function() {
|
|
|
6963
10572
|
key: "getConstants",
|
|
6964
10573
|
value: function getConstants(key, namespace, fallback) {
|
|
6965
10574
|
var _this_tempStore_get, _this_store_get;
|
|
6966
|
-
var
|
|
10575
|
+
var path2 = new BindingInstance(key);
|
|
6967
10576
|
var _this_tempStore_get_get, _ref;
|
|
6968
|
-
return (_ref = (_this_tempStore_get_get = (_this_tempStore_get = this.tempStore.get(namespace)) === null || _this_tempStore_get === void 0 ? void 0 : _this_tempStore_get.get(
|
|
10577
|
+
return (_ref = (_this_tempStore_get_get = (_this_tempStore_get = this.tempStore.get(namespace)) === null || _this_tempStore_get === void 0 ? void 0 : _this_tempStore_get.get(path2)) !== null && _this_tempStore_get_get !== void 0 ? _this_tempStore_get_get : (_this_store_get = this.store.get(namespace)) === null || _this_store_get === void 0 ? void 0 : _this_store_get.get(path2)) !== null && _ref !== void 0 ? _ref : fallback;
|
|
6969
10578
|
}
|
|
6970
10579
|
},
|
|
6971
10580
|
{
|
|
@@ -7564,18 +11173,18 @@ var AsyncNodePlugin = function() {
|
|
|
7564
11173
|
},
|
|
7565
11174
|
{
|
|
7566
11175
|
key: "applyParser",
|
|
7567
|
-
value: function applyParser(
|
|
7568
|
-
|
|
11176
|
+
value: function applyParser(parser2) {
|
|
11177
|
+
parser2.hooks.determineNodeType.tap(this.name, function(obj) {
|
|
7569
11178
|
if (Object.prototype.hasOwnProperty.call(obj, "async")) {
|
|
7570
11179
|
return NodeType.Async;
|
|
7571
11180
|
}
|
|
7572
11181
|
});
|
|
7573
|
-
|
|
11182
|
+
parser2.hooks.parseNode.tap(this.name, function(obj, nodeType, options, determinedNodeType) {
|
|
7574
11183
|
if (determinedNodeType === NodeType.Async) {
|
|
7575
|
-
var parsedAsync =
|
|
11184
|
+
var parsedAsync = parser2.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
|
|
7576
11185
|
var parsedNodeId = getNodeID(parsedAsync);
|
|
7577
11186
|
if (parsedAsync !== null && parsedNodeId) {
|
|
7578
|
-
return
|
|
11187
|
+
return parser2.createASTNode({
|
|
7579
11188
|
id: parsedNodeId,
|
|
7580
11189
|
type: NodeType.Async,
|
|
7581
11190
|
value: parsedAsync
|
|
@@ -7690,6 +11299,14 @@ var AsyncNodePlugin = function() {
|
|
|
7690
11299
|
return __toCommonJS(src_exports);
|
|
7691
11300
|
}(); /*! Bundled license information:
|
|
7692
11301
|
|
|
11302
|
+
arr-flatten/index.js:
|
|
11303
|
+
(*!
|
|
11304
|
+
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
|
11305
|
+
*
|
|
11306
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
11307
|
+
* Released under the MIT License.
|
|
11308
|
+
*)
|
|
11309
|
+
|
|
7693
11310
|
timm/lib/timm.js:
|
|
7694
11311
|
(*!
|
|
7695
11312
|
* Timm
|