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