From 2969c3107ce2ada0958f0e30b7a105e875f89fc4 Mon Sep 17 00:00:00 2001 From: Niklas Kiefer Date: Fri, 28 Jul 2023 10:58:44 +0200 Subject: [PATCH] feat: update to form-js@1.1.0 --- src/main/resources/public/css/form-js.css | 17 +- .../resources/public/js/form-viewer.umd.js | 40843 ++++++++-------- 2 files changed, 19795 insertions(+), 21065 deletions(-) diff --git a/src/main/resources/public/css/form-js.css b/src/main/resources/public/css/form-js.css index 6768d0b..ca3bdf2 100644 --- a/src/main/resources/public/css/form-js.css +++ b/src/main/resources/public/css/form-js.css @@ -32,7 +32,7 @@ * Specify color variables in the following schema: * 1 - use specified layer * 2 - use layer one - * 3 - use fallback + * 3 - use fallback */ --color-background: var( --cds-field, @@ -160,6 +160,10 @@ position: relative; } +.fjs-container .fjs-layout-row:empty { + display: none; +} + .fjs-container .fjs-column { flex-grow: 1; } @@ -350,6 +354,13 @@ margin: auto; } +.fjs-container .fjs-form-field-spacer { + background-color: transparent; + display: flex; + align-items: center; + justify-content: center; +} + .fjs-container .fjs-input[type=text], .fjs-container .fjs-input[type=email], .fjs-container .fjs-input[type=tel], @@ -689,6 +700,10 @@ list-style-type: none; } +.fjs-container .fjs-form-field-text { + overflow-wrap: break-word; +} + .fjs-container .fjs-form-field-text a { color: var(--color-accent); } diff --git a/src/main/resources/public/js/form-viewer.umd.js b/src/main/resources/public/js/form-viewer.umd.js index 1133039..93526f6 100644 --- a/src/main/resources/public/js/form-viewer.umd.js +++ b/src/main/resources/public/js/form-viewer.umd.js @@ -174,7 +174,7 @@ * * @return {Array} */ - function flatten$3(arr) { + function flatten$2(arr) { return Array.prototype.concat.apply([], arr); } @@ -193,7 +193,7 @@ return obj == null; } - function isArray$3(obj) { + function isArray$2(obj) { return nativeToString.call(obj) === '[object Array]'; } @@ -201,7 +201,7 @@ return nativeToString.call(obj) === '[object Object]'; } - function isNumber$3(obj) { + function isNumber$2(obj) { return nativeToString.call(obj) === '[object Number]'; } @@ -217,7 +217,7 @@ ); } - function isString$3(obj) { + function isString$2(obj) { return nativeToString.call(obj) === '[object String]'; } @@ -246,7 +246,7 @@ matcher = toMatcher(matcher); - let idx = isArray$3(collection) ? -1 : undefined; + let idx = isArray$2(collection) ? -1 : undefined; forEach(collection, function(val, key) { if (matcher(val, key)) { @@ -278,7 +278,7 @@ return; } - const convertKey = isArray$3(collection) ? toNum : identity; + const convertKey = isArray$2(collection) ? toNum : identity; for (let key in collection) { @@ -295,6 +295,27 @@ } + /** + * Transform a collection into another collection + * by piping each member through the given fn. + * + * @param {Object|Array} collection + * @param {Function} fn + * + * @return {Array} transformed collection + */ + function map(collection, fn) { + + let result = []; + + forEach(collection, function(val, key) { + result.push(fn(val, key)); + }); + + return result; + } + + /** * Group collection members by attribute. * @@ -323,6 +344,22 @@ } + function uniqueBy(extractor, ...collections) { + + extractor = toExtractor(extractor); + + let grouped = {}; + + forEach(collections, (c) => groupBy(c, extractor, grouped)); + + let result = map(grouped, function(val, key) { + return val[0]; + }); + + return result; + } + + function toExtractor(extractor) { return isFunction(extractor) ? extractor : (e) => { return e[extractor]; @@ -444,6 +481,1031 @@ return isUndefined$1(currentTarget) ? defaultValue : currentTarget; } + /* + * big.js v6.2.1 + * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic. + * Copyright (c) 2022 Michael Mclaughlin + * https://github.com/MikeMcl/big.js/LICENCE.md + */ + + + /************************************** EDITABLE DEFAULTS *****************************************/ + + + // The default values below must be integers within the stated ranges. + + /* + * The maximum number of decimal places (DP) of the results of operations involving division: + * div and sqrt, and pow with negative exponents. + */ + var DP = 20, // 0 to MAX_DP + + /* + * The rounding mode (RM) used when rounding to the above decimal places. + * + * 0 Towards zero (i.e. truncate, no rounding). (ROUND_DOWN) + * 1 To nearest neighbour. If equidistant, round up. (ROUND_HALF_UP) + * 2 To nearest neighbour. If equidistant, to even. (ROUND_HALF_EVEN) + * 3 Away from zero. (ROUND_UP) + */ + RM = 1, // 0, 1, 2 or 3 + + // The maximum value of DP and Big.DP. + MAX_DP = 1E6, // 0 to 1000000 + + // The maximum magnitude of the exponent argument to the pow method. + MAX_POWER = 1E6, // 1 to 1000000 + + /* + * The negative exponent (NE) at and beneath which toString returns exponential notation. + * (JavaScript numbers: -7) + * -1000000 is the minimum recommended exponent value of a Big. + */ + NE = -7, // 0 to -1000000 + + /* + * The positive exponent (PE) at and above which toString returns exponential notation. + * (JavaScript numbers: 21) + * 1000000 is the maximum recommended exponent value of a Big, but this limit is not enforced. + */ + PE = 21, // 0 to 1000000 + + /* + * When true, an error will be thrown if a primitive number is passed to the Big constructor, + * or if valueOf is called, or if toNumber is called on a Big which cannot be converted to a + * primitive number without a loss of precision. + */ + STRICT = false, // true or false + + + /**************************************************************************************************/ + + + // Error messages. + NAME = '[big.js] ', + INVALID$3 = NAME + 'Invalid ', + INVALID_DP = INVALID$3 + 'decimal places', + INVALID_RM = INVALID$3 + 'rounding mode', + DIV_BY_ZERO = NAME + 'Division by zero', + + // The shared prototype object. + P$2 = {}, + UNDEFINED = void 0, + NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i; + + + /* + * Create and return a Big constructor. + */ + function _Big_() { + + /* + * The Big constructor and exported function. + * Create and return a new instance of a Big number object. + * + * n {number|string|Big} A numeric value. + */ + function Big(n) { + var x = this; + + // Enable constructor usage without new. + if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n); + + // Duplicate. + if (n instanceof Big) { + x.s = n.s; + x.e = n.e; + x.c = n.c.slice(); + } else { + if (typeof n !== 'string') { + if (Big.strict === true && typeof n !== 'bigint') { + throw TypeError(INVALID$3 + 'value'); + } + + // Minus zero? + n = n === 0 && 1 / n < 0 ? '-0' : String(n); + } + + parse$1(x, n); + } + + // Retain a reference to this Big constructor. + // Shadow Big.prototype.constructor which points to Object. + x.constructor = Big; + } + + Big.prototype = P$2; + Big.DP = DP; + Big.RM = RM; + Big.NE = NE; + Big.PE = PE; + Big.strict = STRICT; + Big.roundDown = 0; + Big.roundHalfUp = 1; + Big.roundHalfEven = 2; + Big.roundUp = 3; + + return Big; + } + + + /* + * Parse the number or string value passed to a Big constructor. + * + * x {Big} A Big number instance. + * n {number|string} A numeric value. + */ + function parse$1(x, n) { + var e, i, nl; + + if (!NUMERIC.test(n)) { + throw Error(INVALID$3 + 'number'); + } + + // Determine sign. + x.s = n.charAt(0) == '-' ? (n = n.slice(1), -1) : 1; + + // Decimal point? + if ((e = n.indexOf('.')) > -1) n = n.replace('.', ''); + + // Exponential form? + if ((i = n.search(/e/i)) > 0) { + + // Determine exponent. + if (e < 0) e = i; + e += +n.slice(i + 1); + n = n.substring(0, i); + } else if (e < 0) { + + // Integer. + e = n.length; + } + + nl = n.length; + + // Determine leading zeros. + for (i = 0; i < nl && n.charAt(i) == '0';) ++i; + + if (i == nl) { + + // Zero. + x.c = [x.e = 0]; + } else { + + // Determine trailing zeros. + for (; nl > 0 && n.charAt(--nl) == '0';); + x.e = e - i - 1; + x.c = []; + + // Convert string to array of digits without leading/trailing zeros. + for (e = 0; i <= nl;) x.c[e++] = +n.charAt(i++); + } + + return x; + } + + + /* + * Round Big x to a maximum of sd significant digits using rounding mode rm. + * + * x {Big} The Big to round. + * sd {number} Significant digits: integer, 0 to MAX_DP inclusive. + * rm {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * [more] {boolean} Whether the result of division was truncated. + */ + function round$1(x, sd, rm, more) { + var xc = x.c; + + if (rm === UNDEFINED) rm = x.constructor.RM; + if (rm !== 0 && rm !== 1 && rm !== 2 && rm !== 3) { + throw Error(INVALID_RM); + } + + if (sd < 1) { + more = + rm === 3 && (more || !!xc[0]) || sd === 0 && ( + rm === 1 && xc[0] >= 5 || + rm === 2 && (xc[0] > 5 || xc[0] === 5 && (more || xc[1] !== UNDEFINED)) + ); + + xc.length = 1; + + if (more) { + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + x.e = x.e - sd + 1; + xc[0] = 1; + } else { + + // Zero. + xc[0] = x.e = 0; + } + } else if (sd < xc.length) { + + // xc[sd] is the digit after the digit that may be rounded up. + more = + rm === 1 && xc[sd] >= 5 || + rm === 2 && (xc[sd] > 5 || xc[sd] === 5 && + (more || xc[sd + 1] !== UNDEFINED || xc[sd - 1] & 1)) || + rm === 3 && (more || !!xc[0]); + + // Remove any digits after the required precision. + xc.length = sd; + + // Round up? + if (more) { + + // Rounding up may mean the previous digit has to be rounded up. + for (; ++xc[--sd] > 9;) { + xc[sd] = 0; + if (sd === 0) { + ++x.e; + xc.unshift(1); + break; + } + } + } + + // Remove trailing zeros. + for (sd = xc.length; !xc[--sd];) xc.pop(); + } + + return x; + } + + + /* + * Return a string representing the value of Big x in normal or exponential notation. + * Handles P.toExponential, P.toFixed, P.toJSON, P.toPrecision, P.toString and P.valueOf. + */ + function stringify(x, doExponential, isNonzero) { + var e = x.e, + s = x.c.join(''), + n = s.length; + + // Exponential notation? + if (doExponential) { + s = s.charAt(0) + (n > 1 ? '.' + s.slice(1) : '') + (e < 0 ? 'e' : 'e+') + e; + + // Normal notation. + } else if (e < 0) { + for (; ++e;) s = '0' + s; + s = '0.' + s; + } else if (e > 0) { + if (++e > n) { + for (e -= n; e--;) s += '0'; + } else if (e < n) { + s = s.slice(0, e) + '.' + s.slice(e); + } + } else if (n > 1) { + s = s.charAt(0) + '.' + s.slice(1); + } + + return x.s < 0 && isNonzero ? '-' + s : s; + } + + + // Prototype/instance methods + + + /* + * Return a new Big whose value is the absolute value of this Big. + */ + P$2.abs = function () { + var x = new this.constructor(this); + x.s = 1; + return x; + }; + + + /* + * Return 1 if the value of this Big is greater than the value of Big y, + * -1 if the value of this Big is less than the value of Big y, or + * 0 if they have the same value. + */ + P$2.cmp = function (y) { + var isneg, + x = this, + xc = x.c, + yc = (y = new x.constructor(y)).c, + i = x.s, + j = y.s, + k = x.e, + l = y.e; + + // Either zero? + if (!xc[0] || !yc[0]) return !xc[0] ? !yc[0] ? 0 : -j : i; + + // Signs differ? + if (i != j) return i; + + isneg = i < 0; + + // Compare exponents. + if (k != l) return k > l ^ isneg ? 1 : -1; + + j = (k = xc.length) < (l = yc.length) ? k : l; + + // Compare digit by digit. + for (i = -1; ++i < j;) { + if (xc[i] != yc[i]) return xc[i] > yc[i] ^ isneg ? 1 : -1; + } + + // Compare lengths. + return k == l ? 0 : k > l ^ isneg ? 1 : -1; + }; + + + /* + * Return a new Big whose value is the value of this Big divided by the value of Big y, rounded, + * if necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. + */ + P$2.div = function (y) { + var x = this, + Big = x.constructor, + a = x.c, // dividend + b = (y = new Big(y)).c, // divisor + k = x.s == y.s ? 1 : -1, + dp = Big.DP; + + if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { + throw Error(INVALID_DP); + } + + // Divisor is zero? + if (!b[0]) { + throw Error(DIV_BY_ZERO); + } + + // Dividend is 0? Return +-0. + if (!a[0]) { + y.s = k; + y.c = [y.e = 0]; + return y; + } + + var bl, bt, n, cmp, ri, + bz = b.slice(), + ai = bl = b.length, + al = a.length, + r = a.slice(0, bl), // remainder + rl = r.length, + q = y, // quotient + qc = q.c = [], + qi = 0, + p = dp + (q.e = x.e - y.e) + 1; // precision of the result + + q.s = k; + k = p < 0 ? 0 : p; + + // Create version of divisor with leading zero. + bz.unshift(0); + + // Add zeros to make remainder as long as divisor. + for (; rl++ < bl;) r.push(0); + + do { + + // n is how many times the divisor goes into current remainder. + for (n = 0; n < 10; n++) { + + // Compare divisor and remainder. + if (bl != (rl = r.length)) { + cmp = bl > rl ? 1 : -1; + } else { + for (ri = -1, cmp = 0; ++ri < bl;) { + if (b[ri] != r[ri]) { + cmp = b[ri] > r[ri] ? 1 : -1; + break; + } + } + } + + // If divisor < remainder, subtract divisor from remainder. + if (cmp < 0) { + + // Remainder can't be more than 1 digit longer than divisor. + // Equalise lengths using divisor with extra leading zero? + for (bt = rl == bl ? b : bz; rl;) { + if (r[--rl] < bt[rl]) { + ri = rl; + for (; ri && !r[--ri];) r[ri] = 9; + --r[ri]; + r[rl] += 10; + } + r[rl] -= bt[rl]; + } + + for (; !r[0];) r.shift(); + } else { + break; + } + } + + // Add the digit n to the result array. + qc[qi++] = cmp ? n : ++n; + + // Update the remainder. + if (r[0] && cmp) r[rl] = a[ai] || 0; + else r = [a[ai]]; + + } while ((ai++ < al || r[0] !== UNDEFINED) && k--); + + // Leading zero? Do not remove if result is simply zero (qi == 1). + if (!qc[0] && qi != 1) { + + // There can't be more than one zero. + qc.shift(); + q.e--; + p--; + } + + // Round? + if (qi > p) round$1(q, p, Big.RM, r[0] !== UNDEFINED); + + return q; + }; + + + /* + * Return true if the value of this Big is equal to the value of Big y, otherwise return false. + */ + P$2.eq = function (y) { + return this.cmp(y) === 0; + }; + + + /* + * Return true if the value of this Big is greater than the value of Big y, otherwise return + * false. + */ + P$2.gt = function (y) { + return this.cmp(y) > 0; + }; + + + /* + * Return true if the value of this Big is greater than or equal to the value of Big y, otherwise + * return false. + */ + P$2.gte = function (y) { + return this.cmp(y) > -1; + }; + + + /* + * Return true if the value of this Big is less than the value of Big y, otherwise return false. + */ + P$2.lt = function (y) { + return this.cmp(y) < 0; + }; + + + /* + * Return true if the value of this Big is less than or equal to the value of Big y, otherwise + * return false. + */ + P$2.lte = function (y) { + return this.cmp(y) < 1; + }; + + + /* + * Return a new Big whose value is the value of this Big minus the value of Big y. + */ + P$2.minus = P$2.sub = function (y) { + var i, j, t, xlty, + x = this, + Big = x.constructor, + a = x.s, + b = (y = new Big(y)).s; + + // Signs differ? + if (a != b) { + y.s = -b; + return x.plus(y); + } + + var xc = x.c.slice(), + xe = x.e, + yc = y.c, + ye = y.e; + + // Either zero? + if (!xc[0] || !yc[0]) { + if (yc[0]) { + y.s = -b; + } else if (xc[0]) { + y = new Big(x); + } else { + y.s = 1; + } + return y; + } + + // Determine which is the bigger number. Prepend zeros to equalise exponents. + if (a = xe - ye) { + + if (xlty = a < 0) { + a = -a; + t = xc; + } else { + ye = xe; + t = yc; + } + + t.reverse(); + for (b = a; b--;) t.push(0); + t.reverse(); + } else { + + // Exponents equal. Check digit by digit. + j = ((xlty = xc.length < yc.length) ? xc : yc).length; + + for (a = b = 0; b < j; b++) { + if (xc[b] != yc[b]) { + xlty = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xlty) { + t = xc; + xc = yc; + yc = t; + y.s = -y.s; + } + + /* + * Append zeros to xc if shorter. No need to add zeros to yc if shorter as subtraction only + * needs to start at yc.length. + */ + if ((b = (j = yc.length) - (i = xc.length)) > 0) for (; b--;) xc[i++] = 0; + + // Subtract yc from xc. + for (b = i; j > a;) { + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i];) xc[i] = 9; + --xc[i]; + xc[j] += 10; + } + + xc[j] -= yc[j]; + } + + // Remove trailing zeros. + for (; xc[--b] === 0;) xc.pop(); + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] === 0;) { + xc.shift(); + --ye; + } + + if (!xc[0]) { + + // n - n = +0 + y.s = 1; + + // Result must be zero. + xc = [ye = 0]; + } + + y.c = xc; + y.e = ye; + + return y; + }; + + + /* + * Return a new Big whose value is the value of this Big modulo the value of Big y. + */ + P$2.mod = function (y) { + var ygtx, + x = this, + Big = x.constructor, + a = x.s, + b = (y = new Big(y)).s; + + if (!y.c[0]) { + throw Error(DIV_BY_ZERO); + } + + x.s = y.s = 1; + ygtx = y.cmp(x) == 1; + x.s = a; + y.s = b; + + if (ygtx) return new Big(x); + + a = Big.DP; + b = Big.RM; + Big.DP = Big.RM = 0; + x = x.div(y); + Big.DP = a; + Big.RM = b; + + return this.minus(x.times(y)); + }; + + + /* + * Return a new Big whose value is the value of this Big negated. + */ + P$2.neg = function () { + var x = new this.constructor(this); + x.s = -x.s; + return x; + }; + + + /* + * Return a new Big whose value is the value of this Big plus the value of Big y. + */ + P$2.plus = P$2.add = function (y) { + var e, k, t, + x = this, + Big = x.constructor; + + y = new Big(y); + + // Signs differ? + if (x.s != y.s) { + y.s = -y.s; + return x.minus(y); + } + + var xe = x.e, + xc = x.c, + ye = y.e, + yc = y.c; + + // Either zero? + if (!xc[0] || !yc[0]) { + if (!yc[0]) { + if (xc[0]) { + y = new Big(x); + } else { + y.s = x.s; + } + } + return y; + } + + xc = xc.slice(); + + // Prepend zeros to equalise exponents. + // Note: reverse faster than unshifts. + if (e = xe - ye) { + if (e > 0) { + ye = xe; + t = yc; + } else { + e = -e; + t = xc; + } + + t.reverse(); + for (; e--;) t.push(0); + t.reverse(); + } + + // Point xc to the longer array. + if (xc.length - yc.length < 0) { + t = yc; + yc = xc; + xc = t; + } + + e = yc.length; + + // Only start adding at yc.length - 1 as the further digits of xc can be left as they are. + for (k = 0; e; xc[e] %= 10) k = (xc[--e] = xc[e] + yc[e] + k) / 10 | 0; + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + + if (k) { + xc.unshift(k); + ++ye; + } + + // Remove trailing zeros. + for (e = xc.length; xc[--e] === 0;) xc.pop(); + + y.c = xc; + y.e = ye; + + return y; + }; + + + /* + * Return a Big whose value is the value of this Big raised to the power n. + * If n is negative, round to a maximum of Big.DP decimal places using rounding + * mode Big.RM. + * + * n {number} Integer, -MAX_POWER to MAX_POWER inclusive. + */ + P$2.pow = function (n) { + var x = this, + one = new x.constructor('1'), + y = one, + isneg = n < 0; + + if (n !== ~~n || n < -MAX_POWER || n > MAX_POWER) { + throw Error(INVALID$3 + 'exponent'); + } + + if (isneg) n = -n; + + for (;;) { + if (n & 1) y = y.times(x); + n >>= 1; + if (!n) break; + x = x.times(x); + } + + return isneg ? one.div(y) : y; + }; + + + /* + * Return a new Big whose value is the value of this Big rounded to a maximum precision of sd + * significant digits using rounding mode rm, or Big.RM if rm is not specified. + * + * sd {number} Significant digits: integer, 1 to MAX_DP inclusive. + * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + */ + P$2.prec = function (sd, rm) { + if (sd !== ~~sd || sd < 1 || sd > MAX_DP) { + throw Error(INVALID$3 + 'precision'); + } + return round$1(new this.constructor(this), sd, rm); + }; + + + /* + * Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal places + * using rounding mode rm, or Big.RM if rm is not specified. + * If dp is negative, round to an integer which is a multiple of 10**-dp. + * If dp is not specified, round to 0 decimal places. + * + * dp? {number} Integer, -MAX_DP to MAX_DP inclusive. + * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + */ + P$2.round = function (dp, rm) { + if (dp === UNDEFINED) dp = 0; + else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) { + throw Error(INVALID_DP); + } + return round$1(new this.constructor(this), dp + this.e + 1, rm); + }; + + + /* + * Return a new Big whose value is the square root of the value of this Big, rounded, if + * necessary, to a maximum of Big.DP decimal places using rounding mode Big.RM. + */ + P$2.sqrt = function () { + var r, c, t, + x = this, + Big = x.constructor, + s = x.s, + e = x.e, + half = new Big('0.5'); + + // Zero? + if (!x.c[0]) return new Big(x); + + // Negative? + if (s < 0) { + throw Error(NAME + 'No square root'); + } + + // Estimate. + s = Math.sqrt(x + ''); + + // Math.sqrt underflow/overflow? + // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent. + if (s === 0 || s === 1 / 0) { + c = x.c.join(''); + if (!(c.length + e & 1)) c += '0'; + s = Math.sqrt(c); + e = ((e + 1) / 2 | 0) - (e < 0 || e & 1); + r = new Big((s == 1 / 0 ? '5e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e); + } else { + r = new Big(s + ''); + } + + e = r.e + (Big.DP += 4); + + // Newton-Raphson iteration. + do { + t = r; + r = half.times(t.plus(x.div(t))); + } while (t.c.slice(0, e).join('') !== r.c.slice(0, e).join('')); + + return round$1(r, (Big.DP -= 4) + r.e + 1, Big.RM); + }; + + + /* + * Return a new Big whose value is the value of this Big times the value of Big y. + */ + P$2.times = P$2.mul = function (y) { + var c, + x = this, + Big = x.constructor, + xc = x.c, + yc = (y = new Big(y)).c, + a = xc.length, + b = yc.length, + i = x.e, + j = y.e; + + // Determine sign of result. + y.s = x.s == y.s ? 1 : -1; + + // Return signed 0 if either 0. + if (!xc[0] || !yc[0]) { + y.c = [y.e = 0]; + return y; + } + + // Initialise exponent of result as x.e + y.e. + y.e = i + j; + + // If array xc has fewer digits than yc, swap xc and yc, and lengths. + if (a < b) { + c = xc; + xc = yc; + yc = c; + j = a; + a = b; + b = j; + } + + // Initialise coefficient array of result with zeros. + for (c = new Array(j = a + b); j--;) c[j] = 0; + + // Multiply. + + // i is initially xc.length. + for (i = b; i--;) { + b = 0; + + // a is yc.length. + for (j = a + i; j > i;) { + + // Current sum of products at this digit position, plus carry. + b = c[j] + yc[i] * xc[j - i - 1] + b; + c[j--] = b % 10; + + // carry + b = b / 10 | 0; + } + + c[j] = b; + } + + // Increment result exponent if there is a final carry, otherwise remove leading zero. + if (b) ++y.e; + else c.shift(); + + // Remove trailing zeros. + for (i = c.length; !c[--i];) c.pop(); + y.c = c; + + return y; + }; + + + /* + * Return a string representing the value of this Big in exponential notation rounded to dp fixed + * decimal places using rounding mode rm, or Big.RM if rm is not specified. + * + * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive. + * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + */ + P$2.toExponential = function (dp, rm) { + var x = this, + n = x.c[0]; + + if (dp !== UNDEFINED) { + if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { + throw Error(INVALID_DP); + } + x = round$1(new x.constructor(x), ++dp, rm); + for (; x.c.length < dp;) x.c.push(0); + } + + return stringify(x, true, !!n); + }; + + + /* + * Return a string representing the value of this Big in normal notation rounded to dp fixed + * decimal places using rounding mode rm, or Big.RM if rm is not specified. + * + * dp? {number} Decimal places: integer, 0 to MAX_DP inclusive. + * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * + * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. + * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. + */ + P$2.toFixed = function (dp, rm) { + var x = this, + n = x.c[0]; + + if (dp !== UNDEFINED) { + if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { + throw Error(INVALID_DP); + } + x = round$1(new x.constructor(x), dp + x.e + 1, rm); + + // x.e may have changed if the value is rounded up. + for (dp = dp + x.e + 1; x.c.length < dp;) x.c.push(0); + } + + return stringify(x, false, !!n); + }; + + + /* + * Return a string representing the value of this Big. + * Return exponential notation if this Big has a positive exponent equal to or greater than + * Big.PE, or a negative exponent equal to or less than Big.NE. + * Omit the sign for negative zero. + */ + P$2[Symbol.for('nodejs.util.inspect.custom')] = P$2.toJSON = P$2.toString = function () { + var x = this, + Big = x.constructor; + return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]); + }; + + + /* + * Return the value of this Big as a primitve number. + */ + P$2.toNumber = function () { + var n = Number(stringify(this, true, true)); + if (this.constructor.strict === true && !this.eq(n.toString())) { + throw Error(NAME + 'Imprecise conversion'); + } + return n; + }; + + + /* + * Return a string representing the value of this Big rounded to sd significant digits using + * rounding mode rm, or Big.RM if rm is not specified. + * Use exponential notation if sd is less than the number of digits necessary to represent + * the integer part of the value in normal notation. + * + * sd {number} Significant digits: integer, 1 to MAX_DP inclusive. + * rm? {number} Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + */ + P$2.toPrecision = function (sd, rm) { + var x = this, + Big = x.constructor, + n = x.c[0]; + + if (sd !== UNDEFINED) { + if (sd !== ~~sd || sd < 1 || sd > MAX_DP) { + throw Error(INVALID$3 + 'precision'); + } + x = round$1(new Big(x), sd, rm); + for (; x.c.length < sd;) x.c.push(0); + } + + return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE, !!n); + }; + + + /* + * Return a string representing the value of this Big. + * Return exponential notation if this Big has a positive exponent equal to or greater than + * Big.PE, or a negative exponent equal to or less than Big.NE. + * Include the sign for negative zero. + */ + P$2.valueOf = function () { + var x = this, + Big = x.constructor; + if (Big.strict === true) { + throw Error(NAME + 'valueOf disallowed'); + } + return stringify(x, x.e <= Big.NE || x.e >= Big.PE, true); + }; + + + // Export + + + var Big = _Big_(); + // these aren't really private, but nor are they really useful to document /** @@ -1643,13 +2705,13 @@ return defaultZone; } else if (input instanceof Zone) { return input; - } else if (isString$2(input)) { + } else if (isString$1(input)) { const lowered = input.toLowerCase(); if (lowered === "default") return defaultZone; else if (lowered === "local" || lowered === "system") return SystemZone.instance; else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance; else return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input); - } else if (isNumber$2(input)) { + } else if (isNumber$1(input)) { return FixedOffsetZone.instance(input); } else if (typeof input === "object" && input.offset && typeof input.offset === "number") { // This is dumb, but the instanceof check above doesn't seem to really work @@ -1819,7 +2881,7 @@ return typeof o === "undefined"; } - function isNumber$2(o) { + function isNumber$1(o) { return typeof o === "number"; } @@ -1827,7 +2889,7 @@ return typeof o === "number" && o % 1 === 0; } - function isString$2(o) { + function isString$1(o) { return typeof o === "string"; } @@ -2670,7 +3732,7 @@ .slice(0, 2); } - function parse$1(s, ...patterns) { + function parse(s, ...patterns) { if (s == null) { return [null, null]; } @@ -2915,7 +3977,7 @@ */ function parseISODate(s) { - return parse$1( + return parse( s, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], @@ -2925,11 +3987,11 @@ } function parseRFC2822Date(s) { - return parse$1(preprocessRFC2822(s), [rfc2822, extractRFC2822]); + return parse(preprocessRFC2822(s), [rfc2822, extractRFC2822]); } function parseHTTPDate(s) { - return parse$1( + return parse( s, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], @@ -2938,13 +4000,13 @@ } function parseISODuration(s) { - return parse$1(s, [isoDuration, extractISODuration]); + return parse(s, [isoDuration, extractISODuration]); } const extractISOTimeOnly = combineExtractors(extractISOTime); function parseISOTimeOnly(s) { - return parse$1(s, [isoTimeOnly, extractISOTimeOnly]); + return parse(s, [isoTimeOnly, extractISOTimeOnly]); } const sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex); @@ -2957,14 +4019,14 @@ ); function parseSQL(s) { - return parse$1( + return parse( s, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone] ); } - const INVALID$3 = "Invalid Duration"; + const INVALID$2 = "Invalid Duration"; // unit conversion constants const lowOrderMatrix = { @@ -3229,7 +4291,7 @@ * @return {Duration} */ static fromDurationLike(durationLike) { - if (isNumber$2(durationLike)) { + if (isNumber$1(durationLike)) { return Duration.fromMillis(durationLike); } else if (Duration.isDuration(durationLike)) { return durationLike; @@ -3396,7 +4458,7 @@ }; return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) - : INVALID$3; + : INVALID$2; } /** @@ -3706,7 +4768,7 @@ } // plus anything that's already in this unit - if (isNumber$2(vals[k])) { + if (isNumber$1(vals[k])) { own += vals[k]; } @@ -3721,7 +4783,7 @@ } } // otherwise, keep it in the wings to boil it later - } else if (isNumber$2(vals[k])) { + } else if (isNumber$1(vals[k])) { accumulated[k] = vals[k]; } } @@ -3898,7 +4960,7 @@ } } - const INVALID$2 = "Invalid Interval"; + const INVALID$1 = "Invalid Interval"; // checks if the start is equal to or before the end function validateStartEnd(start, end) { @@ -4419,7 +5481,7 @@ * @return {string} */ toString() { - if (!this.isValid) return INVALID$2; + if (!this.isValid) return INVALID$1; return `[${this.s.toISO()} – ${this.e.toISO()})`; } @@ -4444,7 +5506,7 @@ toLocaleString(formatOpts = DATE_SHORT, opts = {}) { return this.isValid ? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this) - : INVALID$2; + : INVALID$1; } /** @@ -4454,7 +5516,7 @@ * @return {string} */ toISO(opts) { - if (!this.isValid) return INVALID$2; + if (!this.isValid) return INVALID$1; return `${this.s.toISO(opts)}/${this.e.toISO(opts)}`; } @@ -4465,7 +5527,7 @@ * @return {string} */ toISODate() { - if (!this.isValid) return INVALID$2; + if (!this.isValid) return INVALID$1; return `${this.s.toISODate()}/${this.e.toISODate()}`; } @@ -4477,7 +5539,7 @@ * @return {string} */ toISOTime(opts) { - if (!this.isValid) return INVALID$2; + if (!this.isValid) return INVALID$1; return `${this.s.toISOTime(opts)}/${this.e.toISOTime(opts)}`; } @@ -4493,7 +5555,7 @@ * @return {string} */ toFormat(dateFormat, { separator = " – " } = {}) { - if (!this.isValid) return INVALID$2; + if (!this.isValid) return INVALID$1; return `${this.s.toFormat(dateFormat)}${separator}${this.e.toFormat(dateFormat)}`; } @@ -5423,7 +6485,7 @@ } else return false; } - const INVALID$1 = "Invalid DateTime"; + const INVALID = "Invalid DateTime"; const MAX_DATE = 8.64e15; function unsupportedZone(zone) { @@ -5973,7 +7035,7 @@ * @return {DateTime} */ static fromMillis(milliseconds, options = {}) { - if (!isNumber$2(milliseconds)) { + if (!isNumber$1(milliseconds)) { throw new InvalidArgumentError( `fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}` ); @@ -6000,7 +7062,7 @@ * @return {DateTime} */ static fromSeconds(seconds, options = {}) { - if (!isNumber$2(seconds)) { + if (!isNumber$1(seconds)) { throw new InvalidArgumentError("fromSeconds requires a numerical input"); } else { return new DateTime({ @@ -6913,7 +7975,7 @@ toFormat(fmt, opts = {}) { return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) - : INVALID$1; + : INVALID; } /** @@ -6938,7 +8000,7 @@ toLocaleString(formatOpts = DATE_SHORT, opts = {}) { return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) - : INVALID$1; + : INVALID; } /** @@ -7147,7 +8209,7 @@ * @return {string} */ toString() { - return this.isValid ? this.toISO() : INVALID$1; + return this.isValid ? this.toISO() : INVALID; } /** @@ -7609,7 +8671,7 @@ function friendlyDateTime(dateTimeish) { if (DateTime.isDateTime(dateTimeish)) { return dateTimeish; - } else if (dateTimeish && dateTimeish.valueOf && isNumber$2(dateTimeish.valueOf())) { + } else if (dateTimeish && dateTimeish.valueOf && isNumber$1(dateTimeish.valueOf())) { return DateTime.fromJSDate(dateTimeish); } else if (dateTimeish && typeof dateTimeish === "object") { return DateTime.fromObject(dateTimeish); @@ -7625,7 +8687,7 @@ /// The default maximum length of a `TreeBuffer` node. const DefaultBufferLength = 1024; let nextPropID = 0; - let Range$3 = class Range { + let Range$2 = class Range { constructor(from, to) { this.from = from; this.to = to; @@ -7712,8 +8774,8 @@ /// Define a node type. static define(spec) { let props = spec.props && spec.props.length ? Object.create(null) : noProps; - let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) | - (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0); + let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) | + (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0); let type = new NodeType(spec.name || "", props, spec.id, flags); if (spec.props) for (let src of spec.props) { @@ -7731,14 +8793,14 @@ /// the prop isn't present on this node. prop(prop) { return this.props[prop.id]; } /// True when this is the top node of a grammar. - get isTop() { return (this.flags & 1 /* Top */) > 0; } + get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; } /// True when this node is produced by a skip rule. - get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; } + get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; } /// Indicates whether this is an error node. - get isError() { return (this.flags & 4 /* Error */) > 0; } + get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; } /// When true, this node type doesn't correspond to a user-declared /// named node, for example because it is used to cache repetition. - get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; } + get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; } /// Returns true when this node's name or one of its /// [groups](#common.NodeProp^group) matches the given string. is(name) { @@ -7771,7 +8833,7 @@ } } /// An empty dummy node type to use when no actual type is available. - NodeType.none = new NodeType("", Object.create(null), 0, 8 /* Anonymous */); + NodeType.none = new NodeType("", Object.create(null), 0, 8 /* NodeFlag.Anonymous */); /// A node set holds a collection of node types. It is used to /// compactly represent trees by storing their type ids, rather than a /// full pointer to the type object, in a numeric array. Each parser @@ -7943,15 +9005,16 @@ /// not have its children iterated over (or `leave` called). iterate(spec) { let { enter, leave, from = 0, to = this.length } = spec; - for (let c = this.cursor((spec.mode || 0) | IterMode.IncludeAnonymous);;) { + let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0; + for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) { let entered = false; - if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) { + if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) { if (c.firstChild()) continue; entered = true; } for (;;) { - if (entered && leave && !c.type.isAnonymous) + if (entered && leave && (anon || !c.type.isAnonymous)) leave(c); if (c.nextSibling()) break; @@ -7980,7 +9043,7 @@ /// which may have children grouped into subtrees with type /// [`NodeType.none`](#common.NodeType^none). balance(config = {}) { - return this.children.length <= 8 /* BranchFactor */ ? this : + return this.children.length <= 8 /* Balance.BranchFactor */ ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length))); } /// Build a tree from a postfix-ordered buffer of node information, @@ -8059,26 +9122,27 @@ return pick; } /// @internal - slice(startI, endI, from, to) { + slice(startI, endI, from) { let b = this.buffer; - let copy = new Uint16Array(endI - startI); + let copy = new Uint16Array(endI - startI), len = 0; for (let i = startI, j = 0; i < endI;) { copy[j++] = b[i++]; copy[j++] = b[i++] - from; - copy[j++] = b[i++] - from; + let to = copy[j++] = b[i++] - from; copy[j++] = b[i++] - startI; + len = Math.max(len, to); } - return new TreeBuffer(copy, to - from, this.set); + return new TreeBuffer(copy, len, this.set); } } function checkSide(side, pos, from, to) { switch (side) { - case -2 /* Before */: return from < pos; - case -1 /* AtOrBefore */: return to >= pos && from < pos; - case 0 /* Around */: return from < pos && to > pos; - case 1 /* AtOrAfter */: return from <= pos && to > pos; - case 2 /* After */: return to > pos; - case 4 /* DontCare */: return true; + case -2 /* Side.Before */: return from < pos; + case -1 /* Side.AtOrBefore */: return to >= pos && from < pos; + case 0 /* Side.Around */: return from < pos && to > pos; + case 1 /* Side.AtOrAfter */: return from <= pos && to > pos; + case 2 /* Side.After */: return to > pos; + case 4 /* Side.DontCare */: return true; } } function enterUnfinishedNodesBefore(node, pos) { @@ -8168,10 +9232,10 @@ return null; } } - get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); } - get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); } - childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); } - childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); } + get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); } + get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); } + childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); } + childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); } enter(pos, side, mode = 0) { let mounted; if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) { @@ -8194,10 +9258,10 @@ return this._parent ? this._parent.nextSignificantParent() : null; } get nextSibling() { - return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null; + return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null; } get prevSibling() { - return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null; + return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null; } cursor(mode = 0) { return new TreeCursor(this, mode); } get tree() { return this._tree; } @@ -8259,24 +9323,24 @@ } } class BufferNode { + get name() { return this.type.name; } + get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; } + get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; } constructor(context, _parent, index) { this.context = context; this._parent = _parent; this.index = index; this.type = context.buffer.set.types[context.buffer.buffer[index]]; } - get name() { return this.type.name; } - get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; } - get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; } child(dir, pos, side) { let { buffer } = this.context; let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side); return index < 0 ? null : new BufferNode(this.context, this, index); } - get firstChild() { return this.child(1, 0, 4 /* DontCare */); } - get lastChild() { return this.child(-1, 0, 4 /* DontCare */); } - childAfter(pos) { return this.child(1, pos, 2 /* After */); } - childBefore(pos) { return this.child(-1, pos, -2 /* Before */); } + get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); } + get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); } + childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); } + childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); } enter(pos, side, mode = 0) { if (mode & IterMode.ExcludeBuffers) return null; @@ -8288,7 +9352,7 @@ return this._parent || this.context.parent.nextSignificantParent(); } externalSibling(dir) { - return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */); + return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */); } get nextSibling() { let { buffer } = this.context; @@ -8302,7 +9366,7 @@ let parentStart = this._parent ? this._parent.index + 4 : 0; if (this.index == parentStart) return this.externalSibling(-1); - return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */)); + return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */)); } cursor(mode = 0) { return new TreeCursor(this, mode); } get tree() { return null; } @@ -8311,8 +9375,8 @@ let { buffer } = this.context; let startI = this.index + 4, endI = buffer.buffer[this.index + 3]; if (endI > startI) { - let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2]; - children.push(buffer.slice(startI, endI, from, to)); + let from = buffer.buffer[this.index + 1]; + children.push(buffer.slice(startI, endI, from)); positions.push(0); } return new Tree(this.type, children, positions, this.to - this.from); @@ -8339,6 +9403,8 @@ /// A tree cursor object focuses on a given node in a syntax tree, and /// allows you to move to adjacent nodes. class TreeCursor { + /// Shorthand for `.type.name`. + get name() { return this.type.name; } /// @internal constructor(node, /// @internal @@ -8362,8 +9428,6 @@ this.yieldBuf(node.index); } } - /// Shorthand for `.type.name`. - get name() { return this.type.name; } yieldNode(node) { if (!node) return false; @@ -8408,13 +9472,13 @@ } /// Move the cursor to this node's first child. When this returns /// false, the node has no child, and the cursor has not been moved. - firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); } + firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); } /// Move the cursor to this node's last child. - lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); } + lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); } /// Move the cursor to the first child that ends after `pos`. - childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); } + childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); } /// Move to the last child that starts before `pos`. - childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); } + childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); } /// Move the cursor to the child around `pos`. If side is -1 the /// child may end at that position, when 1 it may start there. This /// will also enter [overlaid](#common.MountedTree.overlay) @@ -8440,19 +9504,19 @@ if (!this.buffer) return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null - : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode)); + : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)); let { buffer } = this.buffer, d = this.stack.length - 1; if (dir < 0) { let parentStart = d < 0 ? 0 : this.stack[d] + 4; if (this.index != parentStart) - return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */)); + return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */)); } else { let after = buffer.buffer[this.index + 3]; if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3])) return this.yieldBuf(after); } - return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false; + return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false; } /// Move to this node's next sibling, if any. nextSibling() { return this.sibling(1); } @@ -8489,7 +9553,7 @@ return true; } move(dir, enter) { - if (enter && this.enterChild(dir, 0, 4 /* DontCare */)) + if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */)) return true; for (;;) { if (this.sibling(dir)) @@ -8499,7 +9563,7 @@ } } /// Move to the next node in a - /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR)) + /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR) /// traversal, going from a node to its first child or, if the /// current node is empty or `enter` is false, its next sibling or /// the next sibling of the first parent node that has one. @@ -8615,17 +9679,17 @@ let lookAheadAtStart = lookAhead; while (size < 0) { cursor.next(); - if (size == -1 /* Reuse */) { + if (size == -1 /* SpecialRecord.Reuse */) { let node = reused[id]; children.push(node); positions.push(start - parentStart); return; } - else if (size == -3 /* ContextChange */) { // Context change + else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change contextHash = id; return; } - else if (size == -4 /* LookAhead */) { + else if (size == -4 /* SpecialRecord.LookAhead */) { lookAhead = id; return; } @@ -8742,7 +9806,7 @@ fork.next(); while (fork.pos > startPos) { if (fork.size < 0) { - if (fork.size == -3 /* ContextChange */) + if (fork.size == -3 /* SpecialRecord.ContextChange */) localSkipped += 4; else break scan; @@ -8778,10 +9842,10 @@ buffer[--index] = start - bufferStart; buffer[--index] = id; } - else if (size == -3 /* ContextChange */) { + else if (size == -3 /* SpecialRecord.ContextChange */) { contextHash = id; } - else if (size == -4 /* LookAhead */) { + else if (size == -4 /* SpecialRecord.LookAhead */) { lookAhead = id; } return index; @@ -8828,7 +9892,7 @@ let total = 0; for (let i = from; i < to; i++) total += nodeSize(balanceType, children[i]); - let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */); + let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */); let localChildren = [], localPositions = []; function divide(children, positions, from, to, offset) { for (let i = from; i < to;) { @@ -8889,16 +9953,16 @@ this.to = to; this.tree = tree; this.offset = offset; - this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0); + this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0); } /// Whether the start of the fragment represents the start of a /// parse, or the end of a change. (In the second case, it may not /// be safe to reuse some nodes at the start, depending on the /// parsing algorithm.) - get openStart() { return (this.open & 1 /* Start */) > 0; } + get openStart() { return (this.open & 1 /* Open.Start */) > 0; } /// Whether the end of the fragment represents the end of a /// full-document parse, or the start of a change. - get openEnd() { return (this.open & 2 /* End */) > 0; } + get openEnd() { return (this.open & 2 /* Open.End */) > 0; } /// Create a set of fragments from a freshly parsed tree, or update /// an existing set of fragments by replacing the ones that overlap /// with a tree with content from the new tree. When `partial` is @@ -8957,7 +10021,7 @@ startParse(input, fragments, ranges) { if (typeof input == "string") input = new StringInput(input); - ranges = !ranges ? [new Range$3(0, input.length)] : ranges.length ? ranges.map(r => new Range$3(r.from, r.to)) : [new Range$3(0, 0)]; + ranges = !ranges ? [new Range$2(0, input.length)] : ranges.length ? ranges.map(r => new Range$2(r.from, r.to)) : [new Range$2(0, 0)]; return this.createParse(input, fragments || [], ranges); } /// Run a full parse, returning the resulting tree. @@ -9066,7 +10130,8 @@ // Apply a reduce action /// @internal reduce(action) { - let depth = action >> 19 /* ReduceDepthShift */, type = action & 65535 /* ValueMask */; + var _a; + let depth = action >> 19 /* Action.ReduceDepthShift */, type = action & 65535 /* Action.ValueMask */; let { parser } = this.p; let dPrec = parser.dynamicPrecedence(type); if (dPrec) @@ -9085,15 +10150,29 @@ // consume two extra frames (the dummy parent node for the skipped // expression and the state that we'll be staying in, which should // be moved to `this.state`). - let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* StayFlag */ ? 6 : 0); - let start = this.stack[base - 2]; - let bufferBase = this.stack[base - 1], count = this.bufferBase + this.buffer.length - bufferBase; + let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* Action.StayFlag */ ? 6 : 0); + let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start; + // This is a kludge to try and detect overly deep left-associative + // trees, which will not increase the parse stack depth and thus + // won't be caught by the regular stack-depth limit check. + if (size >= 2000 /* Recover.MinBigReduction */ && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) { + if (start == this.p.lastBigReductionStart) { + this.p.bigReductionCount++; + this.p.lastBigReductionSize = size; + } + else if (this.p.lastBigReductionSize < size) { + this.p.bigReductionCount = 1; + this.p.lastBigReductionStart = start; + this.p.lastBigReductionSize = size; + } + } + let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase; // Store normal terms or `R -> R R` repeat reductions - if (type < parser.minRepeatTerm || (action & 131072 /* RepeatFlag */)) { - let pos = parser.stateFlag(this.state, 1 /* Skipped */) ? this.pos : this.reducePos; + if (type < parser.minRepeatTerm || (action & 131072 /* Action.RepeatFlag */)) { + let pos = parser.stateFlag(this.state, 1 /* StateFlag.Skipped */) ? this.pos : this.reducePos; this.storeNode(type, start, pos, count + 4, true); } - if (action & 262144 /* StayFlag */) { + if (action & 262144 /* Action.StayFlag */) { this.state = this.stack[base]; } else { @@ -9107,7 +10186,7 @@ // Shift a value into the buffer /// @internal storeNode(term, start, end, size = 4, isReduce = false) { - if (term == 0 /* Err */ && + if (term == 0 /* Term.Err */ && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) { // Try to omit/merge adjacent error nodes let cur = this, top = this.buffer.length; @@ -9115,7 +10194,7 @@ top = cur.bufferBase - cur.parent.bufferBase; cur = cur.parent; } - if (top > 0 && cur.buffer[top - 4] == 0 /* Err */ && cur.buffer[top - 1] > -1) { + if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) { if (start == end) return; if (cur.buffer[top - 2] >= start) { @@ -9129,7 +10208,7 @@ } else { // There may be skipped nodes that have to be moved forward let index = this.buffer.length; - if (index > 0 && this.buffer[index - 4] != 0 /* Err */) + if (index > 0 && this.buffer[index - 4] != 0 /* Term.Err */) while (index > 0 && this.buffer[index - 2] > end) { // Move this record forward this.buffer[index] = this.buffer[index - 4]; @@ -9150,14 +10229,14 @@ /// @internal shift(action, next, nextEnd) { let start = this.pos; - if (action & 131072 /* GotoFlag */) { - this.pushState(action & 65535 /* ValueMask */, this.pos); + if (action & 131072 /* Action.GotoFlag */) { + this.pushState(action & 65535 /* Action.ValueMask */, this.pos); } - else if ((action & 262144 /* StayFlag */) == 0) { // Regular shift + else if ((action & 262144 /* Action.StayFlag */) == 0) { // Regular shift let nextState = action, { parser } = this.p; if (nextEnd > this.pos || next <= parser.maxNode) { this.pos = nextEnd; - if (!parser.stateFlag(nextState, 1 /* Skipped */)) + if (!parser.stateFlag(nextState, 1 /* StateFlag.Skipped */)) this.reducePos = nextEnd; } this.pushState(nextState, start); @@ -9175,7 +10254,7 @@ // Apply an action /// @internal apply(action, next, nextEnd) { - if (action & 65536 /* ReduceFlag */) + if (action & 65536 /* Action.ReduceFlag */) this.reduce(action); else this.shift(action, next, nextEnd); @@ -9220,9 +10299,9 @@ let isNode = next <= this.p.parser.maxNode; if (isNode) this.storeNode(next, this.pos, nextEnd, 4); - this.storeNode(0 /* Err */, this.pos, nextEnd, isNode ? 8 : 4); + this.storeNode(0 /* Term.Err */, this.pos, nextEnd, isNode ? 8 : 4); this.pos = this.reducePos = nextEnd; - this.score -= 190 /* Delete */; + this.score -= 190 /* Recover.Delete */; } /// Check if the given term would be able to be shifted (optionally /// after some reductions) on this stack. This can be useful for @@ -9230,10 +10309,10 @@ /// given token when it applies. canShift(term) { for (let sim = new SimulatedStack(this);;) { - let action = this.p.parser.stateSlot(sim.state, 4 /* DefaultReduce */) || this.p.parser.hasAction(sim.state, term); + let action = this.p.parser.stateSlot(sim.state, 4 /* ParseState.DefaultReduce */) || this.p.parser.hasAction(sim.state, term); if (action == 0) return false; - if ((action & 65536 /* ReduceFlag */) == 0) + if ((action & 65536 /* Action.ReduceFlag */) == 0) return true; sim.reduce(action); } @@ -9242,17 +10321,17 @@ // inserts some missing token or rule. /// @internal recoverByInsert(next) { - if (this.stack.length >= 300 /* MaxInsertStackDepth */) + if (this.stack.length >= 300 /* Recover.MaxInsertStackDepth */) return []; let nextStates = this.p.parser.nextStates(this.state); - if (nextStates.length > 4 /* MaxNext */ << 1 || this.stack.length >= 120 /* DampenInsertStackDepth */) { + if (nextStates.length > 4 /* Recover.MaxNext */ << 1 || this.stack.length >= 120 /* Recover.DampenInsertStackDepth */) { let best = []; for (let i = 0, s; i < nextStates.length; i += 2) { if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next)) best.push(nextStates[i], s); } - if (this.stack.length < 120 /* DampenInsertStackDepth */) - for (let i = 0; best.length < 4 /* MaxNext */ << 1 && i < nextStates.length; i += 2) { + if (this.stack.length < 120 /* Recover.DampenInsertStackDepth */) + for (let i = 0; best.length < 4 /* Recover.MaxNext */ << 1 && i < nextStates.length; i += 2) { let s = nextStates[i + 1]; if (!best.some((v, i) => (i & 1) && v == s)) best.push(nextStates[i], s); @@ -9260,15 +10339,15 @@ nextStates = best; } let result = []; - for (let i = 0; i < nextStates.length && result.length < 4 /* MaxNext */; i += 2) { + for (let i = 0; i < nextStates.length && result.length < 4 /* Recover.MaxNext */; i += 2) { let s = nextStates[i + 1]; if (s == this.state) continue; let stack = this.split(); stack.pushState(s, this.pos); - stack.storeNode(0 /* Err */, stack.pos, stack.pos, 4, true); + stack.storeNode(0 /* Term.Err */, stack.pos, stack.pos, 4, true); stack.shiftContext(nextStates[i], this.pos); - stack.score -= 200 /* Insert */; + stack.score -= 200 /* Recover.Insert */; result.push(stack); } return result; @@ -9277,27 +10356,59 @@ // be done. /// @internal forceReduce() { - let reduce = this.p.parser.stateSlot(this.state, 5 /* ForcedReduce */); - if ((reduce & 65536 /* ReduceFlag */) == 0) - return false; let { parser } = this.p; + let reduce = parser.stateSlot(this.state, 5 /* ParseState.ForcedReduce */); + if ((reduce & 65536 /* Action.ReduceFlag */) == 0) + return false; if (!parser.validAction(this.state, reduce)) { - let depth = reduce >> 19 /* ReduceDepthShift */, term = reduce & 65535 /* ValueMask */; + let depth = reduce >> 19 /* Action.ReduceDepthShift */, term = reduce & 65535 /* Action.ValueMask */; let target = this.stack.length - depth * 3; - if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) - return false; - this.storeNode(0 /* Err */, this.reducePos, this.reducePos, 4, true); - this.score -= 100 /* Reduce */; + if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) { + let backup = this.findForcedReduction(); + if (backup == null) + return false; + reduce = backup; + } + this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true); + this.score -= 100 /* Recover.Reduce */; } this.reducePos = this.pos; this.reduce(reduce); return true; } + /// Try to scan through the automaton to find some kind of reduction + /// that can be applied. Used when the regular ForcedReduce field + /// isn't a valid action. @internal + findForcedReduction() { + let { parser } = this.p, seen = []; + let explore = (state, depth) => { + if (seen.includes(state)) + return; + seen.push(state); + return parser.allActions(state, (action) => { + if (action & (262144 /* Action.StayFlag */ | 131072 /* Action.GotoFlag */)) ; + else if (action & 65536 /* Action.ReduceFlag */) { + let rDepth = (action >> 19 /* Action.ReduceDepthShift */) - depth; + if (rDepth > 1) { + let term = action & 65535 /* Action.ValueMask */, target = this.stack.length - rDepth * 3; + if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0) + return (rDepth << 19 /* Action.ReduceDepthShift */) | 65536 /* Action.ReduceFlag */ | term; + } + } + else { + let found = explore(action, depth + 1); + if (found != null) + return found; + } + }); + }; + return explore(this.state, 0); + } /// @internal forceAll() { - while (!this.p.parser.stateFlag(this.state, 2 /* Accepting */)) { + while (!this.p.parser.stateFlag(this.state, 2 /* StateFlag.Accepting */)) { if (!this.forceReduce()) { - this.storeNode(0 /* Err */, this.pos, this.pos, 4, true); + this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true); break; } } @@ -9310,8 +10421,8 @@ if (this.stack.length != 3) return false; let { parser } = this.p; - return parser.data[parser.stateSlot(this.state, 1 /* Actions */)] == 65535 /* End */ && - !parser.stateSlot(this.state, 4 /* DefaultReduce */); + return parser.data[parser.stateSlot(this.state, 1 /* ParseState.Actions */)] == 65535 /* Seq.End */ && + !parser.stateSlot(this.state, 4 /* ParseState.DefaultReduce */); } /// Restart the stack (put it back in its start state). Only safe /// when this.stack.length == 3 (state is directly below the top @@ -9346,13 +10457,13 @@ emitContext() { let last = this.buffer.length - 1; if (last < 0 || this.buffer[last] != -3) - this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3); + this.buffer.push(this.curContext.hash, this.pos, this.pos, -3); } /// @internal emitLookAhead() { let last = this.buffer.length - 1; if (last < 0 || this.buffer[last] != -4) - this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4); + this.buffer.push(this.lookAhead, this.pos, this.pos, -4); } updateContext(context) { if (context != this.curContext.context) { @@ -9392,6 +10503,7 @@ Recover[Recover["MaxNext"] = 4] = "MaxNext"; Recover[Recover["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth"; Recover[Recover["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth"; + Recover[Recover["MinBigReduction"] = 2000] = "MinBigReduction"; })(Recover || (Recover = {})); // Used to cheaply run some reductions to scan ahead without mutating // an entire stack @@ -9403,7 +10515,7 @@ this.base = this.stack.length; } reduce(action) { - let term = action & 65535 /* ValueMask */, depth = action >> 19 /* ReduceDepthShift */; + let term = action & 65535 /* Action.ValueMask */, depth = action >> 19 /* Action.ReduceDepthShift */; if (depth == 0) { if (this.stack == this.start.stack) this.stack = this.stack.slice(); @@ -9454,6 +10566,42 @@ } } + // See lezer-generator/src/encode.ts for comments about the encoding + // used here + function decodeArray(input, Type = Uint16Array) { + if (typeof input != "string") + return input; + let array = null; + for (let pos = 0, out = 0; pos < input.length;) { + let value = 0; + for (;;) { + let next = input.charCodeAt(pos++), stop = false; + if (next == 126 /* Encode.BigValCode */) { + value = 65535 /* Encode.BigVal */; + break; + } + if (next >= 92 /* Encode.Gap2 */) + next--; + if (next >= 34 /* Encode.Gap1 */) + next--; + let digit = next - 32 /* Encode.Start */; + if (digit >= 46 /* Encode.Base */) { + digit -= 46 /* Encode.Base */; + stop = true; + } + value += digit; + if (stop) + break; + value *= 46 /* Encode.Base */; + } + if (array) + array[out++] = value; + else + array = new Type(value); + } + return array; + } + class CachedToken { constructor() { this.start = -1; @@ -9678,9 +10826,13 @@ this.data = data; this.id = id; } - token(input, stack) { readToken(this.data, input, stack, this.id); } + token(input, stack) { + let { parser } = stack.p; + readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable); + } } TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false; + TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false; /// `@external tokens` declarations in the grammar should resolve to /// an instance of this class. class ExternalTokenizer { @@ -9718,8 +10870,8 @@ // This function interprets that data, running through a stream as // long as new states with the a matching group mask can be reached, // and updating `input.token` when it matches a token. - function readToken(data, input, stack, group) { - let state = 0, groupMask = 1 << group, { parser } = stack.p, { dialect } = parser; + function readToken(data, input, stack, group, precTable, precOffset) { + let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser; scan: for (;;) { if ((groupMask & data[state]) == 0) break; @@ -9731,14 +10883,15 @@ if ((data[i + 1] & groupMask) > 0) { let term = data[i]; if (dialect.allows(term) && - (input.token.value == -1 || input.token.value == term || parser.overrides(term, input.token.value))) { + (input.token.value == -1 || input.token.value == term || + overrides(term, input.token.value, precTable, precOffset))) { input.acceptToken(term); break; } } let next = input.next, low = 0, high = data[state + 2]; // Special case for EOF - if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* End */ && data[accEnd + high * 3 - 3] == 65535 /* End */) { + if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */ && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */) { state = data[accEnd + high * 3 - 1]; continue scan; } @@ -9760,41 +10913,15 @@ break; } } - - // See lezer-generator/src/encode.ts for comments about the encoding - // used here - function decodeArray(input, Type = Uint16Array) { - if (typeof input != "string") - return input; - let array = null; - for (let pos = 0, out = 0; pos < input.length;) { - let value = 0; - for (;;) { - let next = input.charCodeAt(pos++), stop = false; - if (next == 126 /* BigValCode */) { - value = 65535 /* BigVal */; - break; - } - if (next >= 92 /* Gap2 */) - next--; - if (next >= 34 /* Gap1 */) - next--; - let digit = next - 32 /* Start */; - if (digit >= 46 /* Base */) { - digit -= 46 /* Base */; - stop = true; - } - value += digit; - if (stop) - break; - value *= 46 /* Base */; - } - if (array) - array[out++] = value; - else - array = new Type(value); - } - return array; + function findOffset(data, start, term) { + for (let i = start, next; (next = data[i]) != 65535 /* Seq.End */; i++) + if (next == term) + return i - start; + return -1; + } + function overrides(token, prev, tableData, tableOffset) { + let iPrev = findOffset(tableData, tableOffset, prev); + return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev; } // Environment variable used to control console output @@ -9811,8 +10938,8 @@ if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos))) for (;;) { if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError) - return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Margin */)) - : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Margin */)); + return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Safety.Margin */)) + : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Safety.Margin */)); if (side < 0 ? cursor.prevSibling() : cursor.nextSibling()) break; if (!cursor.parent()) @@ -9916,7 +11043,7 @@ let actionIndex = 0; let main = null; let { parser } = stack.p, { tokenizers } = parser; - let mask = parser.stateSlot(stack.state, 3 /* TokenizerMask */); + let mask = parser.stateSlot(stack.state, 3 /* ParseState.TokenizerMask */); let context = stack.curContext ? stack.curContext.hash : 0; let lookAhead = 0; for (let i = 0; i < tokenizers.length; i++) { @@ -9930,9 +11057,9 @@ token.mask = mask; token.context = context; } - if (token.lookAhead > token.end + 25 /* Margin */) + if (token.lookAhead > token.end + 25 /* Safety.Margin */) lookAhead = Math.max(token.lookAhead, lookAhead); - if (token.value != 0 /* Err */) { + if (token.value != 0 /* Term.Err */) { let startIndex = actionIndex; if (token.extended > -1) actionIndex = this.addActions(stack, token.extended, token.end, actionIndex); @@ -9963,7 +11090,7 @@ let main = new CachedToken, { pos, p } = stack; main.start = pos; main.end = Math.min(pos + 1, p.stream.end); - main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Err */; + main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Term.Err */; return main; } updateCachedToken(token, tokenizer, stack) { @@ -9975,7 +11102,7 @@ if (parser.specialized[i] == token.value) { let result = parser.specializers[i](this.stream.read(token.start, token.end), stack); if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) { - if ((result & 1) == 0 /* Specialize */) + if ((result & 1) == 0 /* Specialize.Specialize */) token.value = result >> 1; else token.extended = result >> 1; @@ -9984,7 +11111,7 @@ } } else { - token.value = 0 /* Err */; + token.value = 0 /* Term.Err */; token.end = this.stream.clipPos(start + 1); } } @@ -10001,13 +11128,13 @@ addActions(stack, token, end, index) { let { state } = stack, { parser } = stack.p, { data } = parser; for (let set = 0; set < 2; set++) { - for (let i = parser.stateSlot(state, set ? 2 /* Skip */ : 1 /* Actions */);; i += 3) { - if (data[i] == 65535 /* End */) { - if (data[i + 1] == 1 /* Next */) { + for (let i = parser.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */);; i += 3) { + if (data[i] == 65535 /* Seq.End */) { + if (data[i + 1] == 1 /* Seq.Next */) { i = pair(data, i + 2); } else { - if (index == 0 && data[i + 1] == 2 /* Other */) + if (index == 0 && data[i + 1] == 2 /* Seq.Other */) index = this.putAction(pair(data, i + 2), token, end, index); break; } @@ -10032,6 +11159,11 @@ // on recursive traversal. Rec[Rec["CutDepth"] = 15000] = "CutDepth"; Rec[Rec["CutTo"] = 9000] = "CutTo"; + Rec[Rec["MaxLeftAssociativeReductionCount"] = 300] = "MaxLeftAssociativeReductionCount"; + // The maximum number of non-recovering stacks to explore (to avoid + // getting bogged down with exponentially multiplying stacks in + // ambiguous content) + Rec[Rec["MaxStackCount"] = 12] = "MaxStackCount"; })(Rec || (Rec = {})); class Parse { constructor(parser, input, fragments, ranges) { @@ -10043,6 +11175,9 @@ this.minStackPos = 0; this.reused = []; this.stoppedAt = null; + this.lastBigReductionStart = -1; + this.lastBigReductionSize = 0; + this.bigReductionCount = 0; this.stream = new InputStream(input, ranges); this.tokens = new TokenCache(parser, this.stream); this.topTerm = parser.top[1]; @@ -10065,6 +11200,18 @@ // This will hold stacks beyond `pos`. let newStacks = this.stacks = []; let stopped, stoppedTokens; + // If a large amount of reductions happened with the same start + // position, force the stack out of that production in order to + // avoid creating a tree too deep to recurse through. + // (This is an ugly kludge, because unfortunately there is no + // straightforward, cheap way to check for this happening, due to + // the history of reductions only being available in an + // expensive-to-access format in the stack buffers.) + if (this.bigReductionCount > 300 /* Rec.MaxLeftAssociativeReductionCount */ && stacks.length == 1) { + let [s] = stacks; + while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) { } + this.bigReductionCount = this.lastBigReductionSize = 0; + } // Keep advancing any stacks at `pos` until they either move // forward or can't be advanced. Gather stacks that can't be // advanced further in `stopped`. @@ -10100,7 +11247,7 @@ throw new SyntaxError("No parse at " + pos); } if (!this.recovering) - this.recovering = 5 /* Distance */; + this.recovering = 5 /* Rec.Distance */; } if (this.recovering && stopped) { let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] @@ -10109,7 +11256,7 @@ return this.stackToTree(finished.forceAll()); } if (this.recovering) { - let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* MaxRemainingPerStep */; + let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* Rec.MaxRemainingPerStep */; if (newStacks.length > maxRemaining) { newStacks.sort((a, b) => b.score - a.score); while (newStacks.length > maxRemaining) @@ -10127,7 +11274,7 @@ for (let j = i + 1; j < newStacks.length; j++) { let other = newStacks[j]; if (stack.sameState(other) || - stack.buffer.length > 500 /* MinBufferLengthPrune */ && other.buffer.length > 500 /* MinBufferLengthPrune */) { + stack.buffer.length > 500 /* Rec.MinBufferLengthPrune */ && other.buffer.length > 500 /* Rec.MinBufferLengthPrune */) { if (((stack.score - other.score) || (stack.buffer.length - other.buffer.length)) > 0) { newStacks.splice(j--, 1); } @@ -10138,6 +11285,8 @@ } } } + if (newStacks.length > 12 /* Rec.MaxStackCount */) + newStacks.splice(12 /* Rec.MaxStackCount */, newStacks.length - 12 /* Rec.MaxStackCount */); } this.minStackPos = newStacks[0].pos; for (let i = 1; i < newStacks.length; i++) @@ -10178,15 +11327,15 @@ break; } } - let defaultReduce = parser.stateSlot(stack.state, 4 /* DefaultReduce */); + let defaultReduce = parser.stateSlot(stack.state, 4 /* ParseState.DefaultReduce */); if (defaultReduce > 0) { stack.reduce(defaultReduce); if (verbose) - console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* ValueMask */)})`); + console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* Action.ValueMask */)})`); return true; } - if (stack.stack.length >= 15000 /* CutDepth */) { - while (stack.stack.length > 9000 /* CutTo */ && stack.forceReduce()) { } + if (stack.stack.length >= 15000 /* Rec.CutDepth */) { + while (stack.stack.length > 9000 /* Rec.CutTo */ && stack.forceReduce()) { } } let actions = this.tokens.getActions(stack); for (let i = 0; i < actions.length;) { @@ -10195,8 +11344,8 @@ let localStack = last ? stack : stack.split(); localStack.apply(action, term, end); if (verbose) - console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* ReduceFlag */) == 0 ? "shift" - : `reduce of ${parser.getName(action & 65535 /* ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`); + console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* Action.ReduceFlag */) == 0 ? "shift" + : `reduce of ${parser.getName(action & 65535 /* Action.ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`); if (last) return true; else if (localStack.pos > start) @@ -10237,7 +11386,7 @@ continue; } let force = stack.split(), forceBase = base; - for (let j = 0; force.forceReduce() && j < 10 /* ForceReduceLimit */; j++) { + for (let j = 0; force.forceReduce() && j < 10 /* Rec.ForceReduceLimit */; j++) { if (verbose) console.log(forceBase + this.stackID(force) + " (via force-reduce)"); let done = this.advanceFully(force, newStacks); @@ -10254,7 +11403,7 @@ if (this.stream.end > stack.pos) { if (tokenEnd == stack.pos) { tokenEnd++; - token = 0 /* Err */; + token = 0 /* Term.Err */; } stack.recoverByDelete(token, tokenEnd); if (verbose) @@ -10336,8 +11485,8 @@ super(); /// @internal this.wrappers = []; - if (spec.version != 14 /* Version */) - throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* Version */})`); + if (spec.version != 14 /* File.Version */) + throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* File.Version */})`); let nodeNames = spec.nodeNames.split(" "); this.minRepeatTerm = nodeNames.length; for (let i = 0; i < spec.repeatNodeCount; i++) @@ -10427,16 +11576,16 @@ hasAction(state, terminal) { let data = this.data; for (let set = 0; set < 2; set++) { - for (let i = this.stateSlot(state, set ? 2 /* Skip */ : 1 /* Actions */), next;; i += 3) { - if ((next = data[i]) == 65535 /* End */) { - if (data[i + 1] == 1 /* Next */) + for (let i = this.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */), next;; i += 3) { + if ((next = data[i]) == 65535 /* Seq.End */) { + if (data[i + 1] == 1 /* Seq.Next */) next = data[i = pair(data, i + 2)]; - else if (data[i + 1] == 2 /* Other */) + else if (data[i + 1] == 2 /* Seq.Other */) return pair(data, i + 2); else break; } - if (next == terminal || next == 0 /* Err */) + if (next == terminal || next == 0 /* Term.Err */) return pair(data, i + 1); } } @@ -10444,39 +11593,43 @@ } /// @internal stateSlot(state, slot) { - return this.states[(state * 6 /* Size */) + slot]; + return this.states[(state * 6 /* ParseState.Size */) + slot]; } /// @internal stateFlag(state, flag) { - return (this.stateSlot(state, 0 /* Flags */) & flag) > 0; + return (this.stateSlot(state, 0 /* ParseState.Flags */) & flag) > 0; } /// @internal validAction(state, action) { - if (action == this.stateSlot(state, 4 /* DefaultReduce */)) - return true; - for (let i = this.stateSlot(state, 1 /* Actions */);; i += 3) { - if (this.data[i] == 65535 /* End */) { - if (this.data[i + 1] == 1 /* Next */) + return !!this.allActions(state, a => a == action ? true : null); + } + /// @internal + allActions(state, action) { + let deflt = this.stateSlot(state, 4 /* ParseState.DefaultReduce */); + let result = deflt ? action(deflt) : undefined; + for (let i = this.stateSlot(state, 1 /* ParseState.Actions */); result == null; i += 3) { + if (this.data[i] == 65535 /* Seq.End */) { + if (this.data[i + 1] == 1 /* Seq.Next */) i = pair(this.data, i + 2); else - return false; + break; } - if (action == pair(this.data, i + 1)) - return true; + result = action(pair(this.data, i + 1)); } + return result; } /// Get the states that can follow this one through shift actions or /// goto jumps. @internal nextStates(state) { let result = []; - for (let i = this.stateSlot(state, 1 /* Actions */);; i += 3) { - if (this.data[i] == 65535 /* End */) { - if (this.data[i + 1] == 1 /* Next */) + for (let i = this.stateSlot(state, 1 /* ParseState.Actions */);; i += 3) { + if (this.data[i] == 65535 /* Seq.End */) { + if (this.data[i + 1] == 1 /* Seq.Next */) i = pair(this.data, i + 2); else break; } - if ((this.data[i + 2] & (65536 /* ReduceFlag */ >> 16)) == 0) { + if ((this.data[i + 2] & (65536 /* Action.ReduceFlag */ >> 16)) == 0) { let value = this.data[i + 1]; if (!result.some((v, i) => (i & 1) && v == value)) result.push(this.data[i], value); @@ -10484,11 +11637,6 @@ } return result; } - /// @internal - overrides(token, prev) { - let iPrev = findOffset(this.data, this.tokenPrecTable, prev); - return iPrev < 0 || findOffset(this.data, this.tokenPrecTable, token) < iPrev; - } /// Configure the parser. Returns a new parser instance that has the /// given settings modified. Settings not provided in `config` are /// kept from the original parser. @@ -10566,30 +11714,24 @@ let disabled = null; for (let i = 0; i < values.length; i++) if (!flags[i]) { - for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* End */;) + for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* Seq.End */;) (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1; } return new Dialect(dialect, flags, disabled); } /// Used by the output of the parser generator. Not available to - /// user code. + /// user code. @hide static deserialize(spec) { return new LRParser(spec); } } function pair(data, off) { return data[off] | (data[off + 1] << 16); } - function findOffset(data, start, term) { - for (let i = start, next; (next = data[i]) != 65535 /* End */; i++) - if (next == term) - return i - start; - return -1; - } function findFinished(stacks) { let best = null; for (let stack of stacks) { let stopped = stack.p.stoppedAt; if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && - stack.p.parser.stateFlag(stack.state, 2 /* Accepting */) && + stack.p.parser.stateFlag(stack.state, 2 /* StateFlag.Accepting */) && (!best || best.score < stack.score)) best = stack; } @@ -10597,7 +11739,7 @@ } function getSpecializer(spec) { if (spec.external) { - let mask = spec.extend ? 1 /* Extend */ : 0 /* Specialize */; + let mask = spec.extend ? 1 /* Specialize.Extend */ : 0 /* Specialize.Specialize */; return (value, stack) => (spec.external(value, stack) << 1) | mask; } return spec.get; @@ -10933,7 +12075,7 @@ if (rule.mode == 1 /* Inherit */) inheritedClass += (inheritedClass ? " " : "") + tagCls; } - this.startSpan(cursor.from, cls); + this.startSpan(Math.max(from, start), cls); if (rule.opaque) return; let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted); @@ -10957,14 +12099,16 @@ break; pos = next.to + start; if (pos > from) { - this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters); - this.startSpan(pos, cls); + this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters); + this.startSpan(Math.min(to, pos), cls); } } if (hasChild) cursor.parent(); } else if (cursor.firstChild()) { + if (mounted) + inheritedClass = ""; do { if (cursor.to <= from) continue; @@ -11458,68 +12602,78 @@ ]); // This file was generated by lezer-generator. You probably shouldn't edit it. - const propertyIdentifier$1 = 147, - identifier$1 = 148, - nameIdentifier$1 = 149, - insertSemi$1 = 150, - expression0$1 = 154, - ForExpression$1 = 4, - forExpressionStart$1 = 157, - ForInExpression$1 = 7, - Name$1 = 8, - Identifier$1 = 9, - AdditionalIdentifier$1 = 10, - forExpressionBodyStart$1 = 165, - IfExpression$1 = 18, - ifExpressionStart$1 = 166, - QuantifiedExpression$1 = 22, - quantifiedExpressionStart$1 = 167, - QuantifiedInExpression$1 = 26, - PositiveUnaryTest$1 = 36, - ArithmeticExpression$1 = 40, - arithmeticPlusStart$1 = 171, - arithmeticTimesStart$1 = 172, - arithmeticExpStart$1 = 173, - arithmeticUnaryStart$1 = 174, - VariableName$1 = 47, - PathExpression$1 = 67, - pathExpressionStart$1 = 179, - FilterExpression$1 = 69, - filterExpressionStart$1 = 180, - FunctionInvocation$1 = 71, - functionInvocationStart$1 = 181, - ParameterName$1 = 103, - nil$1 = 186, - NumericLiteral$1 = 106, - StringLiteral$1 = 107, - BooleanLiteral$1 = 108, - FunctionDefinition$1 = 117, - functionDefinitionStart$1 = 194, - Context$1 = 124, - contextStart$1 = 196, - ContextEntry$1 = 125, - PropertyName$1 = 127, - PropertyIdentifier$1 = 128; - - const LOG_PARSE$1 = typeof process != 'undefined' && process.env && /\bfparse(:dbg)?\b/.test(process.env.LOG); - const LOG_PARSE_DEBUG$1 = typeof process != 'undefined' && process.env && /\fparse:dbg\b/.test(process.env.LOG); - const LOG_VARS$1 = typeof process != 'undefined' && process.env && /\bcontext?\b/.test(process.env.LOG); - - const spaceChars$1 = [ + const propertyIdentifier = 120, + identifier = 121, + nameIdentifier = 122, + insertSemi = 123, + expression0 = 127, + ForExpression = 4, + forExpressionStart = 130, + ForInExpression = 7, + Name = 8, + Identifier = 9, + AdditionalIdentifier = 10, + forExpressionBodyStart = 138, + IfExpression = 19, + ifExpressionStart = 139, + QuantifiedExpression = 23, + quantifiedExpressionStart = 140, + QuantifiedInExpression = 27, + PositiveUnaryTest = 37, + ArithmeticExpression = 41, + arithmeticPlusStart = 144, + arithmeticTimesStart = 145, + arithmeticExpStart = 146, + arithmeticUnaryStart = 147, + VariableName = 47, + PathExpression = 67, + pathExpressionStart = 152, + FilterExpression = 69, + filterExpressionStart = 153, + FunctionInvocation = 71, + functionInvocationStart = 154, + ParameterName = 75, + nil = 159, + NumericLiteral = 78, + StringLiteral = 79, + BooleanLiteral = 80, + List = 88, + listStart = 170, + FunctionDefinition = 89, + functionDefinitionStart = 172, + Context = 96, + contextStart = 174, + ContextEntry = 97, + PropertyName = 99, + PropertyIdentifier = 100; + + /* global console,process */ + + const LOG_PARSE = typeof process != 'undefined' && process.env && /\bfparse(:dbg)?\b/.test(process.env.LOG); + const LOG_PARSE_DEBUG = typeof process != 'undefined' && process.env && /\bfparse:dbg\b/.test(process.env.LOG); + const LOG_VARS = typeof process != 'undefined' && process.env && /\bcontext\b/.test(process.env.LOG); + + const spaceChars = [ 9, 11, 12, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288 ]; - const newlineChars$1 = chars$3('\n\r'); + const newlineChars = chars$1('\n\r'); + + const asterix = '*'.charCodeAt(0); - const additionalNameChars$1 = chars$3("'./-+*"); + const additionalNameChars = chars$1("'./-+*^"); + + /** + * @typedef { VariableContext | any } ContextValue + */ /** * @param { string } str * @return { number[] } */ - function chars$3(str) { + function chars$1(str) { return Array.from(str).map(s => s.charCodeAt(0)); } @@ -11527,7 +12681,7 @@ * @param { number } ch * @return { boolean } */ - function isStartChar$1(ch) { + function isStartChar(ch) { return ( ch === 63 // ? ) || ( @@ -11537,7 +12691,7 @@ ) || ( ch >= 97 && ch <= 122 // a-z ) || ( - ch >= 161 && !isPartChar$1(ch) && !isSpace$1(ch) + ch >= 161 && !isPartChar(ch) && !isSpace(ch) ); } @@ -11545,15 +12699,15 @@ * @param { number } ch * @return { boolean } */ - function isAdditional$1(ch) { - return additionalNameChars$1.includes(ch); + function isAdditional(ch) { + return additionalNameChars.includes(ch); } /** * @param { number } ch * @return { boolean } */ - function isPartChar$1(ch) { + function isPartChar(ch) { return ( ch >= 48 && ch <= 57 // 0-9 ) || ( @@ -11569,12 +12723,12 @@ * @param { number } ch * @return { boolean } */ - function isSpace$1(ch) { - return spaceChars$1.includes(ch); + function isSpace(ch) { + return spaceChars.includes(ch); } // eslint-disable-next-line - function indent$1(str, spaces) { + function indent(str, spaces) { return spaces.concat( str.split(/\n/g).join('\n' + spaces) ); @@ -11583,15 +12737,22 @@ /** * @param { import('@lezer/lr').InputStream } input * @param { number } [offset] - * @param { boolean } [includeOperators] * * @return { { token: string, offset: number } | null } */ - function parseAdditionalSymbol$1(input, offset = 0) { + function parseAdditionalSymbol(input, offset = 0) { const next = input.peek(offset); - if (isAdditional$1(next)) { + if (next === asterix && input.peek(offset + 1) === asterix) { + + return { + offset: 2, + token: '**' + }; + } + + if (isAdditional(next)) { return { offset: 1, token: String.fromCharCode(next) @@ -11608,11 +12769,11 @@ * * @return { { token: string, offset: number } | null } */ - function parseIdentifier$1(input, offset = 0, namePart = false) { + function parseIdentifier(input, offset = 0, namePart = false) { for (let inside = false, chars = [], i = 0;; i++) { const next = input.peek(offset + i); - if (isStartChar$1(next) || ((inside || namePart) && isPartChar$1(next))) { + if (isStartChar(next) || ((inside || namePart) && isPartChar(next))) { if (!inside) { inside = true; } @@ -11638,12 +12799,12 @@ * * @return { { token: string, offset: number } | null } */ - function parseSpaces$1(input, offset) { + function parseSpaces(input, offset) { for (let inside = false, i = 0;; i++) { let next = input.peek(offset + i); - if (isSpace$1(next)) { + if (isSpace(next)) { if (!inside) { inside = true; } @@ -11668,7 +12829,7 @@ * * @return { { token: string, offset: number, term: number } | null } */ - function parseName$1(input, variables) { + function parseName(input, variables) { const contextKeys = variables.contextKeys(); const start = variables.tokens; @@ -11679,9 +12840,9 @@ const maybeSpace = tokens.length > 0; const match = ( - parseIdentifier$1(input, i, namePart) || - namePart && parseAdditionalSymbol$1(input, i) || - maybeSpace && parseSpaces$1(input, i) + parseIdentifier(input, i, namePart) || + namePart && parseAdditionalSymbol(input, i) || + maybeSpace && parseSpaces(input, i) ); // match is required @@ -11710,11 +12871,11 @@ nextMatch = { token, offset: token.length, - term: nameIdentifier$1 + term: nameIdentifier }; } - if (dateTimeIdentifiers$1.some(el => el === name)) { + if (dateTimeIdentifiers.some(el => el === name)) { const token = tokens[0]; // parse date time identifiers as normal @@ -11724,13 +12885,13 @@ nextMatch = { token, offset: token.length, - term: identifier$1 + term: identifier }; } if ( !contextKeys.some(el => el.startsWith(name)) && - !dateTimeIdentifiers$1.some(el => el.startsWith(name)) + !dateTimeIdentifiers.some(el => el.startsWith(name)) ) { return nextMatch; } @@ -11738,50 +12899,50 @@ } - const identifiersMap$1 = { - [ identifier$1 ]: 'identifier', - [ nameIdentifier$1 ]: 'nameIdentifier' + const identifiersMap = { + [ identifier ]: 'identifier', + [ nameIdentifier ]: 'nameIdentifier' }; - const identifiers$1 = new ExternalTokenizer((input, stack) => { + const identifiers = new ExternalTokenizer((input, stack) => { - LOG_PARSE_DEBUG$1 && console.log('%s: T ', input.pos); + LOG_PARSE_DEBUG && console.log('%s: T ', input.pos); - const nameMatch = parseName$1(input, stack.context); + const nameMatch = parseName(input, stack.context); const start = stack.context.tokens; - const match = nameMatch || parseIdentifier$1(input, 0, start.length > 0); + const match = nameMatch || parseIdentifier(input, 0, start.length > 0); if (match) { input.advance(match.offset); - input.acceptToken(nameMatch ? nameMatch.term : identifier$1); + input.acceptToken(nameMatch ? nameMatch.term : identifier); - LOG_PARSE$1 && console.log('%s: MATCH <%s> <%s>', input.pos, nameMatch ? identifiersMap$1[nameMatch.term] : 'identifier', match.token); + LOG_PARSE && console.log('%s: MATCH <%s> <%s>', input.pos, nameMatch ? identifiersMap[nameMatch.term] : 'identifier', match.token); } }, { contextual: true }); - const propertyIdentifiers$1 = new ExternalTokenizer((input, stack) => { + const propertyIdentifiers = new ExternalTokenizer((input, stack) => { - LOG_PARSE_DEBUG$1 && console.log('%s: T ', input.pos); + LOG_PARSE_DEBUG && console.log('%s: T ', input.pos); const start = stack.context.tokens; - const match = parseIdentifier$1(input, 0, start.length > 0); + const match = parseIdentifier(input, 0, start.length > 0); if (match) { input.advance(match.offset); - input.acceptToken(propertyIdentifier$1); + input.acceptToken(propertyIdentifier); - LOG_PARSE$1 && console.log('%s: MATCH <%s>', input.pos, match.token); + LOG_PARSE && console.log('%s: MATCH <%s>', input.pos, match.token); } }); - const insertSemicolon$1 = new ExternalTokenizer((input, stack) => { + const insertSemicolon = new ExternalTokenizer((input, stack) => { - LOG_PARSE_DEBUG$1 && console.log('%s: T ', input.pos); + LOG_PARSE_DEBUG && console.log('%s: T ', input.pos); let offset; let insert = false; @@ -11789,11 +12950,11 @@ for (offset = 0;; offset++) { const char = input.peek(offset); - if (spaceChars$1.includes(char)) { + if (spaceChars.includes(char)) { continue; } - if (newlineChars$1.includes(char)) { + if (newlineChars.includes(char)) { insert = true; } @@ -11802,45 +12963,47 @@ if (insert) { - const identifier = parseIdentifier$1(input, offset + 1); - const spaces = parseSpaces$1(input, offset + 1); + const identifier = parseIdentifier(input, offset + 1); + const spaces = parseSpaces(input, offset + 1); if (spaces || identifier && /^(then|else|return|satisfies)$/.test(identifier.token)) { return; } - LOG_PARSE$1 && console.log('%s: MATCH ', input.pos); - input.acceptToken(insertSemi$1); + LOG_PARSE && console.log('%s: MATCH ', input.pos); + input.acceptToken(insertSemi); } }); - const prefixedContextStarts$1 = { - [ functionInvocationStart$1 ]: 'FunctionInvocation', - [ filterExpressionStart$1 ]: 'FilterExpression', - [ pathExpressionStart$1 ]: 'PathExpression' + const prefixedContextStarts = { + [ functionInvocationStart ]: 'FunctionInvocation', + [ filterExpressionStart ]: 'FilterExpression', + [ pathExpressionStart ]: 'PathExpression' }; - const contextStarts$1 = { - [ contextStart$1 ]: 'Context', - [ functionDefinitionStart$1 ]: 'FunctionDefinition', - [ forExpressionStart$1 ]: 'ForExpression', - [ ifExpressionStart$1 ]: 'IfExpression', - [ quantifiedExpressionStart$1 ]: 'QuantifiedExpression' + const contextStarts = { + [ contextStart ]: 'Context', + [ functionDefinitionStart ]: 'FunctionDefinition', + [ forExpressionStart ]: 'ForExpression', + [ listStart ]: 'List', + [ ifExpressionStart ]: 'IfExpression', + [ quantifiedExpressionStart ]: 'QuantifiedExpression' }; - const contextEnds$1 = { - [ Context$1 ]: 'Context', - [ FunctionDefinition$1 ]: 'FunctionDefinition', - [ ForExpression$1 ]: 'ForExpression', - [ IfExpression$1 ]: 'IfExpression', - [ QuantifiedExpression$1 ]: 'QuantifiedExpression', - [ PathExpression$1 ]: 'PathExpression', - [ FunctionInvocation$1 ]: 'FunctionInvocation', - [ FilterExpression$1 ]: 'FilterExpression', - [ ArithmeticExpression$1 ]: 'ArithmeticExpression' + const contextEnds = { + [ Context ]: 'Context', + [ FunctionDefinition ]: 'FunctionDefinition', + [ ForExpression ]: 'ForExpression', + [ List ]: 'List', + [ IfExpression ]: 'IfExpression', + [ QuantifiedExpression ]: 'QuantifiedExpression', + [ PathExpression ]: 'PathExpression', + [ FunctionInvocation ]: 'FunctionInvocation', + [ FilterExpression ]: 'FilterExpression', + [ ArithmeticExpression ]: 'ArithmeticExpression' }; - let ValueProducer$1 = class ValueProducer { + class ValueProducer { /** * @param { Function } fn @@ -11862,25 +13025,131 @@ return new ValueProducer(fn); } - }; + } - const dateTimeLiterals$1 = { + const dateTimeLiterals = { 'date and time': 1, 'date': 1, 'time': 1, 'duration': 1 }; - const dateTimeIdentifiers$1 = Object.keys(dateTimeLiterals$1); + const dateTimeIdentifiers = Object.keys(dateTimeLiterals); + + + /** + * A basic key-value store to hold context values. + */ + class VariableContext { + + /** + * Creates a new context from a JavaScript object. + * + * @param {any} value + */ + constructor(value = {}) { + + /** + * @protected + */ + this.value = value; + } + + /** + * Return all defined keys of the context. + * + * @returns {Array} the keys of the context + */ + getKeys() { + return Object.keys(this.value); + } + + /** + * Returns the value of the given key. + * + * If the value represents a context itself, it should be wrapped in a + * context class. + * + * @param {String} key + * @returns {VariableContext|ValueProducer|null} + */ + get(key) { + const result = this.value[key]; + + if (this.constructor.isAtomic(result)) { + return result; + } + + return this.constructor.of(result); + } + + /** + * Creates a new context with the given key added. + * + * @param {String} key + * @param {any} value + * @returns {VariableContext} new context with the given key added + */ + set(key, value) { + return this.constructor.of({ + ...this.value, + [key]: value + }); + } + + /** + * Wether the given value is atomic. Non-atomic values need to be wrapped in a + * context Class. + * + * @param {any} value + * @returns {Boolean} + */ + static isAtomic(value) { + return !value || + value instanceof this || + value instanceof ValueProducer || + typeof value !== 'object'; + } + + /** + * Takes any number of Contexts and merges them into a single Context. + * + * @param {...Context} contexts + * @returns {VariableContext} + */ + static of(...contexts) { + const unwrap = (context) => { + if (!context || typeof context !== 'object') { + return {}; + } + + if (context instanceof this) { + return context.value; + } - let Variables$1 = class Variables { + return { ...context }; + }; + + const merged = contexts.reduce((merged, context) => { + return { + ...merged, + ...unwrap(context) + }; + }, {}); + + return new this(merged); + } + + } + + class Variables { constructor({ name = 'Expressions', tokens = [], children = [], parent = null, - context = { }, + context, value, raw } = {}) { @@ -11900,7 +13169,7 @@ parent: this }); - LOG_VARS$1 && console.log('[%s] enter', childScope.path, childScope.context); + LOG_VARS && console.log('[%s] enter', childScope.path, childScope.context); return childScope; } @@ -11908,19 +13177,19 @@ exitScope(str) { if (!this.parent) { - LOG_VARS$1 && console.log('[%s] NO exit %o\n%s', this.path, this.context, indent$1(str, ' ')); + LOG_VARS && console.log('[%s] NO exit %o\n%s', this.path, this.context, indent(str, ' ')); return this; } - LOG_VARS$1 && console.log('[%s] exit %o\n%s', this.path, this.context, indent$1(str, ' ')); + LOG_VARS && console.log('[%s] exit %o\n%s', this.path, this.context, indent(str, ' ')); return this.parent.pushChild(this); } token(part) { - LOG_VARS$1 && console.log('[%s] token <%s> + <%s>', this.path, this.tokens.join(' '), part); + LOG_VARS && console.log('[%s] token <%s> + <%s>', this.path, this.tokens.join(' '), part); return this.assign({ tokens: [ ...this.tokens, part ] @@ -11929,7 +13198,7 @@ literal(value) { - LOG_VARS$1 && console.log('[%s] literal %o', this.path, value); + LOG_VARS && console.log('[%s] literal %o', this.path, value); return this.pushChild(this.of({ name: 'Literal', @@ -11943,7 +13212,7 @@ * @return {any} */ computedValue() { - for (let scope = this;;scope = scope.children.slice(-1)[0]) { + for (let scope = this;;scope = last(scope.children)) { if (!scope) { return null; @@ -11956,7 +13225,7 @@ } contextKeys() { - return Object.keys(this.context).map(normalizeContextKey$1); + return this.context.getKeys().map(normalizeContextKey); } get path() { @@ -11971,19 +13240,19 @@ */ get(variable) { - const names = [ variable, variable && normalizeContextKey$1(variable) ]; + const names = [ variable, variable && normalizeContextKey(variable) ]; - const contextKey = Object.keys(this.context).find( - key => names.includes(normalizeContextKey$1(key)) + const contextKey = this.context.getKeys().find( + key => names.includes(normalizeContextKey(key)) ); if (typeof contextKey === 'undefined') { return undefined; } - const val = this.context[contextKey]; + const val = this.context.get(contextKey); - if (val instanceof ValueProducer$1) { + if (val instanceof ValueProducer) { return val.get(this); } else { return val; @@ -12006,7 +13275,7 @@ raw: variable }); - LOG_VARS$1 && console.log('[%s] resolve name <%s=%s>', variableScope.path, variable, this.get(variable)); + LOG_VARS && console.log('[%s] resolve name <%s=%s>', variableScope.path, variable, this.get(variable)); return parentScope.pushChild(variableScope); } @@ -12045,7 +13314,7 @@ const variableName = this.tokens.join(' '); - LOG_VARS$1 && console.log('[%s] declareName <%s>', this.path, variableName); + LOG_VARS && console.log('[%s] declareName <%s>', this.path, variableName); return this.assign({ tokens: [] @@ -12060,17 +13329,14 @@ define(name, value) { if (typeof name !== 'string') { - LOG_VARS$1 && console.log('[%s] no define <%s=%s>', this.path, name, value); + LOG_VARS && console.log('[%s] no define <%s=%s>', this.path, name, value); return this; } - LOG_VARS$1 && console.log('[%s] define <%s=%s>', this.path, name, value); + LOG_VARS && console.log('[%s] define <%s=%s>', this.path, name, value); - const context = { - ...this.context, - [name]: value - }; + const context = this.context.set(name, value); return this.assign({ context @@ -12109,38 +13375,41 @@ } static of(options) { + const { name, tokens = [], children = [], parent = null, - context = {}, + context, value, raw } = options; + if (!context) { + throw new Error('must provide '); + } + return new Variables({ name, tokens: [ ...tokens ], children: [ ...children ], - context: { - ...context - }, + context, parent, value, raw }); } - }; + } /** * @param { string } name * * @return { string } normalizedName */ - function normalizeContextKey$1(name) { - return name.replace(/\s*([./\-'+*])\s*/g, ' $1 ').replace(/\s{2,}/g, ' ').trim(); + function normalizeContextKey(name) { + return name.replace(/\s*([./\-'+]|\*\*?)\s*/g, ' $1 ').replace(/\s{2,}/g, ' ').trim(); } /** @@ -12151,7 +13420,7 @@ * @param { string } code * @return { Variables } */ - function wrap$1(variables, scopeName, code) { + function wrap(variables, scopeName, code) { const parts = variables.children.filter(c => c.name !== scopeName); const children = variables.children.filter(c => c.name === scopeName); @@ -12173,38 +13442,43 @@ } /** - * @param { any } context + * @param { ContextValue } [context] + * @param { typeof VariableContext } [Context] * * @return { ContextTracker } */ - function trackVariables$1(context = {}) { + function trackVariables(context = {}, Context = VariableContext) { - const start = Variables$1.of({ - context + const start = Variables.of({ + context: Context.of(context) }); return new ContextTracker({ start, reduce(variables, term, stack, input) { - if (term === Context$1) { + if (term === IfExpression) { + const [ thenPart, elsePart ] = variables.children.slice(-2); + variables = variables.assign({ - value: variables.context + value: Context.of( + thenPart?.computedValue(), + elsePart?.computedValue() + ) }); } - if (term === IfExpression$1) { - const [ thenPart, elsePart ] = variables.children.slice(-2); - + if (term === List) { variables = variables.assign({ - value: { - ...thenPart?.computedValue(), - ...elsePart?.computedValue() - } + value: Context.of( + ...variables.children.map( + c => c?.computedValue() + ) + ) }); } - if (term === FilterExpression$1) { + if (term === FilterExpression) { const [ sourcePart, _ ] = variables.children.slice(-2); variables = variables.assign({ @@ -12212,7 +13486,7 @@ }); } - if (term === FunctionInvocation$1) { + if (term === FunctionInvocation) { const [ name, @@ -12221,70 +13495,94 @@ // preserve type information through `get value(context, key)` utility if (name?.raw === 'get value') { - variables = getContextValue$1(variables, args); + variables = getContextValue(variables, args); } } - const start = contextStarts$1[term]; + const start = contextStarts[term]; if (start) { return variables.enterScope(start); } - const prefixedStart = prefixedContextStarts$1[term]; + const prefixedStart = prefixedContextStarts[term]; // pull into new context if (prefixedStart) { - const children = variables.children.slice(0, -1); - const lastChild = variables.children.slice(-1)[0]; + const { + children: currentChildren, + context: currentContext, + } = variables; - return variables.assign({ - children - }).enterScope(prefixedStart).pushChild(lastChild).assign({ - context: { - ...variables.context, - ...lastChild?.computedValue() - } - }); + const children = currentChildren.slice(0, -1); + const lastChild = last(currentChildren); + + let newContext = null; + + if (term === pathExpressionStart) { + newContext = Context.of(lastChild?.computedValue()); + } + + if (term === filterExpressionStart) { + newContext = Context.of( + currentContext, + lastChild?.computedValue() + ).set('item', lastChild?.computedValue()); + } + + return variables + .assign({ children }) + .enterScope(prefixedStart) + .pushChild(lastChild) + .assign({ context: newContext || currentContext }); } const code = input.read(input.pos, stack.pos); - const end = contextEnds$1[term]; + const end = contextEnds[term]; if (end) { return variables.exitScope(code); } - if (term === ContextEntry$1) { - return wrap$1(variables, 'ContextEntry', code); + if (term === ContextEntry) { + const parts = variables.children.filter(c => c.name !== 'ContextEntry'); + + const name = parts[0]; + const value = last(parts); + + return wrap(variables, 'ContextEntry', code).assign( + { + value: Context + .of(variables.value) + .set(name.computedValue(), value?.computedValue()) + } + ); } if ( - term === ForInExpression$1 || - term === QuantifiedInExpression$1 + term === ForInExpression || + term === QuantifiedInExpression ) { - return wrap$1(variables, 'InExpression', code); + return wrap(variables, 'InExpression', code); } // define within ForExpression body - if (term === forExpressionBodyStart$1) { + if (term === forExpressionBodyStart) { return variables.define( 'partial', - ValueProducer$1.of(variables => { - return variables.children[variables.children.length - 1]?.computedValue(); + ValueProducer.of(variables => { + return last(variables.children)?.computedValue(); }) ); } if ( - term === ParameterName$1 + term === ParameterName ) { - const [ left ] = variables.children.slice(-1); - - const name = left.computedValue(); + const name = last(variables.children).computedValue(); // TODO: attach type information return variables.define(name, 1); @@ -12292,71 +13590,71 @@ // pull into ArithmeticExpression child if ( - term === arithmeticPlusStart$1 || - term === arithmeticTimesStart$1 || - term === arithmeticExpStart$1 + term === arithmeticPlusStart || + term === arithmeticTimesStart || + term === arithmeticExpStart ) { const children = variables.children.slice(0, -1); - const lastChild = variables.children.slice(-1)[0]; + const lastChild = last(variables.children); return variables.assign({ children }).enterScope('ArithmeticExpression').pushChild(lastChild); } - if (term === arithmeticUnaryStart$1) { + if (term === arithmeticUnaryStart) { return variables.enterScope('ArithmeticExpression'); } if ( - term === Identifier$1 || - term === AdditionalIdentifier$1 || - term === PropertyIdentifier$1 + term === Identifier || + term === AdditionalIdentifier || + term === PropertyIdentifier ) { return variables.token(code); } if ( - term === StringLiteral$1 + term === StringLiteral ) { return variables.literal(code.replace(/^"|"$/g, '')); } - if (term === BooleanLiteral$1) { + if (term === BooleanLiteral) { return variables.literal(code === 'true' ? true : false); } - if (term === NumericLiteral$1) { + if (term === NumericLiteral) { return variables.literal(parseFloat(code)); } - if (term === nil$1) { + if (term === nil) { return variables.literal(null); } if ( - term === VariableName$1 + term === VariableName ) { return variables.resolveName(); } if ( - term === Name$1 || - term === PropertyName$1 + term === Name || + term === PropertyName ) { return variables.declareName(); } if ( - term === expression0$1 || - term === PositiveUnaryTest$1 + term === expression0 || + term === PositiveUnaryTest ) { if (variables.tokens.length > 0) { throw new Error('uncleared name'); } } - if (term === expression0$1) { + if (term === expression0) { let parent = variables; @@ -12372,12 +13670,12 @@ }); } - const variableTracker$1 = trackVariables$1({}); + const variableTracker = trackVariables({}); // helpers ////////////// - function getContextValue$1(variables, args) { + function getContextValue(variables, args) { if (!args.length) { return variables.assign({ @@ -12386,7 +13684,7 @@ } if (args[0].name === 'Name') { - args = extractNamedArgs$1(args, [ 'm', 'key' ]); + args = extractNamedArgs(args, [ 'm', 'key' ]); } if (args.length !== 2) { @@ -12412,17 +13710,13 @@ } return variables.assign({ - value: [ normalizeContextKey$1(keyValue), keyValue ].reduce((value, keyValue) => { - if (keyValue in contextValue) { - return contextValue[keyValue]; - } - - return value; + value: [ normalizeContextKey(keyValue), keyValue ].reduce((value, keyValue) => { + return contextValue.get(keyValue) || value; }, null) }); } - function extractNamedArgs$1(args, argNames) { + function extractNamedArgs(args, argNames) { const context = {}; @@ -12435,181 +13729,106 @@ return argNames.map(name => context[name]); } - const feelHighlighting$1 = styleTags({ - 'StringLiteral': tags.string, - 'NumericLiteral': tags.number, - 'BooleanLiteral': tags.bool, - 'Name QualifiedName': tags.name, - 'CompareOp': tags.compareOperator, - 'ArithOp': tags.arithmeticOperator, - 'PropertyName PathExpression/Name Key': tags.propertyName, - 'for if then else some every satisfies between': tags.controlKeyword, - 'in return instance of and or': tags.operatorKeyword, - 'function': tags.definitionKeyword, - 'FormalParameter/Type!': tags.typeName, - 'as': tags.keyword, - 'Wildcard': tags.special, - 'null': tags.null, - ',': tags.separator, + function last(arr) { + return arr[arr.length - 1]; + } + + const feelHighlighting = styleTags({ + StringLiteral: tags.string, + NumericLiteral: tags.number, + BooleanLiteral: tags.bool, + 'AtLiteral!': tags.special(tags.string), + CompareOp: tags.compareOperator, + ArithOp: tags.arithmeticOperator, + 'for if then else some every satisfies between return': tags.controlKeyword, + 'in instance of and or': tags.operatorKeyword, + function: tags.definitionKeyword, + as: tags.keyword, + 'Type/...': tags.typeName, + Wildcard: tags.special, + null: tags.null, + LineComment: tags.lineComment, + BlockComment: tags.blockComment, + 'VariableName! "?"': tags.variableName, + 'DateTimeConstructor! SpecialFunctionName!': tags.function(tags.special(tags.variableName)), + 'List Interval': tags.list, + Context: tags.definition(tags.literal), + 'Name!': tags.definition(tags.variableName), + 'Key/Name! ContextEntryType/Name!': tags.definition(tags.propertyName), + 'PathExpression/VariableName!': tags.function(tags.propertyName), + 'FormalParameter/ParameterName!': tags.function(tags.definition(tags.variableName)), + '( )': tags.paren, '[ ]': tags.squareBracket, '{ }': tags.brace, - '( )': tags.paren, - 'LineComment': tags.lineComment, - 'BlockComment': tags.blockComment, - 'ParameterName VariableName ?': tags.variableName, - 'DateTimeConstructor! SpecialFunctionName BuiltInFunctionName': tags.function(tags.special(tags.variableName)), - 'FunctionInvocation/VariableName': tags.function(tags.variableName), - 'List Interval': tags.list, - 'BuiltInType ListType ContextType FunctionType': tags.function(tags.typeName), - 'Context': tags.definition(tags.literal), - 'ContextEntry/Key': tags.variableName, - 'InExpression/Name': tags.local(tags.variableName), - 'ParameterName/Name': tags.local(tags.variableName), - 'IterationContext/".." Interval/".." "."': tags.punctuation + '.': tags.derefOperator, + ', ;': tags.separator, + '..': tags.punctuation }); // This file was generated by lezer-generator. You probably shouldn't edit it. - const spec_identifier$1 = {__proto__:null,for:10, in:30, return:34, if:38, then:40, else:42, some:46, every:48, satisfies:55, or:58, and:62, between:70, instance:86, of:89, days:99, time:101, duration:103, years:105, months:107, date:109, list:115, context:121, function:128, string:147, length:149, upper:151, case:153, lower:155, substring:157, before:159, after:161, starts:163, with:165, ends:167, contains:169, insert:171, index:173, distinct:175, values:177, met:179, by:181, overlaps:183, finished:185, started:187, day:189, year:191, week:193, month:195, get:197, value:199, entries:201, null:210, true:380, false:380, "?":224, external:240, not:263}; - const parser$2 = LRParser.deserialize({ + const spec_identifier = {__proto__:null,for:10, in:32, return:36, if:40, then:42, else:44, some:48, every:50, satisfies:57, or:60, and:64, between:72, instance:86, of:89, days:99, time:101, duration:103, years:105, months:107, date:109, list:115, context:121, function:128, null:154, true:326, false:326, "?":168, external:184, not:209}; + const parser$1 = LRParser.deserialize({ version: 14, - states: "!&nO`QYOOO&wQYOOOOQU'#Ce'#CeO'RQYO'#C`O([Q^O'#FlOOQQ'#GQ'#GQO*|QYO'#GQO`QYO'#DUOOQU'#FZ'#FZO-rQ^O'#D]OOQO'#GX'#GXO1yQWO'#DuOOQU'#Ej'#EjOOQU'#Ek'#EkOOQU'#El'#ElO2OOWO'#EoO1yQWO'#EmOOQU'#Em'#EmOOQU'#G_'#G_OOQU'#G]'#G]O2TQYO'#ErO`QYO'#EsO2uQYO'#EtO2TQYO'#EqOOQU'#Eq'#EqOOQU'#Fn'#FnO4ZQ^O'#FnO6uQWO'#EuOOQP'#Gh'#GhO6zQXO'#E|OOQU'#Ge'#GeOOQU'#Fm'#FmOOQQ'#FU'#FUQ`QYOOOOQQ'#Fo'#FoOOQQ'#Fx'#FxO`QYO'#CnOOQQ'#Fy'#FyO'RQYO'#CrO7VQYO'#DvO7[QYO'#DvO7aQYO'#DvO7fQYO'#DvO7nQYO'#DvO7sQYO'#DvO7xQYO'#DvO7}QYO'#DvO8SQYO'#DvO8XQYO'#DvO8^QYO'#DvO8cQYO'#DvO8hQYO'#DvOOQU'#G^'#G^O8pQYO'#EnOOQO'#En'#EnOOQO'#Gf'#GfO:SQYO'#DQO:jQWO'#F|OOQO'#DS'#DSO:uQYO'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x'z(Q(R(S(T(U(V(W(X(Y(`(b(c(h(i(l(m(s(t(u(v(w(x(y(z)Q)S)T)X)Y)[)c)iQ!{ZR!}`R$[!zQ#WfR$]!z$ocOPVefqt!f!j!k!l!p!r!s!t!u!z#n#p#t#x$T$c$l$p$q$t%S%_%k%v&Y&Z'O'P'Q'R'S'T'U'V'^'_'a'b'i'j'm't'v'x'z(Q(R(S(T(U(V(W(X(Y(`(b(c(h(i(l(m(s(t(u(v(w(x(y(z)Q)S)T)X)Y)[)c)i$hcOPVqt!f!j!k!l!p!r!s!t!u!z#n#p#t#x$c$l$p$q$t%S%_%k%v&Y&Z'O'P'Q'R'S'T'U'V'^'_'a'b'i'j'm't'v'x'z(Q(R(S(T(U(V(W(X(Y(`(b(c(h(i(l(m(s(t(u(v(w(x(y(z)Q)S)T)X)Y)[)c)iU#Qdg$aV#Uef$TW#Rdef$TQ#XgR%e$apkOVq!f!j!k!l!r!s!u#x$t%S%k&Y&Z!j(PPeft!p!t!z#n#p#t$T$c$l$q%_%v'O'P'Q'R'S'T'U'V'_'a'b'i'j'm'x'z(Q(l)c)ip)e'^'v(s(t(u(v(w(x(y(z)Q)S)T)X)Y)[q)k$p't(R(S(T(U(V(W(X(Y(`(b(c(h(i(mX$h#Z'{)d)j$omOPVefqt!f!j!k!l!p!r!s!t!u!z#n#p#t#x$T$c$l$p$q$t%S%_%k%v&Y&Z'O'P'Q'R'S'T'U'V'^'_'a'b'i'j'm't'v'x'z(Q(R(S(T(U(V(W(X(Y(`(b(c(h(i(l(m(s(t(u(v(w(x(y(z)Q)S)T)X)Y)[)c)iR#am", - nodeNames: "⚠ LineComment BlockComment Expressions ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression ArithOp InstanceOfExpression instance of Type QualifiedName VariableName SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName string length upper case lower substring before after starts with ends contains insert index distinct values met by overlaps finished started day year week month get value entries NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier UnaryTests Wildcard not", - maxTerm: 198, - context: variableTracker$1, + states: "DSO`QYOOO`QYOOO$gQYOOOOQU'#Ce'#CeO$qQYO'#C`O%zQYO'#FPOOQQ'#Fe'#FeO&UQYO'#FeO`QYO'#DVOOQU'#Em'#EmO'rQ^O'#D]OOQO'#Fl'#FlO)oQWO'#DuOOQQ'#D|'#D|OOQQ'#D}'#D}OOQQ'#EO'#EOO)tOWO'#ERO)oQWO'#EPOOQQ'#EP'#EPOOQQ'#Fr'#FrOOQQ'#Fp'#FpOOQQ'#Fw'#FwO,iQYO'#FwO.gQYO'#FwOOQQ'#ET'#ETO`QYO'#EVOOQQ'#FR'#FRO0cQ^O'#FRO2YQYO'#EWO2aQWO'#EXOOQP'#GQ'#GQO2fQXO'#E`OOQQ'#F{'#F{OOQQ'#FQ'#FQQOQWOOOOQQ'#FS'#FSOOQQ'#F]'#F]O`QYO'#CoOOQQ'#F^'#F^O$qQYO'#CsO2qQYO'#DvOOQQ'#Fq'#FqO2vQYO'#EQOOQO'#EQ'#EQO`QYO'#EUO`QYO'#ETOOQO'#GO'#GOQ3OQWOOO3TQYO'#DRO3zQWO'#FaOOQO'#DT'#DTO4VQYO'#FeO4^QWOOO5TQYO'#CdO5bQYO'#FUOOQQ'#Cc'#CcO5gQYO'#FTOOQQ'#Cb'#CbO5oQYO,58zO`QYO,59iOOQQ'#Fb'#FbOOQQ'#Fc'#FcOOQQ'#Fd'#FdO`QYO,59qO`QY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u%|&_!m[OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xQ!q[R!saR#y!pQ!wlR#z!p!mdOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%x!m|OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xR%{%c!miOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xR#}!t!mlOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xR$R!w!mmOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xR$U!x!moOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Z#]#_#c#g#r$O$Y$^$_$b$e$r$}%W%d%w%xR#Oo", + nodeNames: "⚠ LineComment BlockComment Expression ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression InstanceOfExpression instance of Type QualifiedName VariableName SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier Expressions UnaryTests Wildcard not", + maxTerm: 176, + context: variableTracker, nodeProps: [ - ["group", -17,4,18,22,28,30,32,40,42,67,69,71,112,113,115,116,117,124,"Expression",47,"Expression Expression",-5,105,106,107,108,109,"Expression Literal"], - ["closedBy", 37,")",70,"]",123,"}"], - ["openedBy", 39,"(",68,"[",122,"{"] + ["closedBy", 38,")",70,"]",95,"}"], + ["openedBy", 40,"(",68,"[",94,"{"], + ["group", -5,77,78,79,80,81,"Literal"] ], - propSources: [feelHighlighting$1], + propSources: [feelHighlighting], skippedNodes: [0,1,2], repeatNodeCount: 14, - tokenData: ")x~RuXY#fYZ$ZZ[#f]^$Zpq#fqr$`rs$kwx%_xy%dyz%iz{%n{|%{|}&Q}!O&V!O!P&d!P!Q&|!Q![(X![!](j!]!^(o!^!_(t!_!`$f!`!a)T!b!c)_!}#O)d#P#Q)i#Q#R%v#o#p)n#q#r)s$f$g#f#BY#BZ#f$IS$I_#f$I|$I}$Z$I}$JO$Z$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~#kY$^~XY#fZ[#fpq#f$f$g#f#BY#BZ#f$IS$I_#f$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~$`O$_~~$cP!_!`$f~$kOq~~$pU%T~OY$kZr$krs%Ss#O$k#O#P%X#P~$k~%XO%T~~%[PO~$k~%dO$g~~%iOu~~%nOw~~%sP^~z{%v~%{Oy~~&QO[~~&VO$j~R&[PZP!`!a&_Q&dO$xQ~&iQ$f~!O!P&o!Q![&t~&tO$i~~&yP%S~!Q![&t~'RQ]~z{'X!P!Q'|~'[ROz'Xz{'e{~'X~'hTOz'Xz{'e{!P'X!P!Q'w!Q~'X~'|OQ~~(RQP~OY'|Z~'|~(^Q%S~!O!P(d!Q![(X~(gP!Q![&t~(oO$v~~(tO%^~R({P![QrP!_!`)OP)TOrPR)[P!XQrP!_!`)O~)dO%V~~)iO!h~~)nO!f~~)sO#o~~)xO#n~", - tokenizers: [propertyIdentifiers$1, identifiers$1, insertSemicolon$1, 0, 1], - topRules: {"Expressions":[0,3],"UnaryTests":[1,129]}, - dynamicPrecedences: {"30":-1,"71":-1,"101":-1,"154":-1}, - specialized: [{term: 148, get: value => spec_identifier$1[value] || -1}], - tokenPrec: 0 + tokenData: "+l~RuXY#fYZ$ZZ[#f]^$Zpq#fqr$`rs$kwx&cxy&hyz&mz{&r{|'P|}'U}!O'Z!O!P'h!P!Q(Q!Q![){![!]*^!]!^*c!^!_*h!_!`$f!`!a*w!b!c+R!}#O+W#P#Q+]#Q#R&z#o#p+b#q#r+g$f$g#f#BY#BZ#f$IS$I_#f$I|$I}$Z$I}$JO$Z$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~#kY#q~XY#fZ[#fpq#f$f$g#f#BY#BZ#f$IS$I_#f$JT$JU#f$KV$KW#f&FU&FV#f?HT?HU#f~$`O#r~~$cP!_!`$f~$kOr~~$pW$h~OY$kZr$krs%Ys#O$k#O#P%_#P;'S$k;'S;=`&]<%lO$k~%_O$h~~%bRO;'S$k;'S;=`%k;=`O$k~%pX$h~OY$kZr$krs%Ys#O$k#O#P%_#P;'S$k;'S;=`&];=`<%l$k<%lO$k~&`P;=`<%l$k~&hO#z~~&mOv~~&rOx~~&wP^~z{&z~'PO_~~'UO[~~'ZO#}~R'`PZP!`!a'cQ'hO$]Q~'mQ#y~!O!P's!Q!['x~'xO#|~~'}P$g~!Q!['x~(VQ]~z{(]!P!Q)d~(`TOz(]z{(o{;'S(];'S;=`)^<%lO(]~(rVOz(]z{(o{!P(]!P!Q)X!Q;'S(];'S;=`)^<%lO(]~)^OQ~~)aP;=`<%l(]~)iSP~OY)dZ;'S)d;'S;=`)u<%lO)d~)xP;=`<%l)d~*QQ$g~!O!P*W!Q![){~*ZP!Q!['x~*cO$Z~~*hO$v~R*oP![QsP!_!`*rP*wOsPR+OP!XQsP!_!`*r~+WO$j~~+]O!h~~+bO!f~~+gO#R~~+lO#Q~", + tokenizers: [propertyIdentifiers, identifiers, insertSemicolon, 0, 1], + topRules: {"Expression":[0,3],"Expressions":[1,101],"UnaryTests":[2,102]}, + dynamicPrecedences: {"31":-1,"71":-1,"73":-1}, + specialized: [{term: 121, get: value => spec_identifier[value] || -1}], + tokenPrec: 2857 }); - function parseParameterNames$1(fn) { - if (Array.isArray(fn.$args)) { - return fn.$args; - } - const code = fn.toString(); - const match = /^(?:[^(]*\s*)?\(([^)]+)?\)/.exec(code); - if (!match) { - throw new Error('failed to parse params: ' + code); - } - const [_, params] = match; - if (!params) { - return []; - } - return params.split(',').map(p => p.trim()); - } - function notImplemented$1(thing) { - return new Error(`not implemented: ${thing}`); - } - /** - * @param {string} name - * @param {Record} context - * - * @return {any} - */ - function getFromContext$1(name, context) { - if (['nil', 'boolean', 'number', 'string'].includes(getType$1(context))) { - return null; - } - if (name in context) { - return context[name]; - } - const normalizedName = normalizeContextKey$1(name); - if (normalizedName in context) { - return context[normalizedName]; - } - const entry = Object.entries(context).find(([key]) => normalizedName === normalizeContextKey$1(key)); - if (entry) { - return entry[1]; - } - return null; + function isContext(e) { + return Object.getPrototypeOf(e) === Object.prototype; } - - function isDateTime$1(obj) { + function isDateTime(obj) { return DateTime.isDateTime(obj); } - function isDuration$1(obj) { + function isDuration(obj) { return Duration.isDuration(obj); } - function duration$2(opts) { - if (typeof opts === 'number') { - return Duration.fromMillis(opts); - } - return Duration.fromISO(opts); - } - function date$1(str = null, time = null, zone = null) { - if (time) { - if (str) { - throw new Error(' and