@sheetxl/sdk 0.7.28-beta.2 → 0.7.28-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/cjs/{BREMLtxkQhtNSVra.cjs → BF14ZEAnaqxXroSj.cjs} +1 -1
- package/browser/cjs/{BG7YDVxiC4ErxvF1.cjs → BXtvdT1Z-MsB_o5F.cjs} +1 -1
- package/browser/cjs/Bc4JjVVZfFo3R4He.cjs +33 -0
- package/browser/cjs/{CQf4zxkBmheTVbjX.cjs → CD2RXdnfqSYNc6gX.cjs} +2 -2
- package/browser/cjs/DcLpXGexEtOxi-dD.cjs +1 -0
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/{DN4d5bDBkti28wuc.mjs → 0Mj5WKM362q6CECb.mjs} +213 -207
- package/browser/esm/{BxIOX1TojvA-1ZZP.mjs → CHSahmMFYNB0Ajkf.mjs} +2 -2
- package/browser/esm/{CZO1RubmqnJV96rq.mjs → CKk58ZLcrllMzfou.mjs} +2 -2
- package/browser/esm/{DRWu3TmcE9JFf78V.mjs → CPTtL2f6_4iblmFM.mjs} +2 -2
- package/browser/esm/{DPOelA1J3WHbMXyh.mjs → CoA-sUxjiIUIpTUF.mjs} +2 -2
- package/browser/esm/{vHWuKF-ftK7LM1uw.mjs → DBIu6NUHIcxOOBQp.mjs} +1 -1
- package/browser/esm/{CB_4gdPPPruwremH.mjs → Dy4Sdpju1T2icURu.mjs} +4748 -3883
- package/browser/esm/index.mjs +419 -411
- package/node/esm/{XQhP3dYwF_tEuswB.mjs → BtGxbEbBm79YvF_k.mjs} +303 -297
- package/node/esm/{B-tgcZihStNV9CbZ.mjs → DUYP6faJJHCaW1Xf.mjs} +1 -1
- package/node/esm/{C8tfYGL3wHy9IDDc.mjs → DqgWsVXROpSgKq6c.mjs} +2 -2
- package/node/esm/index.mjs +8686 -7802
- package/package.json +6 -6
- package/resources/locales/de/model.msg.json +12 -0
- package/resources/locales/en/model.msg.json +12 -0
- package/types/scripting-enums.json +2 -0
- package/types/scripting.d.ts +341 -15
- package/types/src/anchored/IAnchored.d.ts +27 -0
- package/types/src/calculation/Calculation.d.ts +21 -12
- package/types/src/calculation/ICalculation.d.ts +183 -0
- package/types/src/calculation/compiler/CompilerUtils.d.ts +20 -0
- package/types/src/calculation/compiler/FormulaParser.d.ts +32 -6
- package/types/src/calculation/executor/CalcExecutor.d.ts +204 -13
- package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
- package/types/src/calculation/executor/CircularReference.d.ts +81 -0
- package/types/src/calculation/functions/Operators.d.ts +1 -1
- package/types/src/calculation/grid/CalcGrid.d.ts +5 -1
- package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
- package/types/src/calculation/grid/ICalcGrid.d.ts +23 -1
- package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
- package/types/src/calculation/spatial/index.d.ts +1 -0
- package/types/src/calculation/state/CalcNode.d.ts +24 -17
- package/types/src/calculation/state/CalcState.d.ts +78 -15
- package/types/src/calculation/state/CalculationContext.d.ts +39 -0
- package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
- package/types/src/cell/ICell.d.ts +16 -0
- package/types/src/cellRange/ICellRange.d.ts +72 -6
- package/types/src/condition/AnchoredConditional.d.ts +26 -6
- package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
- package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
- package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
- package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
- package/types/src/hyperlink/IHyperlink.d.ts +3 -1
- package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
- package/types/src/lib/utils/utils.browser.d.ts +5 -0
- package/types/src/license/LicenseDetails.d.ts +5 -0
- package/types/src/primitives/CalcSignal.d.ts +20 -0
- package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
- package/types/src/scripting/_ScriptUtils.d.ts +13 -0
- package/types/src/sheet/Sheet.d.ts +33 -2
- package/types/src/sheet/SheetCell.d.ts +2 -0
- package/types/src/sheet/SheetRange.d.ts +12 -1
- package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
- package/types/src/style/IStyle.d.ts +5 -0
- package/types/src/table/AnchoredTable.d.ts +17 -1
- package/types/src/text/TextUtils.d.ts +18 -0
- package/browser/cjs/DoemwsUQoGCk0vBK.cjs +0 -33
- package/browser/cjs/_c2uwwpr03Y7lzIj.cjs +0 -1
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.
|
|
2
|
+
* @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.7.28-beta.4
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
6
|
*/
|
|
7
|
-
import { A as e, B as t, C as s, D as i, E as r, F as n,
|
|
7
|
+
import { A as e, B as t, C as s, D as i, E as r, F as n, H as o, I as a, ICalculation as h, L as l, M as u, N as c, O as p, P as g, R as O, S as _, T as m, V as E, _ as L, a as A, b as T, c as f, d as U, f as d, g as N, h as C, i as S, j as x, k as I, l as R, m as M, n as P, o as v, p as y, r as b, s as k, t as w, u as B, v as $, w as F, x as G, y as D, z as Y } from "./index.mjs";
|
|
8
8
|
import { FormulaError as z } from "@sheetxl/primitives";
|
|
9
|
-
import { CommonUtils as
|
|
10
|
-
import { EOF as
|
|
11
|
-
var
|
|
9
|
+
import { CommonUtils as V } from "@sheetxl/utils";
|
|
10
|
+
import { EOF as W, EmbeddedActionsParser as j, Lexer as q, createToken as H, defaultParserErrorProvider as X } from "chevrotain";
|
|
11
|
+
var Q = [
|
|
12
12
|
"All",
|
|
13
13
|
"Data",
|
|
14
14
|
"Headers",
|
|
15
15
|
"Totals",
|
|
16
16
|
"This Row"
|
|
17
17
|
];
|
|
18
|
-
var
|
|
19
|
-
constructor(e =
|
|
18
|
+
var Z = class {
|
|
19
|
+
constructor(e = o) {
|
|
20
20
|
const t = function(e) {
|
|
21
|
-
const t = [...
|
|
21
|
+
const t = [...Q];
|
|
22
22
|
if (e) for (const s of Object.values(e)) {
|
|
23
23
|
const e = s?.trim();
|
|
24
24
|
e && !t.some((t) => t.toLowerCase() === e.toLowerCase()) && t.push(e);
|
|
25
25
|
}
|
|
26
26
|
return t.sort((e, t) => t.length - e.length), t.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
27
|
-
}(e.specifiers), s =
|
|
27
|
+
}(e.specifiers), s = H({
|
|
28
28
|
name: "WhiteSpace",
|
|
29
29
|
pattern: /\s+/,
|
|
30
|
-
group:
|
|
31
|
-
}), i =
|
|
30
|
+
group: q.SKIPPED
|
|
31
|
+
}), i = H({
|
|
32
32
|
name: "TableSpecifier",
|
|
33
33
|
pattern: new RegExp(`\\[#(?:${t})\\]`, "i")
|
|
34
34
|
}), r = [
|
|
35
35
|
s,
|
|
36
36
|
i,
|
|
37
|
-
|
|
37
|
+
H({
|
|
38
38
|
name: "BracketedColumn",
|
|
39
39
|
pattern: /\[([^[\]]*)\]/,
|
|
40
40
|
longer_alt: [i]
|
|
41
41
|
}),
|
|
42
|
-
|
|
42
|
+
H({
|
|
43
43
|
name: "BareSpecifier",
|
|
44
44
|
pattern: new RegExp(`#(?:${t})`, "i")
|
|
45
45
|
}),
|
|
46
|
-
|
|
46
|
+
H({
|
|
47
47
|
name: "ColumnSep",
|
|
48
48
|
pattern: /:/
|
|
49
49
|
}),
|
|
50
|
-
|
|
50
|
+
H({
|
|
51
51
|
name: "ListSep",
|
|
52
52
|
pattern: new RegExp(e.separators.separatorFunction.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
53
53
|
})
|
|
54
54
|
];
|
|
55
|
-
this._lexer = new
|
|
55
|
+
this._lexer = new q(r, { ensureOptimizations: !0 });
|
|
56
56
|
const n = {};
|
|
57
57
|
r.forEach((e) => {
|
|
58
58
|
n[e.name] = e;
|
|
@@ -64,116 +64,116 @@ var Q = class {
|
|
|
64
64
|
tokenize(e) {
|
|
65
65
|
return this._lexer.tokenize(e);
|
|
66
66
|
}
|
|
67
|
-
},
|
|
68
|
-
constructor(e =
|
|
69
|
-
const t = new
|
|
70
|
-
super(
|
|
67
|
+
}, K = class extends j {
|
|
68
|
+
constructor(e = o) {
|
|
69
|
+
const t = new Z(e), i = t.getVocabulary();
|
|
70
|
+
super(i, {
|
|
71
71
|
nodeLocationTracking: "none",
|
|
72
72
|
maxLookahead: 2,
|
|
73
73
|
skipValidations: !0,
|
|
74
74
|
recoveryEnabled: !1
|
|
75
75
|
}), this._lexer = t;
|
|
76
|
-
const { TableSpecifier:
|
|
77
|
-
|
|
78
|
-
const e = [], t =
|
|
79
|
-
return
|
|
76
|
+
const { TableSpecifier: r, BracketedColumn: a, BareSpecifier: h, ColumnSep: u, ListSep: c } = i, p = this;
|
|
77
|
+
p.RULE("ruleContent", () => {
|
|
78
|
+
const e = [], t = p.SUBRULE(p.ruleItem);
|
|
79
|
+
return p.ACTION(() => {
|
|
80
80
|
t && e.push(t);
|
|
81
|
-
}),
|
|
82
|
-
|
|
83
|
-
const t =
|
|
84
|
-
|
|
81
|
+
}), p.MANY(() => {
|
|
82
|
+
p.CONSUME(c), p.OPTION(() => {
|
|
83
|
+
const t = p.SUBRULE2(p.ruleItem);
|
|
84
|
+
p.ACTION(() => {
|
|
85
85
|
t && e.push(t);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
}), e;
|
|
89
|
-
}),
|
|
90
|
-
const t =
|
|
91
|
-
return
|
|
92
|
-
const s =
|
|
89
|
+
}), p.RULE("ruleItem", () => p.OR([{ ALT: () => p.SUBRULE(p.ruleSpecifier) }, { ALT: () => p.SUBRULE(p.ruleColumnOrRange) }])), p.RULE("ruleSpecifier", () => p.OR([{ ALT: () => {
|
|
90
|
+
const t = p.CONSUME(r);
|
|
91
|
+
return p.ACTION(() => {
|
|
92
|
+
const s = l(t.image, e);
|
|
93
93
|
return s.image = t.image, s;
|
|
94
94
|
});
|
|
95
95
|
} }, { ALT: () => {
|
|
96
|
-
const t =
|
|
97
|
-
return
|
|
98
|
-
const s =
|
|
96
|
+
const t = p.CONSUME(h);
|
|
97
|
+
return p.ACTION(() => {
|
|
98
|
+
const s = l(t.image, e);
|
|
99
99
|
return s.image = t.image, s;
|
|
100
100
|
});
|
|
101
|
-
} }])),
|
|
102
|
-
const e =
|
|
103
|
-
let t,
|
|
104
|
-
return
|
|
105
|
-
t =
|
|
106
|
-
}),
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
return
|
|
101
|
+
} }])), p.RULE("ruleColumnOrRange", () => {
|
|
102
|
+
const e = p.CONSUME(a);
|
|
103
|
+
let t, i;
|
|
104
|
+
return p.OPTION(() => {
|
|
105
|
+
t = p.CONSUME(u), i = p.CONSUME2(a);
|
|
106
|
+
}), p.ACTION(() => {
|
|
107
|
+
const r = n(e.image);
|
|
108
|
+
if (r.image = e.image, !i) return r;
|
|
109
|
+
const o = n(i.image);
|
|
110
|
+
o.image = i.image;
|
|
111
|
+
const a = s(":", r, o, !0);
|
|
112
|
+
return a.image = t?.image ?? ":", a;
|
|
113
113
|
});
|
|
114
|
-
}),
|
|
114
|
+
}), p.performSelfAnalysis();
|
|
115
115
|
}
|
|
116
116
|
_parseInner(e) {
|
|
117
117
|
const t = this._lexer.tokenize(e);
|
|
118
118
|
return t.errors.length > 0 || 0 === t.tokens.length ? [] : (this.input = t.tokens, this.reset(), this.ruleContent() ?? []);
|
|
119
119
|
}
|
|
120
|
-
_parseContent(
|
|
121
|
-
if (!e) return [];
|
|
122
|
-
const t = e.trim();
|
|
120
|
+
_parseContent(t) {
|
|
123
121
|
if (!t) return [];
|
|
124
|
-
const s = t
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
const s = t.trim();
|
|
123
|
+
if (!s) return [];
|
|
124
|
+
const i = s[0];
|
|
125
|
+
if ("@" === i) {
|
|
126
|
+
const t = s.slice(1).trim();
|
|
127
|
+
if (!t) {
|
|
128
|
+
const t = e("@", null, !0);
|
|
129
|
+
return t.image = "@", [t];
|
|
130
130
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
return
|
|
131
|
+
const i = n(t);
|
|
132
|
+
i.image = t;
|
|
133
|
+
const r = e("@", i, !0);
|
|
134
|
+
return r.image = "@", [r];
|
|
135
135
|
}
|
|
136
|
-
if ("[" !==
|
|
137
|
-
const
|
|
138
|
-
return
|
|
136
|
+
if ("[" !== i && "#" !== i) {
|
|
137
|
+
const e = n(t);
|
|
138
|
+
return e.image = t, [e];
|
|
139
139
|
}
|
|
140
|
-
return this._parseInner(
|
|
140
|
+
return this._parseInner(s);
|
|
141
141
|
}
|
|
142
142
|
parse(e, t, s) {
|
|
143
143
|
const i = () => ({
|
|
144
|
-
root:
|
|
144
|
+
root: a("", []),
|
|
145
145
|
errors: []
|
|
146
146
|
});
|
|
147
147
|
if (!s) return i();
|
|
148
148
|
const r = s.indexOf("[");
|
|
149
149
|
if (-1 === r) return i();
|
|
150
|
-
const
|
|
150
|
+
const n = s.slice(0, r), o = s.slice(r + 1, -1);
|
|
151
151
|
return {
|
|
152
|
-
root: n
|
|
152
|
+
root: a(n, this._parseContent(o)),
|
|
153
153
|
errors: this.errors.length > 0 ? [...this.errors] : []
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
},
|
|
156
|
+
}, J = /* @__PURE__ */ new Set([
|
|
157
157
|
":",
|
|
158
158
|
".:.",
|
|
159
159
|
".:",
|
|
160
160
|
":."
|
|
161
|
-
]),
|
|
161
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
162
162
|
".:.",
|
|
163
163
|
".:",
|
|
164
164
|
":."
|
|
165
|
-
]),
|
|
165
|
+
]), te = (e) => {
|
|
166
166
|
if (!e) return null;
|
|
167
|
-
if (e.type ===
|
|
167
|
+
if (e.type === t.Cell) {
|
|
168
168
|
const t = e.value;
|
|
169
169
|
return t.rowIndex === Number.MIN_SAFE_INTEGER ? "col" : t.colIndex === Number.MIN_SAFE_INTEGER ? "row" : null;
|
|
170
170
|
}
|
|
171
171
|
return Number.isInteger(e.value) ? "row" : null;
|
|
172
|
-
},
|
|
172
|
+
}, se = (e, t) => {
|
|
173
173
|
const s = parseInt(36 === e.charCodeAt(0) ? e.substring(1) : e, 10);
|
|
174
174
|
return s >= 1 && s <= t;
|
|
175
|
-
},
|
|
176
|
-
function
|
|
175
|
+
}, ie = "A formula must not be empty";
|
|
176
|
+
function re(e, t) {
|
|
177
177
|
const s = e?.[0]?.image;
|
|
178
178
|
if (!s) {
|
|
179
179
|
const e = t?.image;
|
|
@@ -181,48 +181,48 @@ function ie(e, t) {
|
|
|
181
181
|
}
|
|
182
182
|
return `Unexpected '${s}'`;
|
|
183
183
|
}
|
|
184
|
-
var
|
|
185
|
-
...
|
|
186
|
-
buildNoViableAltMessage: (e) =>
|
|
187
|
-
buildEarlyExitMessage: (e) =>
|
|
184
|
+
var ne = {
|
|
185
|
+
...X,
|
|
186
|
+
buildNoViableAltMessage: (e) => re(e.actual, e.previous),
|
|
187
|
+
buildEarlyExitMessage: (e) => re(e.actual, e.previous),
|
|
188
188
|
buildNotAllInputParsedMessage: (e) => {
|
|
189
189
|
const t = e.firstRedundant?.image;
|
|
190
|
-
return t ? `Unexpected '${t}'` :
|
|
190
|
+
return t ? `Unexpected '${t}'` : X.buildNotAllInputParsedMessage(e);
|
|
191
191
|
},
|
|
192
192
|
buildMismatchTokenMessage: (e) => {
|
|
193
193
|
const t = e.actual?.image;
|
|
194
|
-
return e.expected ===
|
|
194
|
+
return e.expected === W && t ? `Unexpected '${t}'` : X.buildMismatchTokenMessage(e);
|
|
195
195
|
}
|
|
196
|
-
},
|
|
196
|
+
}, oe = class extends j {
|
|
197
197
|
constructor(n) {
|
|
198
|
-
const o = n?.lexer ??
|
|
198
|
+
const o = n?.lexer ?? E.shared(n?.lexerOptions), a = o.getVocabulary();
|
|
199
199
|
super(a, {
|
|
200
200
|
skipValidations: !0,
|
|
201
201
|
recoveryEnabled: !0,
|
|
202
202
|
...n,
|
|
203
203
|
nodeLocationTracking: "full",
|
|
204
|
-
errorMessageProvider:
|
|
204
|
+
errorMessageProvider: ne,
|
|
205
205
|
maxLookahead: 1
|
|
206
206
|
}), this._ruleInfixOp = this.RULE("ruleInfixOp", () => {
|
|
207
|
-
const { PlusOp: e, MinOp: t, MulOp:
|
|
207
|
+
const { PlusOp: e, MinOp: t, MulOp: i, DivOp: r, ExOp: n, ConcatOp: o, GtOp: a, EqOp: h, LtOp: l, NeqOp: u, GteOp: c, LteOp: p } = this._vocab, g = [];
|
|
208
208
|
return g.push({ node: this.SUBRULE(this._rulePostfixOp) }), this.MANY(() => {
|
|
209
|
-
const
|
|
209
|
+
const s = this.OR(this._c1 || (this._c1 = [
|
|
210
210
|
{ ALT: () => this.CONSUME(e).image },
|
|
211
211
|
{ ALT: () => this.CONSUME(t).image },
|
|
212
|
-
{ ALT: () => this.CONSUME(s).image },
|
|
213
212
|
{ ALT: () => this.CONSUME(i).image },
|
|
214
213
|
{ ALT: () => this.CONSUME(r).image },
|
|
215
214
|
{ ALT: () => this.CONSUME(n).image },
|
|
216
215
|
{ ALT: () => this.CONSUME(o).image },
|
|
217
216
|
{ ALT: () => this.CONSUME(a).image },
|
|
217
|
+
{ ALT: () => this.CONSUME(h).image },
|
|
218
218
|
{ ALT: () => this.CONSUME(l).image },
|
|
219
219
|
{ ALT: () => this.CONSUME(u).image },
|
|
220
220
|
{ ALT: () => this.CONSUME(c).image },
|
|
221
221
|
{ ALT: () => this.CONSUME(p).image }
|
|
222
222
|
])), _ = {
|
|
223
|
-
value:
|
|
223
|
+
value: s,
|
|
224
224
|
index: this.getLexerPosition(),
|
|
225
|
-
isRange:
|
|
225
|
+
isRange: O.includes(s)
|
|
226
226
|
}, m = this.SUBRULE2(this._rulePostfixOp);
|
|
227
227
|
g.push({
|
|
228
228
|
op: _,
|
|
@@ -230,17 +230,17 @@ var re = {
|
|
|
230
230
|
});
|
|
231
231
|
}), this.ACTION(() => {
|
|
232
232
|
let e = g.length - 1;
|
|
233
|
-
const t =
|
|
234
|
-
for (let
|
|
235
|
-
const t =
|
|
236
|
-
let
|
|
237
|
-
for (;
|
|
238
|
-
const
|
|
239
|
-
if (t.includes(
|
|
240
|
-
const t = g[
|
|
241
|
-
let
|
|
242
|
-
|
|
243
|
-
} else
|
|
233
|
+
const t = C.length;
|
|
234
|
+
for (let i = 0; e > 0 && i < t; i++) {
|
|
235
|
+
const t = C[i];
|
|
236
|
+
let r = 1;
|
|
237
|
+
for (; r < g.length;) {
|
|
238
|
+
const i = g[r].op;
|
|
239
|
+
if (t.includes(i.value)) {
|
|
240
|
+
const t = g[r - 1].node, n = g[r].node;
|
|
241
|
+
let o = s(i.value, t, n, i.isRange);
|
|
242
|
+
o = this._tag(o, i.index), g[r - 1].node = o, g.splice(r, 1), e--;
|
|
243
|
+
} else r++;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}), g[0].node;
|
|
@@ -248,64 +248,73 @@ var re = {
|
|
|
248
248
|
const { PlusOp: e, MinOp: t } = this._vocab;
|
|
249
249
|
return this.OR([{ ALT: () => this.CONSUME(e) }, { ALT: () => this.CONSUME(t) }]);
|
|
250
250
|
}), this._rulePostfixOp = this.RULE("rulePostfixOp", () => {
|
|
251
|
-
const { PercentOp: e
|
|
252
|
-
let
|
|
253
|
-
const
|
|
251
|
+
const { PercentOp: e } = this._vocab;
|
|
252
|
+
let t = this.SUBRULE(this._rulePrefixOp);
|
|
253
|
+
const s = [];
|
|
254
254
|
return this.MANY(() => {
|
|
255
|
-
const
|
|
255
|
+
const t = this.CONSUME(e).image;
|
|
256
256
|
this.ACTION(() => {
|
|
257
|
-
|
|
257
|
+
s.push([t, this.getLexerPosition()]);
|
|
258
258
|
});
|
|
259
259
|
}), this.ACTION(() => {
|
|
260
|
-
const e =
|
|
261
|
-
if (0 !== e) for (let
|
|
262
|
-
const e = i
|
|
263
|
-
|
|
260
|
+
const e = s.length;
|
|
261
|
+
if (0 !== e) for (let i = 0; i < e; i++) {
|
|
262
|
+
const e = s[i], r = e[0], n = e[1], o = O.includes(r);
|
|
263
|
+
t = I(r, t, o), t = this._tag(t, n);
|
|
264
264
|
}
|
|
265
|
-
}),
|
|
265
|
+
}), t;
|
|
266
266
|
}), this._rulePrefixOp = this.RULE("rulePrefixOp", () => {
|
|
267
|
-
const { PlusOp:
|
|
267
|
+
const { PlusOp: t, MinOp: s, ImplicitIntersectOp: i } = this._vocab, r = [];
|
|
268
268
|
this.MANY(() => {
|
|
269
|
-
const
|
|
270
|
-
{ ALT: () => this.CONSUME(e).image },
|
|
269
|
+
const e = this.OR([
|
|
271
270
|
{ ALT: () => this.CONSUME(t).image },
|
|
272
|
-
{ ALT: () => this.CONSUME(s).image }
|
|
271
|
+
{ ALT: () => this.CONSUME(s).image },
|
|
272
|
+
{ ALT: () => this.CONSUME(i).image }
|
|
273
273
|
]);
|
|
274
274
|
this.ACTION(() => {
|
|
275
|
-
|
|
275
|
+
r.push([e, this.getLexerPosition()]);
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
|
-
let
|
|
278
|
+
let n = this.SUBRULE(this._ruleRangeOp);
|
|
279
279
|
return this.ACTION(() => {
|
|
280
|
-
const
|
|
281
|
-
if (0 !==
|
|
282
|
-
const
|
|
283
|
-
|
|
280
|
+
const t = r.length;
|
|
281
|
+
if (0 !== t) for (let s = t - 1; s >= 0; s--) {
|
|
282
|
+
const t = r[s], i = t[0], o = t[1], a = O.includes(i);
|
|
283
|
+
n = e(i, n, a), n = this._tag(n, o);
|
|
284
284
|
}
|
|
285
|
-
}),
|
|
285
|
+
}), n;
|
|
286
286
|
}), this._ruleRangeOp = this.RULE("ruleRangeOp", () => {
|
|
287
|
-
const { RangeOp: e, RangeTrimFullOp: t, RangeTrimLeadingOp:
|
|
288
|
-
return
|
|
289
|
-
|
|
287
|
+
const { RangeOp: e, RangeTrimFullOp: t, RangeTrimLeadingOp: i, RangeTrimTrailingOp: r, ArrayAnchorOp: n } = this._vocab, o = [];
|
|
288
|
+
return o.push({ node: this.SUBRULE(this._ruleCallOp) }), this.MANY2(() => {
|
|
289
|
+
this.CONSUME(n), o.push({ anchor: this.getLexerPosition() });
|
|
290
|
+
}), this.MANY(() => {
|
|
291
|
+
const s = {
|
|
290
292
|
value: this.OR(this._c2 || (this._c2 = [
|
|
291
293
|
{ ALT: () => this.CONSUME(e).image },
|
|
292
294
|
{ ALT: () => this.CONSUME(t).image },
|
|
293
|
-
{ ALT: () => this.CONSUME(
|
|
294
|
-
{ ALT: () => this.CONSUME(
|
|
295
|
+
{ ALT: () => this.CONSUME(i).image },
|
|
296
|
+
{ ALT: () => this.CONSUME(r).image }
|
|
295
297
|
])),
|
|
296
298
|
index: this.getLexerPosition()
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
op:
|
|
300
|
-
node:
|
|
299
|
+
}, a = this.SUBRULE2(this._ruleCallOp);
|
|
300
|
+
o.push({
|
|
301
|
+
op: s,
|
|
302
|
+
node: a
|
|
303
|
+
}), this.MANY3(() => {
|
|
304
|
+
this.CONSUME2(n), o.push({ anchor: this.getLexerPosition() });
|
|
301
305
|
});
|
|
302
306
|
}), this.ACTION(() => {
|
|
303
|
-
for (let e = 1; e <
|
|
304
|
-
const t =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
for (let e = 1; e < o.length; e++) {
|
|
308
|
+
const t = o[e];
|
|
309
|
+
if (void 0 !== t.anchor) {
|
|
310
|
+
o[0].node = this._tag(I("#", o[0].node, !0), t.anchor);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const i = t.op;
|
|
314
|
+
let r = s(i.value, o[0].node, t.node, !0);
|
|
315
|
+
r = this._tag(r, i.index), o[0].node = r;
|
|
307
316
|
}
|
|
308
|
-
}),
|
|
317
|
+
}), o[0].node;
|
|
309
318
|
}), this._ruleCallOp = this.RULE("ruleCallOp", () => {
|
|
310
319
|
const { OpenParen: e, CloseParen: t } = this._vocab;
|
|
311
320
|
let s = this.SUBRULE(this._ruleFormula);
|
|
@@ -316,7 +325,7 @@ var re = {
|
|
|
316
325
|
},
|
|
317
326
|
DEF: () => {
|
|
318
327
|
this.CONSUME(e);
|
|
319
|
-
const i = this.getLexerPosition(), r = this.SUBRULE(this._ruleFunctionArguments), n = s, o = this.ACTION(() => this._tag(
|
|
328
|
+
const i = this.getLexerPosition(), r = this.SUBRULE(this._ruleFunctionArguments), n = s, o = this.ACTION(() => this._tag($(n, r), i)), a = this.OPTION(() => this.CONSUME(t));
|
|
320
329
|
this.ACTION(() => {
|
|
321
330
|
a || this._reportError(o, "Missing closing parenthesis ')'", i), this._tagClose(o, this.getLexerPosition()), s = o;
|
|
322
331
|
});
|
|
@@ -337,15 +346,15 @@ var re = {
|
|
|
337
346
|
}), this.ACTION(() => {
|
|
338
347
|
for (; e.length > 1;) {
|
|
339
348
|
let t = e.length - 1;
|
|
340
|
-
for (let
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (void 0 !==
|
|
345
|
-
const e = this.input[
|
|
346
|
-
s.length > 0 && (
|
|
349
|
+
for (let i = 0; i < t; i++) {
|
|
350
|
+
const r = e[i], n = e[i + 1], o = s(" ", r, n, !0), a = this._tokenMap.get(r);
|
|
351
|
+
a && delete a.tokenIndexClose;
|
|
352
|
+
const h = this._tokenMap.get(n), l = h?.tokenIndex;
|
|
353
|
+
if (void 0 !== l) {
|
|
354
|
+
const e = this.input[l], t = this.input[l - 1]?.endOffset ?? -1, s = this._inputText.slice(t + 1, e.startOffset).slice(0, -1);
|
|
355
|
+
s.length > 0 && (o.wsBefore = s);
|
|
347
356
|
}
|
|
348
|
-
|
|
357
|
+
h && delete h.tokenIndex, i + 1 < t && h && delete h.tokenIndexClose, e.splice(i, 2, o), i--, t--;
|
|
349
358
|
}
|
|
350
359
|
}
|
|
351
360
|
}), e[0];
|
|
@@ -367,82 +376,82 @@ var re = {
|
|
|
367
376
|
});
|
|
368
377
|
}), t;
|
|
369
378
|
}), this._ruleParen = this.RULE("ruleParen", () => {
|
|
370
|
-
const { OpenParen: e, CloseParen:
|
|
371
|
-
return this._processParen(
|
|
379
|
+
const { OpenParen: e, CloseParen: s } = this._vocab;
|
|
380
|
+
return this._processParen(t.Paren, e, s);
|
|
372
381
|
}), this._ruleLiteralArray = this.RULE("ruleLiteralArray", () => {
|
|
373
|
-
const { OpenCurlyParen: e, CloseCurlyParen: t, ColSeparator:
|
|
374
|
-
let n =
|
|
382
|
+
const { OpenCurlyParen: e, CloseCurlyParen: t, ColSeparator: s, RowSeparator: i } = this._vocab;
|
|
383
|
+
let n = r();
|
|
375
384
|
this.CONSUME(e);
|
|
376
385
|
const o = this.getLexerPosition();
|
|
377
|
-
let a = this.ACTION(() => this._tag(
|
|
386
|
+
let a = this.ACTION(() => this._tag(F(n), o));
|
|
378
387
|
const h = this.SUBRULE(this._ruleLiteralForArray);
|
|
379
388
|
this.ACTION(() => {
|
|
380
389
|
n.value.push(h);
|
|
381
390
|
}), this.MANY(() => {
|
|
382
391
|
let e = !1;
|
|
383
392
|
this.OR([{ ALT: () => {
|
|
384
|
-
this.CONSUME(
|
|
385
|
-
} }, { ALT: () => this.CONSUME(
|
|
393
|
+
this.CONSUME(s), e = !0;
|
|
394
|
+
} }, { ALT: () => this.CONSUME(i) }]);
|
|
386
395
|
const t = this.SUBRULE2(this._ruleLiteralForArray);
|
|
387
396
|
this.ACTION(() => {
|
|
388
|
-
e || (n =
|
|
397
|
+
e || (n = r(), a.value.push(n)), n.value.push(t);
|
|
389
398
|
});
|
|
390
399
|
});
|
|
391
400
|
const l = this.OPTION(() => this.CONSUME(t));
|
|
392
401
|
return a = this.ACTION(() => (l || this._reportError(a, "Missing closing parenthesis '}'", o), this._tagClose(a, this.getLexerPosition()))), a;
|
|
393
402
|
}), this._ruleLiteralForArray = this.RULE("ruleLiteralForArray", () => {
|
|
394
|
-
const { StringToken:
|
|
403
|
+
const { StringToken: e, BooleanToken: t, LiteralError: s, RefError: i } = this._vocab;
|
|
395
404
|
return this.OR([
|
|
396
405
|
{ ALT: () => {
|
|
397
|
-
const
|
|
398
|
-
return this.ACTION(() =>
|
|
406
|
+
const e = this.OPTION(() => this.SUBRULE(this._rulePlusMinusOp)), t = this.SUBRULE(this._ruleNumber), s = this.ACTION(() => this._tag(p(t.image, this._locale), this.getLexerPosition()));
|
|
407
|
+
return this.ACTION(() => e ? x(e.image, s) : s);
|
|
399
408
|
} },
|
|
400
409
|
{ ALT: () => {
|
|
401
|
-
const
|
|
402
|
-
return this.ACTION(() => this._tag(
|
|
410
|
+
const t = this.CONSUME(e);
|
|
411
|
+
return this.ACTION(() => this._tag(g(t.image), this.getLexerPosition()));
|
|
403
412
|
} },
|
|
404
413
|
{ ALT: () => {
|
|
405
|
-
const e = this.CONSUME(
|
|
406
|
-
return this.ACTION(() => this._tag(
|
|
414
|
+
const e = this.CONSUME(t);
|
|
415
|
+
return this.ACTION(() => this._tag(L(e.image, this._locale), this.getLexerPosition()));
|
|
407
416
|
} },
|
|
408
417
|
{ ALT: () => {
|
|
409
|
-
const e = this.CONSUME(
|
|
410
|
-
return this.ACTION(() => this._tag(
|
|
418
|
+
const e = this.CONSUME(s);
|
|
419
|
+
return this.ACTION(() => this._tag(m(e.image, this._locale), this.getLexerPosition()));
|
|
411
420
|
} },
|
|
412
421
|
{ ALT: () => {
|
|
413
|
-
const e = this.CONSUME(
|
|
414
|
-
return this.ACTION(() => this._tag(
|
|
422
|
+
const e = this.CONSUME(i);
|
|
423
|
+
return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
|
|
415
424
|
} }
|
|
416
425
|
]);
|
|
417
426
|
}), this._ruleLiteral = this.RULE("ruleLiteral", () => {
|
|
418
|
-
const { StringToken: e, BooleanToken: t, LiteralError: s, RefError:
|
|
427
|
+
const { StringToken: e, BooleanToken: t, LiteralError: s, RefError: i } = this._vocab;
|
|
419
428
|
return this.OR([
|
|
420
429
|
{ ALT: () => {
|
|
421
430
|
const e = this.SUBRULE(this._ruleNumber);
|
|
422
|
-
return this.ACTION(() => this._tag(
|
|
431
|
+
return this.ACTION(() => this._tag(p(e.image, this._locale), this.getLexerPosition()));
|
|
423
432
|
} },
|
|
424
433
|
{ ALT: () => {
|
|
425
434
|
const t = this.CONSUME(e);
|
|
426
|
-
return this.ACTION(() => this._tag(
|
|
435
|
+
return this.ACTION(() => this._tag(g(t.image), this.getLexerPosition()));
|
|
427
436
|
} },
|
|
428
437
|
{ ALT: () => {
|
|
429
438
|
const e = this.CONSUME(t);
|
|
430
|
-
return this.ACTION(() => this._tag(
|
|
439
|
+
return this.ACTION(() => this._tag(L(e.image, this._locale), this.getLexerPosition()));
|
|
431
440
|
} },
|
|
432
441
|
{ ALT: () => {
|
|
433
442
|
const e = this.CONSUME(s);
|
|
434
|
-
return this.ACTION(() => this._tag(
|
|
443
|
+
return this.ACTION(() => this._tag(m(e.image, this._locale), this.getLexerPosition()));
|
|
435
444
|
} },
|
|
436
445
|
{ ALT: () => {
|
|
437
|
-
const e = this.CONSUME(
|
|
438
|
-
return this.ACTION(() => this._tag(
|
|
446
|
+
const e = this.CONSUME(i);
|
|
447
|
+
return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
|
|
439
448
|
} }
|
|
440
449
|
]);
|
|
441
450
|
}), this._ruleFunction = this.RULE("ruleFunction", () => {
|
|
442
451
|
const { FunctionToken: e, OpenParen: t, CloseParen: s } = this._vocab, i = this.CONSUME(e).image, r = this.getLexerPosition();
|
|
443
452
|
this.CONSUME(t);
|
|
444
453
|
const n = this.SUBRULE(this._ruleFunctionArguments);
|
|
445
|
-
let o = this.ACTION(() => this._tag(
|
|
454
|
+
let o = this.ACTION(() => this._tag(_(i, n), r));
|
|
446
455
|
const a = this.OPTION(() => this.CONSUME(s));
|
|
447
456
|
return o = this.ACTION(() => (a || this._reportError(o, "Missing closing parenthesis ')'", r), this._tagClose(o, this.getLexerPosition()))), o;
|
|
448
457
|
}), this._ruleFunctionArguments = this.RULE("ruleFunctionArguments", () => {
|
|
@@ -453,11 +462,11 @@ var re = {
|
|
|
453
462
|
let t;
|
|
454
463
|
this.OPTION2(() => {
|
|
455
464
|
t = this.SUBRULE(this._ruleIntersectOp);
|
|
456
|
-
}), t = this.ACTION(() => t ?? this._tagClose(
|
|
465
|
+
}), t = this.ACTION(() => t ?? this._tagClose(G(), this.getLexerPosition())), s.push(t), this.MANY(() => {
|
|
457
466
|
let t;
|
|
458
467
|
this.CONSUME(e), this.OPTION3(() => {
|
|
459
468
|
t = this.SUBRULE2(this._ruleIntersectOp);
|
|
460
|
-
}), t = this.ACTION(() => t ?? this._tagClose(
|
|
469
|
+
}), t = this.ACTION(() => t ?? this._tagClose(G(), this.getLexerPosition())), s.push(t);
|
|
461
470
|
});
|
|
462
471
|
}
|
|
463
472
|
}), s;
|
|
@@ -476,14 +485,14 @@ var re = {
|
|
|
476
485
|
return this._tag(e.root, s);
|
|
477
486
|
});
|
|
478
487
|
}), this._ruleReference = this.RULE("ruleReference", () => {
|
|
479
|
-
const { Sheet: e, SheetQuoted:
|
|
488
|
+
const { Sheet: e, SheetQuoted: s, DivOp: r, MulOp: n, PlusOp: o, MinOp: a, ArgSeparator: h, Cell: l, NamedToken: p, SingleQuotedString: g, Column: O, AbsRow: _, DigitToken: m, RefError: E } = this._vocab;
|
|
480
489
|
let L;
|
|
481
490
|
this.OPTION2({
|
|
482
491
|
GATE: () => {
|
|
483
|
-
for (let
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
if ("" ===
|
|
492
|
+
for (let t = 1; t < 6; t++) {
|
|
493
|
+
const i = this.LA(t);
|
|
494
|
+
if (i.tokenType === e || i.tokenType === s) return !0;
|
|
495
|
+
if ("" === i.image || ")" === i.image || i.tokenType === r || i.tokenType === n || i.tokenType === o || i.tokenType === a || i.tokenType === h) break;
|
|
487
496
|
}
|
|
488
497
|
return !1;
|
|
489
498
|
},
|
|
@@ -493,40 +502,37 @@ var re = {
|
|
|
493
502
|
});
|
|
494
503
|
let A = this.OR([
|
|
495
504
|
{ ALT: () => {
|
|
496
|
-
const e = this.CONSUME(
|
|
497
|
-
return this.ACTION(() =>
|
|
498
|
-
const i = this._tag(B(e.image, this.rowIndex, this.colIndex), t);
|
|
499
|
-
return s ? this._tag(c("#", i, !0), t) : i;
|
|
500
|
-
});
|
|
505
|
+
const e = this.CONSUME(l), t = this.getLexerPosition();
|
|
506
|
+
return this.ACTION(() => this._tag(D(e.image, this.rowIndex, this.colIndex), t));
|
|
501
507
|
} },
|
|
502
508
|
{ ALT: () => {
|
|
503
509
|
const e = this.OR2([{ ALT: () => this.CONSUME(p) }, { ALT: () => this.CONSUME(g) }]);
|
|
504
|
-
return this.ACTION(() => this._tag(
|
|
510
|
+
return this.ACTION(() => this._tag(i(e.image), this.getLexerPosition()));
|
|
505
511
|
} },
|
|
506
512
|
{ ALT: () => this.SUBRULE(this._ruleBracketedString) },
|
|
507
513
|
{ ALT: () => this.SUBRULE(this._ruleFunction) },
|
|
508
514
|
{ ALT: () => {
|
|
509
515
|
const e = this.CONSUME(O);
|
|
510
|
-
return this.ACTION(() => this._tag(
|
|
516
|
+
return this.ACTION(() => this._tag(T(e.image, this.colIndex), this.getLexerPosition()));
|
|
511
517
|
} },
|
|
512
518
|
{ ALT: () => {
|
|
513
519
|
const e = this.CONSUME(_);
|
|
514
|
-
return this.ACTION(() => this._tag(
|
|
520
|
+
return this.ACTION(() => this._tag(c(e.image, this.rowIndex), this.getLexerPosition()));
|
|
515
521
|
} },
|
|
516
522
|
{ ALT: () => {
|
|
517
523
|
const e = this.CONSUME(m);
|
|
518
|
-
return this.ACTION(() => this._tag(
|
|
524
|
+
return this.ACTION(() => this._tag(c(e.image, this.rowIndex), this.getLexerPosition()));
|
|
519
525
|
} },
|
|
520
526
|
{ ALT: () => {
|
|
521
527
|
const e = this.CONSUME(E);
|
|
522
|
-
return this.ACTION(() => this._tag(
|
|
528
|
+
return this.ACTION(() => this._tag(u(e.image, this._locale), this.getLexerPosition()));
|
|
523
529
|
} }
|
|
524
530
|
]);
|
|
525
531
|
return this.ACTION(() => {
|
|
526
532
|
if (L && A) {
|
|
527
533
|
if ("" === L.name) return void this._reportError(A, `'${L.image}' is not a valid sheet reference — a '!' needs a sheet name before it`);
|
|
528
534
|
let e = A;
|
|
529
|
-
A.type ===
|
|
535
|
+
A.type === t.Postfix && A.inputs?.[0] && (e = A.inputs[0]), e.type !== t.Cell && e.type !== t.Named && e.type !== t.Row && e.type !== t.TableColumn && e.type !== t.Error || (e.value.scope = L.name, e.value.scopeImage = L.image);
|
|
530
536
|
}
|
|
531
537
|
}), A;
|
|
532
538
|
}), this._rulePrefixSheetName = this.RULE("rulePrefixSheetName", () => {
|
|
@@ -561,52 +567,52 @@ var re = {
|
|
|
561
567
|
{ ALT: () => this.CONSUME(s) }
|
|
562
568
|
]);
|
|
563
569
|
}), this._ruleRoot = this.RULE("ruleRoot", () => {
|
|
564
|
-
const { ArgSeparator: e } = this._vocab,
|
|
570
|
+
const { ArgSeparator: e } = this._vocab, s = this.SUBRULE(this._ruleIntersectOp), i = [];
|
|
565
571
|
return this.MANY(() => {
|
|
566
|
-
this.CONSUME(e),
|
|
567
|
-
}), this.ACTION(() => 0 ===
|
|
568
|
-
type:
|
|
572
|
+
this.CONSUME(e), i.push(this.SUBRULE2(this._ruleIntersectOp));
|
|
573
|
+
}), this.ACTION(() => 0 === i.length ? s : {
|
|
574
|
+
type: t.List,
|
|
569
575
|
value: ",",
|
|
570
|
-
inputs: [
|
|
576
|
+
inputs: [s, ...i],
|
|
571
577
|
isReference: !0
|
|
572
578
|
});
|
|
573
|
-
}), this._lexer = o, this._locale = o.getLocale(), this._vocab = a, this._srParser = n?.srParser ?? new
|
|
579
|
+
}), this._lexer = o, this._locale = o.getLocale(), this._vocab = a, this._srParser = n?.srParser ?? new K(this._locale), this.performSelfAnalysis();
|
|
574
580
|
}
|
|
575
581
|
getLexer() {
|
|
576
582
|
return this._lexer;
|
|
577
583
|
}
|
|
578
|
-
parse(e,
|
|
579
|
-
const
|
|
580
|
-
let
|
|
581
|
-
if (!
|
|
584
|
+
parse(e, s, r, n) {
|
|
585
|
+
const o = this._lexer.tokenize(r);
|
|
586
|
+
let a;
|
|
587
|
+
if (!o) return {
|
|
582
588
|
root: {
|
|
583
|
-
type:
|
|
584
|
-
value:
|
|
589
|
+
type: t.Unparsed,
|
|
590
|
+
value: r
|
|
585
591
|
},
|
|
586
592
|
errors: []
|
|
587
593
|
};
|
|
588
|
-
const
|
|
589
|
-
if (0 ===
|
|
590
|
-
return this.input =
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
593
|
-
const
|
|
594
|
-
return
|
|
594
|
+
const h = o.tokens;
|
|
595
|
+
if (0 === h.length) throw new z.Parse(ie);
|
|
596
|
+
return this.input = h, this._inputText = r, this._inputTextLength = r.length, this.rowIndex = e, this.colIndex = s, this._astErrors = [], this._tokenMap = /* @__PURE__ */ new Map(), this.reset(), a = this._ruleRoot(), a && this._bindAllWhitespace(a), a = Y(a, (s, r) => {
|
|
597
|
+
const n = s.type, o = r?.isReference ? r.value : void 0, a = "string" == typeof o && J.has(o), h = "string" == typeof o && ee.has(o), l = a ? r.inputs : void 0, u = l ? l[0] === s ? l[1] : l[0] : void 0, p = this._lexer.getMaxRow();
|
|
598
|
+
if (a && n !== t.Cell && Number.isInteger(s.value)) {
|
|
599
|
+
const t = c(s.image, e);
|
|
600
|
+
return N(t, s), "row" !== te(u) ? this._reportError(t, `'${s.image}' is not a valid reference — a whole row can only pair with another row (as in ${s.image}:${s.image})`) : se(s.image, p) || this._reportError(t, `'${s.image}' is not a valid row — rows run from 1 to ${p}`), t;
|
|
595
601
|
}
|
|
596
|
-
if (
|
|
597
|
-
if (
|
|
598
|
-
const e =
|
|
599
|
-
if ((
|
|
600
|
-
if (
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
return
|
|
602
|
+
if (h && n === t.Named) return this._reportError(s, `'${s.image ?? s.value?.nameId}' is a name — '${o}' needs a cell or range on both sides`), s;
|
|
603
|
+
if (n === t.Cell) {
|
|
604
|
+
const e = s.value, t = e.colIndex === Number.MIN_SAFE_INTEGER, r = e.rowIndex === Number.MIN_SAFE_INTEGER;
|
|
605
|
+
if ((t || r) && te(u) === (t ? "row" : "col")) return t && !se(s.image, p) && this._reportError(s, `'${s.image}' is not a valid row — rows run from 1 to ${p}`), s;
|
|
606
|
+
if (t || r || e.colIndex >= 16384) {
|
|
607
|
+
const n = i(s.image);
|
|
608
|
+
N(n, s);
|
|
609
|
+
const a = e.scope;
|
|
610
|
+
return a && (n.value.scope = a, n.value.scopeImage = e.scopeImage), t ? this._reportError(n, `'${s.image}' is not a valid reference — a row needs a column (use ${s.image}:${s.image} for the whole row)`) : r && s.image.includes("$") ? this._reportError(n, `'${s.image}' is not a valid reference — a whole column can only pair with another column (as in ${s.image}:${s.image})`) : h && this._reportError(n, `'${s.image}' is a name — '${o}' needs a cell or range on both sides`), n;
|
|
605
611
|
}
|
|
606
612
|
}
|
|
607
|
-
return
|
|
608
|
-
}),
|
|
609
|
-
root:
|
|
613
|
+
return s;
|
|
614
|
+
}), n && a && (a = w(a, n, null)), {
|
|
615
|
+
root: a,
|
|
610
616
|
errors: [...this.errors, ...this._astErrors]
|
|
611
617
|
};
|
|
612
618
|
}
|
|
@@ -662,26 +668,26 @@ var re = {
|
|
|
662
668
|
_bindAllWhitespace(e) {
|
|
663
669
|
if (e) {
|
|
664
670
|
if (this._bindNodeWhitespace(e), e.inputs) for (const t of e.inputs) t && this._bindAllWhitespace(t);
|
|
665
|
-
if (e.type ===
|
|
671
|
+
if (e.type === t.Array && Array.isArray(e.value)) {
|
|
666
672
|
for (const t of e.value) if (t && Array.isArray(t.value)) for (const e of t.value) e && this._bindAllWhitespace(e);
|
|
667
673
|
}
|
|
668
674
|
}
|
|
669
675
|
}
|
|
670
|
-
},
|
|
676
|
+
}, ae = class {
|
|
671
677
|
constructor(e) {
|
|
672
|
-
e = { ...e }, this._editing = "editing" === e.profile, this._parser = new
|
|
678
|
+
e = { ...e }, this._editing = "editing" === e.profile, this._parser = new oe(e);
|
|
673
679
|
}
|
|
674
|
-
compile(e, t, s, i, r, n, o,
|
|
680
|
+
compile(e, t, s, i, r, n, o, a) {
|
|
675
681
|
if (0 === i.length) {
|
|
676
|
-
const t = new z.Parse(
|
|
682
|
+
const t = new z.Parse(ie);
|
|
677
683
|
return this._compileUnparsed(e, r, i, {
|
|
678
684
|
input: i,
|
|
679
685
|
cause: t,
|
|
680
686
|
causes: [t]
|
|
681
687
|
});
|
|
682
688
|
}
|
|
683
|
-
if (i.length >
|
|
684
|
-
const t = new z.Parse((l = i.length, `A formula must not be longer than ${
|
|
689
|
+
if (i.length > h.MAX_EXPRESSION_LENGTH) {
|
|
690
|
+
const t = new z.Parse((l = i.length, `A formula must not be longer than ${h.MAX_EXPRESSION_LENGTH} characters (this one is ${l})`));
|
|
685
691
|
return this._compileUnparsed(e, r, i, {
|
|
686
692
|
input: i,
|
|
687
693
|
cause: t,
|
|
@@ -691,22 +697,22 @@ var re = {
|
|
|
691
697
|
var l;
|
|
692
698
|
let u, c, p = [];
|
|
693
699
|
try {
|
|
694
|
-
const e = this._parser.parse(t, s, i,
|
|
700
|
+
const e = this._parser.parse(t, s, i, a);
|
|
695
701
|
u = e.root, p = e.errors;
|
|
696
702
|
} catch (e) {
|
|
697
703
|
c = z.isError(e, z.Code.Parse) ? e : new z.Parse(e.message, e);
|
|
698
704
|
}
|
|
699
705
|
const g = [];
|
|
700
|
-
for (const e of p) g.push(
|
|
706
|
+
for (const e of p) g.push(U(e));
|
|
701
707
|
if (u) {
|
|
702
|
-
|
|
703
|
-
const e =
|
|
708
|
+
R(u, n ?? null) && g.push(new z.Parse("The implicit intersection operator ' ' requires a cell or range on both sides")), f(u, n ?? null) && g.push(new z.Parse("The spill anchor operator '#' requires a cell or range")), B(u, n ?? null) && g.push(new z.Parse("Expected a reference; a value cannot be converted to one."));
|
|
709
|
+
const e = S(u, n ?? null);
|
|
704
710
|
e && g.push(new z.Parse(e));
|
|
705
|
-
const t =
|
|
711
|
+
const t = A(u, n ?? null);
|
|
706
712
|
t && g.push(new z.Parse(t));
|
|
707
|
-
const s =
|
|
713
|
+
const s = v(u, n ?? null);
|
|
708
714
|
s && g.push(new z.Parse(s));
|
|
709
|
-
const i =
|
|
715
|
+
const i = k(u);
|
|
710
716
|
i && g.push(new z.Parse(i));
|
|
711
717
|
}
|
|
712
718
|
g.length > 0 && !c && (c = g[0]);
|
|
@@ -722,9 +728,9 @@ var re = {
|
|
|
722
728
|
}
|
|
723
729
|
return this._compileUnparsed(e, r, i, O);
|
|
724
730
|
}
|
|
725
|
-
u =
|
|
726
|
-
const _ =
|
|
727
|
-
if (this._editing && O &&
|
|
731
|
+
u = y(u, n ?? null), u = P(u, n ?? null), r && (u = d(u, r, o));
|
|
732
|
+
const _ = b(e, r, u, this._editing, O, n ?? null);
|
|
733
|
+
if (this._editing && O && M(_.getTokens(), r) !== i) return this._recoverCompiled(e, t, s, i, r, O, o) || this._compileUnparsed(e, r, i, O);
|
|
728
734
|
return _;
|
|
729
735
|
}
|
|
730
736
|
autoCorrect(e) {
|
|
@@ -745,93 +751,93 @@ var re = {
|
|
|
745
751
|
}
|
|
746
752
|
return 0 === s.length ? null : e + s.reverse().join("");
|
|
747
753
|
}
|
|
748
|
-
_compileUnparsed(e,
|
|
749
|
-
const
|
|
754
|
+
_compileUnparsed(e, s, i, r) {
|
|
755
|
+
const n = {
|
|
750
756
|
runtime: e,
|
|
751
|
-
symbols:
|
|
757
|
+
symbols: s,
|
|
752
758
|
getFunction: null,
|
|
753
759
|
ast: null,
|
|
754
|
-
evaluations:
|
|
755
|
-
executions:
|
|
756
|
-
bindings:
|
|
757
|
-
referencesAbsolute:
|
|
758
|
-
referencesExecute:
|
|
759
|
-
referencesRelative:
|
|
760
|
-
referencesRoot:
|
|
761
|
-
referenceIndices:
|
|
760
|
+
evaluations: V.EmptyArray,
|
|
761
|
+
executions: V.EmptyArray,
|
|
762
|
+
bindings: V.EmptyArray,
|
|
763
|
+
referencesAbsolute: V.EmptyArray,
|
|
764
|
+
referencesExecute: V.EmptyArray,
|
|
765
|
+
referencesRelative: V.EmptyArray,
|
|
766
|
+
referencesRoot: V.EmptyArray,
|
|
767
|
+
referenceIndices: V.EmptyArray,
|
|
762
768
|
getTokens: () => [{
|
|
763
|
-
type:
|
|
764
|
-
value:
|
|
765
|
-
text:
|
|
769
|
+
type: t.Unparsed,
|
|
770
|
+
value: i,
|
|
771
|
+
text: i
|
|
766
772
|
}],
|
|
767
|
-
namedIds:
|
|
768
|
-
symbolIds:
|
|
773
|
+
namedIds: V.EmptyArray,
|
|
774
|
+
symbolIds: V.EmptyArray,
|
|
769
775
|
hasTotals: !1,
|
|
770
776
|
isReferenceOnly: !1,
|
|
771
|
-
error:
|
|
772
|
-
transform: () =>
|
|
777
|
+
error: r,
|
|
778
|
+
transform: () => n
|
|
773
779
|
};
|
|
774
|
-
return
|
|
780
|
+
return n;
|
|
775
781
|
}
|
|
776
|
-
_recoverCompiled(e,
|
|
777
|
-
let
|
|
782
|
+
_recoverCompiled(e, s, i, r, n, o, a) {
|
|
783
|
+
let h, l = r.length;
|
|
778
784
|
try {
|
|
779
|
-
const e = this._parser.getLexer().tokenize(
|
|
780
|
-
|
|
785
|
+
const e = this._parser.getLexer().tokenize(r, !1);
|
|
786
|
+
h = e.tokens, e.errors.length > 0 && (l = Math.min(l, e.errors[0].offset));
|
|
781
787
|
} catch {
|
|
782
788
|
return null;
|
|
783
789
|
}
|
|
784
|
-
const
|
|
785
|
-
for (let e =
|
|
786
|
-
const t = (
|
|
787
|
-
t > 0 && t <
|
|
790
|
+
const u = [];
|
|
791
|
+
for (let e = h.length - 1; e >= 0 && u.length < 24; e--) {
|
|
792
|
+
const t = (h[e].endOffset ?? -1) + 1;
|
|
793
|
+
t > 0 && t < r.length && t <= l && u.push(t);
|
|
788
794
|
}
|
|
789
|
-
for (const
|
|
790
|
-
const
|
|
791
|
-
let
|
|
795
|
+
for (const h of u) {
|
|
796
|
+
const l = r.slice(0, h);
|
|
797
|
+
let u, c;
|
|
792
798
|
try {
|
|
793
|
-
|
|
799
|
+
u = this._parser.parse(s, i, l).root;
|
|
794
800
|
} catch {
|
|
795
801
|
continue;
|
|
796
802
|
}
|
|
797
|
-
if (!
|
|
803
|
+
if (!u || u.type === t.Unparsed) continue;
|
|
798
804
|
try {
|
|
799
|
-
const t =
|
|
800
|
-
|
|
805
|
+
const t = P(u, null);
|
|
806
|
+
c = b(e, n, n ? d(t, n, a) : t, !0, o);
|
|
801
807
|
} catch {
|
|
802
808
|
continue;
|
|
803
809
|
}
|
|
804
|
-
if (
|
|
805
|
-
const
|
|
806
|
-
if (0 ===
|
|
807
|
-
let
|
|
808
|
-
const
|
|
809
|
-
...
|
|
810
|
-
getTokens: () => (
|
|
811
|
-
transform: () =>
|
|
810
|
+
if (M(c.getTokens(), n) !== l) continue;
|
|
811
|
+
const p = r.slice(h);
|
|
812
|
+
if (0 === p.length) return c;
|
|
813
|
+
let g;
|
|
814
|
+
const O = {
|
|
815
|
+
...c,
|
|
816
|
+
getTokens: () => (g || (g = [...c.getTokens()], this._appendUnparsedTail(g, p)), g),
|
|
817
|
+
transform: () => O
|
|
812
818
|
};
|
|
813
|
-
return
|
|
819
|
+
return O;
|
|
814
820
|
}
|
|
815
821
|
return null;
|
|
816
822
|
}
|
|
817
|
-
_appendUnparsedTail(e,
|
|
818
|
-
const
|
|
819
|
-
for (const
|
|
820
|
-
ctx:
|
|
823
|
+
_appendUnparsedTail(e, s) {
|
|
824
|
+
const i = [];
|
|
825
|
+
for (const s of e) s.type === t.Paren && "(" === s.text ? i.push({
|
|
826
|
+
ctx: s.context,
|
|
821
827
|
argIndex: 0
|
|
822
|
-
}) :
|
|
823
|
-
const
|
|
824
|
-
...
|
|
825
|
-
argIndex: -1 ===
|
|
826
|
-
} : void 0,
|
|
827
|
-
const
|
|
828
|
-
type:
|
|
829
|
-
value:
|
|
830
|
-
text:
|
|
828
|
+
}) : s.type === t.Paren && ")" === s.text ? i.pop() : s.type === t.Separator && i.length > 0 && i[i.length - 1].argIndex++;
|
|
829
|
+
const r = i.length > 0 ? i[i.length - 1] : void 0, n = r?.ctx ? {
|
|
830
|
+
...r.ctx,
|
|
831
|
+
argIndex: -1 === r.ctx.argIndex ? r.argIndex : r.ctx.argIndex
|
|
832
|
+
} : void 0, o = (s, i) => {
|
|
833
|
+
const r = {
|
|
834
|
+
type: t.Unparsed,
|
|
835
|
+
value: s,
|
|
836
|
+
text: s
|
|
831
837
|
};
|
|
832
|
-
|
|
833
|
-
},
|
|
834
|
-
|
|
838
|
+
n && (r.context = n), i && (r.isLookup = !0), e.push(r);
|
|
839
|
+
}, a = /[A-Za-z_][A-Za-z0-9_]*$/.exec(s), h = a ? a.index : -1;
|
|
840
|
+
h >= 0 && (0 === h || !/[A-Za-z0-9_.]/.test(s[h - 1])) ? (h > 0 && o(s.slice(0, h)), o(s.slice(h), !0)) : o(s);
|
|
835
841
|
}
|
|
836
842
|
};
|
|
837
|
-
export {
|
|
843
|
+
export { ae as FormulaCompiler };
|