@gridsheet/react-core 0.12.4-rc.0 → 0.12.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.
Files changed (212) hide show
  1. package/dist/components/Cell.d.ts.map +1 -1
  2. package/dist/components/Cell.js +181 -190
  3. package/dist/components/Cell.js.map +1 -1
  4. package/dist/components/ContextMenu.js +198 -208
  5. package/dist/components/ContextMenu.js.map +1 -1
  6. package/dist/components/Editor.d.ts.map +1 -1
  7. package/dist/components/Editor.js +262 -275
  8. package/dist/components/Editor.js.map +1 -1
  9. package/dist/components/Emitter.js +29 -39
  10. package/dist/components/Emitter.js.map +1 -1
  11. package/dist/components/GridSheet.d.ts.map +1 -1
  12. package/dist/components/GridSheet.js +109 -119
  13. package/dist/components/GridSheet.js.map +1 -1
  14. package/dist/components/HeaderLeftCell.js +61 -72
  15. package/dist/components/HeaderLeftCell.js.map +1 -1
  16. package/dist/components/HeaderTopCell.js +62 -73
  17. package/dist/components/HeaderTopCell.js.map +1 -1
  18. package/dist/components/Resizer.d.ts.map +1 -1
  19. package/dist/components/Resizer.js +79 -87
  20. package/dist/components/Resizer.js.map +1 -1
  21. package/dist/components/SearchBox.d.ts.map +1 -1
  22. package/dist/components/SearchBox.js +54 -62
  23. package/dist/components/SearchBox.js.map +1 -1
  24. package/dist/components/StoreInitializer.js +71 -81
  25. package/dist/components/StoreInitializer.js.map +1 -1
  26. package/dist/components/Tabular.d.ts +2 -2
  27. package/dist/components/Tabular.d.ts.map +1 -1
  28. package/dist/components/Tabular.js +85 -95
  29. package/dist/components/Tabular.js.map +1 -1
  30. package/dist/constants.d.ts.map +1 -1
  31. package/dist/constants.js +26 -33
  32. package/dist/constants.js.map +1 -1
  33. package/dist/formula/evaluator.d.ts +1 -1
  34. package/dist/formula/evaluator.js +490 -500
  35. package/dist/formula/evaluator.js.map +1 -1
  36. package/dist/formula/functions/__base.js +17 -27
  37. package/dist/formula/functions/__base.js.map +1 -1
  38. package/dist/formula/functions/__utils.js +103 -113
  39. package/dist/formula/functions/__utils.js.map +1 -1
  40. package/dist/formula/functions/abs.js +21 -31
  41. package/dist/formula/functions/abs.js.map +1 -1
  42. package/dist/formula/functions/abs.spec.js +25 -35
  43. package/dist/formula/functions/abs.spec.js.map +1 -1
  44. package/dist/formula/functions/acos.js +28 -38
  45. package/dist/formula/functions/acos.js.map +1 -1
  46. package/dist/formula/functions/add.js +47 -57
  47. package/dist/formula/functions/add.js.map +1 -1
  48. package/dist/formula/functions/and.js +28 -38
  49. package/dist/formula/functions/and.js.map +1 -1
  50. package/dist/formula/functions/asin.js +28 -38
  51. package/dist/formula/functions/asin.js.map +1 -1
  52. package/dist/formula/functions/atan.js +26 -36
  53. package/dist/formula/functions/atan.js.map +1 -1
  54. package/dist/formula/functions/atan2.js +32 -42
  55. package/dist/formula/functions/atan2.js.map +1 -1
  56. package/dist/formula/functions/average.js +40 -50
  57. package/dist/formula/functions/average.js.map +1 -1
  58. package/dist/formula/functions/col.js +28 -38
  59. package/dist/formula/functions/col.js.map +1 -1
  60. package/dist/formula/functions/concat.js +27 -37
  61. package/dist/formula/functions/concat.js.map +1 -1
  62. package/dist/formula/functions/concatenate.js +25 -35
  63. package/dist/formula/functions/concatenate.js.map +1 -1
  64. package/dist/formula/functions/cos.js +26 -36
  65. package/dist/formula/functions/cos.js.map +1 -1
  66. package/dist/formula/functions/count.js +35 -45
  67. package/dist/formula/functions/count.js.map +1 -1
  68. package/dist/formula/functions/counta.js +35 -45
  69. package/dist/formula/functions/counta.js.map +1 -1
  70. package/dist/formula/functions/countif.js +30 -40
  71. package/dist/formula/functions/countif.js.map +1 -1
  72. package/dist/formula/functions/divide.js +32 -42
  73. package/dist/formula/functions/divide.js.map +1 -1
  74. package/dist/formula/functions/eq.js +25 -35
  75. package/dist/formula/functions/eq.js.map +1 -1
  76. package/dist/formula/functions/exp.js +28 -38
  77. package/dist/formula/functions/exp.js.map +1 -1
  78. package/dist/formula/functions/gt.js +27 -37
  79. package/dist/formula/functions/gt.js.map +1 -1
  80. package/dist/formula/functions/gte.js +27 -37
  81. package/dist/formula/functions/gte.js.map +1 -1
  82. package/dist/formula/functions/hlookup.js +67 -77
  83. package/dist/formula/functions/hlookup.js.map +1 -1
  84. package/dist/formula/functions/if.js +36 -46
  85. package/dist/formula/functions/if.js.map +1 -1
  86. package/dist/formula/functions/iferror.js +38 -48
  87. package/dist/formula/functions/iferror.js.map +1 -1
  88. package/dist/formula/functions/iferror.spec.js +53 -63
  89. package/dist/formula/functions/iferror.spec.js.map +1 -1
  90. package/dist/formula/functions/len.js +26 -36
  91. package/dist/formula/functions/len.js.map +1 -1
  92. package/dist/formula/functions/lenb.js +26 -36
  93. package/dist/formula/functions/lenb.js.map +1 -1
  94. package/dist/formula/functions/ln.js +28 -38
  95. package/dist/formula/functions/ln.js.map +1 -1
  96. package/dist/formula/functions/log.js +33 -43
  97. package/dist/formula/functions/log.js.map +1 -1
  98. package/dist/formula/functions/log10.js +28 -38
  99. package/dist/formula/functions/log10.js.map +1 -1
  100. package/dist/formula/functions/lt.js +27 -37
  101. package/dist/formula/functions/lt.js.map +1 -1
  102. package/dist/formula/functions/lte.js +27 -37
  103. package/dist/formula/functions/lte.js.map +1 -1
  104. package/dist/formula/functions/max.js +42 -52
  105. package/dist/formula/functions/max.js.map +1 -1
  106. package/dist/formula/functions/min.js +42 -52
  107. package/dist/formula/functions/min.js.map +1 -1
  108. package/dist/formula/functions/minus.js +47 -57
  109. package/dist/formula/functions/minus.js.map +1 -1
  110. package/dist/formula/functions/mod.js +30 -40
  111. package/dist/formula/functions/mod.js.map +1 -1
  112. package/dist/formula/functions/mod.spec.js +47 -57
  113. package/dist/formula/functions/mod.spec.js.map +1 -1
  114. package/dist/formula/functions/multiply.js +27 -37
  115. package/dist/formula/functions/multiply.js.map +1 -1
  116. package/dist/formula/functions/ne.js +25 -35
  117. package/dist/formula/functions/ne.js.map +1 -1
  118. package/dist/formula/functions/not.js +30 -40
  119. package/dist/formula/functions/not.js.map +1 -1
  120. package/dist/formula/functions/now.js +21 -31
  121. package/dist/formula/functions/now.js.map +1 -1
  122. package/dist/formula/functions/or.js +28 -38
  123. package/dist/formula/functions/or.js.map +1 -1
  124. package/dist/formula/functions/pi.js +19 -29
  125. package/dist/formula/functions/pi.js.map +1 -1
  126. package/dist/formula/functions/power.js +24 -34
  127. package/dist/formula/functions/power.js.map +1 -1
  128. package/dist/formula/functions/product.js +37 -47
  129. package/dist/formula/functions/product.js.map +1 -1
  130. package/dist/formula/functions/radians.js +26 -36
  131. package/dist/formula/functions/radians.js.map +1 -1
  132. package/dist/formula/functions/rand.js +19 -29
  133. package/dist/formula/functions/rand.js.map +1 -1
  134. package/dist/formula/functions/round.js +34 -44
  135. package/dist/formula/functions/round.js.map +1 -1
  136. package/dist/formula/functions/rounddown.js +34 -44
  137. package/dist/formula/functions/rounddown.js.map +1 -1
  138. package/dist/formula/functions/roundup.js +34 -44
  139. package/dist/formula/functions/roundup.js.map +1 -1
  140. package/dist/formula/functions/row.js +28 -38
  141. package/dist/formula/functions/row.js.map +1 -1
  142. package/dist/formula/functions/sin.js +26 -36
  143. package/dist/formula/functions/sin.js.map +1 -1
  144. package/dist/formula/functions/sqrt.js +28 -38
  145. package/dist/formula/functions/sqrt.js.map +1 -1
  146. package/dist/formula/functions/sum.js +42 -52
  147. package/dist/formula/functions/sum.js.map +1 -1
  148. package/dist/formula/functions/sum.spec.js +35 -45
  149. package/dist/formula/functions/sum.spec.js.map +1 -1
  150. package/dist/formula/functions/sumif.js +56 -66
  151. package/dist/formula/functions/sumif.js.map +1 -1
  152. package/dist/formula/functions/tan.js +26 -36
  153. package/dist/formula/functions/tan.js.map +1 -1
  154. package/dist/formula/functions/uminus.js +23 -33
  155. package/dist/formula/functions/uminus.js.map +1 -1
  156. package/dist/formula/functions/vlookup.js +67 -77
  157. package/dist/formula/functions/vlookup.js.map +1 -1
  158. package/dist/formula/mapping.js +116 -126
  159. package/dist/formula/mapping.js.map +1 -1
  160. package/dist/formula/solver.js +61 -71
  161. package/dist/formula/solver.js.map +1 -1
  162. package/dist/index.js +31 -41
  163. package/dist/index.js.map +1 -1
  164. package/dist/lib/autofill.js +334 -344
  165. package/dist/lib/autofill.js.map +1 -1
  166. package/dist/lib/clipboard.js +45 -55
  167. package/dist/lib/clipboard.js.map +1 -1
  168. package/dist/lib/converters.js +130 -140
  169. package/dist/lib/converters.js.map +1 -1
  170. package/dist/lib/hooks.d.ts +1 -0
  171. package/dist/lib/hooks.d.ts.map +1 -0
  172. package/dist/lib/hooks.js +2 -0
  173. package/dist/lib/hooks.js.map +1 -0
  174. package/dist/lib/structs.js +254 -264
  175. package/dist/lib/structs.js.map +1 -1
  176. package/dist/lib/table.d.ts +1 -3
  177. package/dist/lib/table.d.ts.map +1 -1
  178. package/dist/lib/table.js +897 -911
  179. package/dist/lib/table.js.map +1 -1
  180. package/dist/lib/time.d.ts.map +1 -1
  181. package/dist/lib/time.js +59 -69
  182. package/dist/lib/time.js.map +1 -1
  183. package/dist/lib/virtualization.d.ts +3 -12
  184. package/dist/lib/virtualization.d.ts.map +1 -1
  185. package/dist/lib/virtualization.js +116 -120
  186. package/dist/lib/virtualization.js.map +1 -1
  187. package/dist/parsers/core.js +109 -119
  188. package/dist/parsers/core.js.map +1 -1
  189. package/dist/renderers/checkbox.js +11 -21
  190. package/dist/renderers/checkbox.js.map +1 -1
  191. package/dist/renderers/core.d.ts +1 -1
  192. package/dist/renderers/core.d.ts.map +1 -1
  193. package/dist/renderers/core.js +129 -139
  194. package/dist/renderers/core.js.map +1 -1
  195. package/dist/renderers/thousand_separator.js +15 -25
  196. package/dist/renderers/thousand_separator.js.map +1 -1
  197. package/dist/store/actions.js +485 -495
  198. package/dist/store/actions.js.map +1 -1
  199. package/dist/store/helpers.js +78 -88
  200. package/dist/store/helpers.js.map +1 -1
  201. package/dist/store/index.js +5 -15
  202. package/dist/store/index.js.map +1 -1
  203. package/dist/styles/embedder.js +17 -27
  204. package/dist/styles/embedder.js.map +1 -1
  205. package/dist/styles/minified.js +6 -16
  206. package/dist/styles/minified.js.map +1 -1
  207. package/dist/types.d.ts +10 -5
  208. package/dist/types.d.ts.map +1 -1
  209. package/dist/types.js +2 -12
  210. package/dist/utils.js +9 -19
  211. package/dist/utils.js.map +1 -1
  212. package/package.json +9 -2
@@ -1,567 +1,557 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "../lib/structs", "../lib/converters"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.convertFormulaAbsolute = exports.Parser = exports.Lexer = exports.Token = exports.Function = exports.IdRange = exports.Id = exports.Range = exports.Ref = exports.InvalidRef = exports.Unreferenced = exports.Value = exports.FormulaError = void 0;
13
- const structs_1 = require("../lib/structs");
14
- const converters_1 = require("../lib/converters");
15
- // strip sharp and dollars
16
- const getId = (idString, stripAbsolute = true) => {
17
- let id = idString.slice(1);
18
- if (stripAbsolute && id.startsWith("$")) {
19
- id = id.slice(1);
20
- }
21
- if (stripAbsolute && id.endsWith("$")) {
22
- id = id.slice(0, -1);
23
- }
24
- return id;
25
- };
26
- class FormulaError {
27
- constructor(code, message, error) {
28
- this.code = code;
29
- this.message = message;
30
- this.error = error;
31
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertFormulaAbsolute = exports.Parser = exports.Lexer = exports.Token = exports.Function = exports.IdRange = exports.Id = exports.Range = exports.Ref = exports.InvalidRef = exports.Unreferenced = exports.Value = exports.FormulaError = void 0;
4
+ const structs_1 = require("../lib/structs");
5
+ const converters_1 = require("../lib/converters");
6
+ // strip sharp and dollars
7
+ const getId = (idString, stripAbsolute = true) => {
8
+ let id = idString.slice(1);
9
+ if (stripAbsolute && id.startsWith("$")) {
10
+ id = id.slice(1);
32
11
  }
33
- exports.FormulaError = FormulaError;
34
- class Entity {
35
- constructor(value) {
36
- this.value = value;
37
- }
12
+ if (stripAbsolute && id.endsWith("$")) {
13
+ id = id.slice(0, -1);
38
14
  }
39
- class Value extends Entity {
40
- evaluate({}) {
41
- return this.value;
42
- }
15
+ return id;
16
+ };
17
+ class FormulaError {
18
+ constructor(code, message, error) {
19
+ this.code = code;
20
+ this.message = message;
21
+ this.error = error;
43
22
  }
44
- exports.Value = Value;
45
- class Unreferenced extends Entity {
46
- evaluate({}) {
47
- throw new FormulaError("#REF!", `Reference does not exist.`);
48
- }
23
+ }
24
+ exports.FormulaError = FormulaError;
25
+ class Entity {
26
+ constructor(value) {
27
+ this.value = value;
49
28
  }
50
- exports.Unreferenced = Unreferenced;
51
- class InvalidRef extends Entity {
52
- evaluate({}) {
53
- throw new FormulaError("#NAME?", `Invalid ref: ${this.value}`);
54
- }
29
+ }
30
+ class Value extends Entity {
31
+ evaluate({}) {
32
+ return this.value;
55
33
  }
56
- exports.InvalidRef = InvalidRef;
57
- class Ref extends Entity {
58
- constructor(value) {
59
- super(value.toUpperCase());
60
- }
61
- evaluate({ table }) {
62
- const { y, x } = (0, converters_1.a2p)(this.value);
63
- return table.trim({ top: y, left: x, bottom: y, right: x });
64
- }
65
- id(table) {
66
- const id = table.getIdByAddress(this.value);
67
- if (id) {
68
- return id;
69
- }
70
- return this.value;
34
+ }
35
+ exports.Value = Value;
36
+ class Unreferenced extends Entity {
37
+ evaluate({}) {
38
+ throw new FormulaError("#REF!", `Reference does not exist.`);
39
+ }
40
+ }
41
+ exports.Unreferenced = Unreferenced;
42
+ class InvalidRef extends Entity {
43
+ evaluate({}) {
44
+ throw new FormulaError("#NAME?", `Invalid ref: ${this.value}`);
45
+ }
46
+ }
47
+ exports.InvalidRef = InvalidRef;
48
+ class Ref extends Entity {
49
+ constructor(value) {
50
+ super(value.toUpperCase());
51
+ }
52
+ evaluate({ table }) {
53
+ const { y, x } = (0, converters_1.a2p)(this.value);
54
+ return table.trim({ top: y, left: x, bottom: y, right: x });
55
+ }
56
+ id(table) {
57
+ const id = table.getIdByAddress(this.value);
58
+ if (id) {
59
+ return id;
71
60
  }
61
+ return this.value;
62
+ }
63
+ }
64
+ exports.Ref = Ref;
65
+ class Range extends Entity {
66
+ constructor(value) {
67
+ super(value.toUpperCase());
72
68
  }
73
- exports.Ref = Ref;
74
- class Range extends Entity {
75
- constructor(value) {
76
- super(value.toUpperCase());
69
+ evaluate({ table }) {
70
+ const area = (0, structs_1.rangeToArea)(this.complementRange(table));
71
+ return table.trim(area);
72
+ }
73
+ idRange(table) {
74
+ return this.value
75
+ .split(":")
76
+ .map((ref) => table.getIdByAddress(ref))
77
+ .join(":");
78
+ }
79
+ complementRange(table) {
80
+ const cells = this.value.split(":");
81
+ let [start = "", end = ""] = cells;
82
+ if (!start.match(/[1-9]\d*/)) {
83
+ start += "1";
77
84
  }
78
- evaluate({ table }) {
79
- const area = (0, structs_1.rangeToArea)(this.complementRange(table));
80
- return table.trim(area);
85
+ if (!start.match(/[a-zA-Z]/)) {
86
+ start = "A" + start;
81
87
  }
82
- idRange(table) {
83
- return this.value
84
- .split(":")
85
- .map((ref) => table.getIdByAddress(ref))
86
- .join(":");
88
+ if (!end.match(/[1-9]\d*/)) {
89
+ end += table.getNumRows();
87
90
  }
88
- complementRange(table) {
89
- const cells = this.value.split(":");
90
- let [start = "", end = ""] = cells;
91
- if (!start.match(/[1-9]\d*/)) {
92
- start += "1";
93
- }
94
- if (!start.match(/[a-zA-Z]/)) {
95
- start = "A" + start;
96
- }
97
- if (!end.match(/[1-9]\d*/)) {
98
- end += table.getNumRows();
99
- }
100
- if (!end.match(/[a-zA-Z]/)) {
101
- end = (0, converters_1.x2c)(table.getNumCols() + 1) + end;
102
- }
103
- return `${start}:${end}`;
91
+ if (!end.match(/[a-zA-Z]/)) {
92
+ end = (0, converters_1.x2c)(table.getNumCols() + 1) + end;
104
93
  }
94
+ return `${start}:${end}`;
105
95
  }
106
- exports.Range = Range;
107
- class Id extends Entity {
108
- evaluate({ table }) {
109
- const id = getId(this.value);
110
- const { y, x } = table.getPointById(id);
111
- return table.trim({ top: y, left: x, bottom: y, right: x });
112
- }
113
- ref(table, slideY = 0, slideX = 0) {
114
- return table.getAddressById(getId(this.value, false), slideY, slideX);
115
- }
116
- slide(table, slideY = 0, slideX = 0) {
117
- const address = this.ref(table, slideY, slideX);
118
- if (address == null || address.length < 2) {
119
- return "#REF!";
120
- }
121
- return table.getIdByAddress(address);
122
- }
96
+ }
97
+ exports.Range = Range;
98
+ class Id extends Entity {
99
+ evaluate({ table }) {
100
+ const id = getId(this.value);
101
+ const { y, x } = table.getPointById(id);
102
+ return table.trim({ top: y, left: x, bottom: y, right: x });
123
103
  }
124
- exports.Id = Id;
125
- class IdRange extends Entity {
126
- evaluate({ table }) {
127
- const ids = this.value.split(":");
128
- const [p1, p2] = ids
129
- .map((id) => getId(id))
130
- .map((id) => table.getPointById(id));
131
- return table.trim({ top: p1.y, left: p1.x, bottom: p2.y, right: p2.x });
132
- }
133
- range(table, slideY = 0, slideX = 0) {
134
- return this.value
135
- .split(":")
136
- .map((id) => getId(id, false))
137
- .map((id) => table.getAddressById(id, slideY, slideX))
138
- .join(":");
139
- }
140
- slide(table, slideY = 0, slideX = 0) {
141
- const range = this.range(table, slideY, slideX);
142
- return new Range(range).idRange(table);
143
- }
104
+ ref(table, slideY = 0, slideX = 0) {
105
+ return table.getAddressById(getId(this.value, false), slideY, slideX);
144
106
  }
145
- exports.IdRange = IdRange;
146
- class Function {
147
- constructor(name, precedence = 0, args = []) {
148
- this.name = name;
149
- this.precedence = precedence;
150
- this.args = args;
107
+ slide(table, slideY = 0, slideX = 0) {
108
+ const address = this.ref(table, slideY, slideX);
109
+ if (address == null || address.length < 2) {
110
+ return "#REF!";
151
111
  }
152
- evaluate({ table }) {
153
- const name = this.name.toLowerCase();
154
- const Func = table.getFunction(name);
155
- if (Func == null) {
156
- throw new FormulaError("#NAME?", `Unknown function: ${name}`);
112
+ return table.getIdByAddress(address);
113
+ }
114
+ }
115
+ exports.Id = Id;
116
+ class IdRange extends Entity {
117
+ evaluate({ table }) {
118
+ const ids = this.value.split(":");
119
+ const [p1, p2] = ids
120
+ .map((id) => getId(id))
121
+ .map((id) => table.getPointById(id));
122
+ return table.trim({ top: p1.y, left: p1.x, bottom: p2.y, right: p2.x });
123
+ }
124
+ range(table, slideY = 0, slideX = 0) {
125
+ return this.value
126
+ .split(":")
127
+ .map((id) => getId(id, false))
128
+ .map((id) => table.getAddressById(id, slideY, slideX))
129
+ .join(":");
130
+ }
131
+ slide(table, slideY = 0, slideX = 0) {
132
+ const range = this.range(table, slideY, slideX);
133
+ return new Range(range).idRange(table);
134
+ }
135
+ }
136
+ exports.IdRange = IdRange;
137
+ class Function {
138
+ constructor(name, precedence = 0, args = []) {
139
+ this.name = name;
140
+ this.precedence = precedence;
141
+ this.args = args;
142
+ }
143
+ evaluate({ table }) {
144
+ const name = this.name.toLowerCase();
145
+ const Func = table.getFunction(name);
146
+ if (Func == null) {
147
+ throw new FormulaError("#NAME?", `Unknown function: ${name}`);
148
+ }
149
+ const func = new Func({ args: this.args, table });
150
+ return func.call();
151
+ }
152
+ }
153
+ exports.Function = Function;
154
+ const ZERO = new Value(0);
155
+ const INFIX_FUNCTION_NAME_MAP = {
156
+ "+": "add",
157
+ "-": "minus",
158
+ "/": "divide",
159
+ "*": "multiply",
160
+ "^": "power",
161
+ "&": "concat",
162
+ "=": "eq",
163
+ "<>": "ne",
164
+ ">": "gt",
165
+ ">=": "gte",
166
+ "<": "lt",
167
+ "<=": "lte",
168
+ };
169
+ const PREFIX_FUNCTION_NAME_MAP = {
170
+ "-": "uminus",
171
+ };
172
+ class Token {
173
+ constructor(type, entity, precedence = 0) {
174
+ this.type = type;
175
+ this.entity = entity;
176
+ this.precedence = precedence;
177
+ }
178
+ convert() {
179
+ switch (this.type) {
180
+ case "VALUE":
181
+ return new Value(this.entity);
182
+ case "ID":
183
+ return new Id(this.entity);
184
+ case "ID_RANGE":
185
+ return new IdRange(this.entity);
186
+ case "REF":
187
+ return new Ref(this.entity);
188
+ case "RANGE":
189
+ return new Range(this.entity);
190
+ case "INFIX_OPERATOR": {
191
+ const name = INFIX_FUNCTION_NAME_MAP[this.entity];
192
+ return new Function(name, this.precedence);
157
193
  }
158
- const func = new Func({ args: this.args, table });
159
- return func.call();
194
+ case "PREFIX_OPERATOR": {
195
+ const name = PREFIX_FUNCTION_NAME_MAP[this.entity];
196
+ return new Function(name, this.precedence);
197
+ }
198
+ case "FUNCTION":
199
+ return new Function(this.entity);
200
+ case "UNREFERENCED":
201
+ return new Unreferenced(this.entity);
202
+ case "INVALID_REF":
203
+ return new InvalidRef(this.entity);
160
204
  }
161
205
  }
162
- exports.Function = Function;
163
- const ZERO = new Value(0);
164
- const INFIX_FUNCTION_NAME_MAP = {
165
- "+": "add",
166
- "-": "minus",
167
- "/": "divide",
168
- "*": "multiply",
169
- "^": "power",
170
- "&": "concat",
171
- "=": "eq",
172
- "<>": "ne",
173
- ">": "gt",
174
- ">=": "gte",
175
- "<": "lt",
176
- "<=": "lte",
177
- };
178
- const PREFIX_FUNCTION_NAME_MAP = {
179
- "-": "uminus",
180
- };
181
- class Token {
182
- constructor(type, entity, precedence = 0) {
183
- this.type = type;
184
- this.entity = entity;
185
- this.precedence = precedence;
186
- }
187
- convert() {
188
- switch (this.type) {
206
+ }
207
+ exports.Token = Token;
208
+ const isWhiteSpace = (char) => {
209
+ return char === " " || char === "\n" || char === "\t";
210
+ };
211
+ const TOKEN_OPEN = new Token("OPEN", "("), TOKEN_CLOSE = new Token("CLOSE", ")"), TOKEN_COMMA = new Token("COMMA", ","), TOKEN_ADD = new Token("INFIX_OPERATOR", "+", 3), TOKEN_MINUS = new Token("INFIX_OPERATOR", "-", 3), TOKEN_UMINUS = new Token("PREFIX_OPERATOR", "-", 6), TOKEN_DIVIDE = new Token("INFIX_OPERATOR", "/", 4), TOKEN_MULTIPLY = new Token("INFIX_OPERATOR", "*", 4), TOKEN_POWER = new Token("INFIX_OPERATOR", "^", 5), TOKEN_CONCAT = new Token("INFIX_OPERATOR", "&", 4), TOKEN_GTE = new Token("INFIX_OPERATOR", ">=", 2), TOKEN_GT = new Token("INFIX_OPERATOR", ">", 2), TOKEN_LTE = new Token("INFIX_OPERATOR", "<=", 2), TOKEN_LT = new Token("INFIX_OPERATOR", "<", 2), TOKEN_NE = new Token("INFIX_OPERATOR", "<>", 1), TOKEN_EQ = new Token("INFIX_OPERATOR", "=", 1);
212
+ const BOOLS = { ["true"]: true, ["false"]: false };
213
+ class Lexer {
214
+ constructor(formula) {
215
+ this.tokens = [];
216
+ this.formula = formula;
217
+ this.index = 0;
218
+ this.tokens = [];
219
+ }
220
+ isWhiteSpace() {
221
+ return isWhiteSpace(this.formula[this.index]);
222
+ }
223
+ next(base = 1) {
224
+ this.index += base;
225
+ }
226
+ get(base = 0) {
227
+ const c = this.formula[this.index + base];
228
+ return c;
229
+ }
230
+ getToken(base = 0) {
231
+ return this.tokens[this.tokens.length + base];
232
+ }
233
+ stringifyToId(table, slideY = 0, slideX = 0) {
234
+ return this.tokens
235
+ .map((t) => {
236
+ switch (t.type) {
189
237
  case "VALUE":
190
- return new Value(this.entity);
238
+ if (typeof t.entity === "number" || typeof t.entity === "boolean") {
239
+ return t.entity;
240
+ }
241
+ return `"${t.entity}"`;
191
242
  case "ID":
192
- return new Id(this.entity);
243
+ return new Id(t.entity).slide(table, slideY, slideX);
193
244
  case "ID_RANGE":
194
- return new IdRange(this.entity);
245
+ return new IdRange(t.entity).slide(table, slideY, slideX);
195
246
  case "REF":
196
- return new Ref(this.entity);
247
+ return new Ref(t.entity).id(table);
197
248
  case "RANGE":
198
- return new Range(this.entity);
199
- case "INFIX_OPERATOR": {
200
- const name = INFIX_FUNCTION_NAME_MAP[this.entity];
201
- return new Function(name, this.precedence);
202
- }
203
- case "PREFIX_OPERATOR": {
204
- const name = PREFIX_FUNCTION_NAME_MAP[this.entity];
205
- return new Function(name, this.precedence);
206
- }
207
- case "FUNCTION":
208
- return new Function(this.entity);
209
- case "UNREFERENCED":
210
- return new Unreferenced(this.entity);
211
- case "INVALID_REF":
212
- return new InvalidRef(this.entity);
249
+ return new Range(t.entity).idRange(table);
213
250
  }
214
- }
251
+ return t.entity;
252
+ })
253
+ .join("");
215
254
  }
216
- exports.Token = Token;
217
- const isWhiteSpace = (char) => {
218
- return char === " " || char === "\n" || char === "\t";
219
- };
220
- const TOKEN_OPEN = new Token("OPEN", "("), TOKEN_CLOSE = new Token("CLOSE", ")"), TOKEN_COMMA = new Token("COMMA", ","), TOKEN_ADD = new Token("INFIX_OPERATOR", "+", 3), TOKEN_MINUS = new Token("INFIX_OPERATOR", "-", 3), TOKEN_UMINUS = new Token("PREFIX_OPERATOR", "-", 6), TOKEN_DIVIDE = new Token("INFIX_OPERATOR", "/", 4), TOKEN_MULTIPLY = new Token("INFIX_OPERATOR", "*", 4), TOKEN_POWER = new Token("INFIX_OPERATOR", "^", 5), TOKEN_CONCAT = new Token("INFIX_OPERATOR", "&", 4), TOKEN_GTE = new Token("INFIX_OPERATOR", ">=", 2), TOKEN_GT = new Token("INFIX_OPERATOR", ">", 2), TOKEN_LTE = new Token("INFIX_OPERATOR", "<=", 2), TOKEN_LT = new Token("INFIX_OPERATOR", "<", 2), TOKEN_NE = new Token("INFIX_OPERATOR", "<>", 1), TOKEN_EQ = new Token("INFIX_OPERATOR", "=", 1);
221
- const BOOLS = { ["true"]: true, ["false"]: false };
222
- class Lexer {
223
- constructor(formula) {
224
- this.tokens = [];
225
- this.formula = formula;
226
- this.index = 0;
227
- this.tokens = [];
228
- }
229
- isWhiteSpace() {
230
- return isWhiteSpace(this.formula[this.index]);
231
- }
232
- next(base = 1) {
233
- this.index += base;
234
- }
235
- get(base = 0) {
236
- const c = this.formula[this.index + base];
237
- return c;
238
- }
239
- getToken(base = 0) {
240
- return this.tokens[this.tokens.length + base];
241
- }
242
- stringifyToId(table, slideY = 0, slideX = 0) {
243
- return this.tokens
244
- .map((t) => {
245
- switch (t.type) {
246
- case "VALUE":
247
- if (typeof t.entity === "number" || typeof t.entity === "boolean") {
248
- return t.entity;
249
- }
250
- return `"${t.entity}"`;
251
- case "ID":
252
- return new Id(t.entity).slide(table, slideY, slideX);
253
- case "ID_RANGE":
254
- return new IdRange(t.entity).slide(table, slideY, slideX);
255
- case "REF":
256
- return new Ref(t.entity).id(table);
257
- case "RANGE":
258
- return new Range(t.entity).idRange(table);
259
- }
260
- return t.entity;
261
- })
262
- .join("");
263
- }
264
- stringifyToRef(table) {
265
- return this.tokens
266
- .map((t) => {
267
- switch (t.type) {
268
- case "VALUE":
269
- if (typeof t.entity === "number" || typeof t.entity === "boolean") {
270
- return t.entity;
271
- }
272
- return `"${t.entity}"`;
273
- case "ID":
274
- return new Id(t.entity).ref(table);
275
- case "ID_RANGE":
276
- return new IdRange(t.entity).range(table);
255
+ stringifyToRef(table) {
256
+ return this.tokens
257
+ .map((t) => {
258
+ switch (t.type) {
259
+ case "VALUE":
260
+ if (typeof t.entity === "number" || typeof t.entity === "boolean") {
261
+ return t.entity;
262
+ }
263
+ return `"${t.entity}"`;
264
+ case "ID":
265
+ return new Id(t.entity).ref(table);
266
+ case "ID_RANGE":
267
+ return new IdRange(t.entity).range(table);
268
+ }
269
+ return t.entity;
270
+ })
271
+ .join("");
272
+ }
273
+ tokenize() {
274
+ var _a, _b;
275
+ while (this.index <= this.formula.length) {
276
+ this.skipSpaces();
277
+ const char = this.get();
278
+ this.next();
279
+ switch (char) {
280
+ case undefined:
281
+ return;
282
+ case "(":
283
+ this.tokens.push(TOKEN_OPEN);
284
+ continue;
285
+ case ")":
286
+ this.tokens.push(TOKEN_CLOSE);
287
+ continue;
288
+ case ",":
289
+ this.tokens.push(TOKEN_COMMA);
290
+ continue;
291
+ case "+":
292
+ this.tokens.push(TOKEN_ADD);
293
+ continue;
294
+ case "-": {
295
+ const prev1 = (_a = this.getToken(-1)) === null || _a === void 0 ? void 0 : _a.type;
296
+ const prev2 = (_b = this.getToken(-2)) === null || _b === void 0 ? void 0 : _b.type;
297
+ if (prev1 === "INFIX_OPERATOR" ||
298
+ (prev1 === "SPACE" && prev2 === "INFIX_OPERATOR")) {
299
+ this.tokens.push(TOKEN_UMINUS);
300
+ }
301
+ else {
302
+ this.tokens.push(TOKEN_MINUS);
303
+ }
304
+ continue;
277
305
  }
278
- return t.entity;
279
- })
280
- .join("");
281
- }
282
- tokenize() {
283
- var _a, _b;
284
- while (this.index <= this.formula.length) {
285
- this.skipSpaces();
286
- const char = this.get();
287
- this.next();
288
- switch (char) {
289
- case undefined:
290
- return;
291
- case "(":
292
- this.tokens.push(TOKEN_OPEN);
293
- continue;
294
- case ")":
295
- this.tokens.push(TOKEN_CLOSE);
296
- continue;
297
- case ",":
298
- this.tokens.push(TOKEN_COMMA);
299
- continue;
300
- case "+":
301
- this.tokens.push(TOKEN_ADD);
302
- continue;
303
- case "-": {
304
- const prev1 = (_a = this.getToken(-1)) === null || _a === void 0 ? void 0 : _a.type;
305
- const prev2 = (_b = this.getToken(-2)) === null || _b === void 0 ? void 0 : _b.type;
306
- if (prev1 === "INFIX_OPERATOR" ||
307
- (prev1 === "SPACE" && prev2 === "INFIX_OPERATOR")) {
308
- this.tokens.push(TOKEN_UMINUS);
309
- }
310
- else {
311
- this.tokens.push(TOKEN_MINUS);
312
- }
306
+ case "/":
307
+ this.tokens.push(TOKEN_DIVIDE);
308
+ continue;
309
+ case "*":
310
+ this.tokens.push(TOKEN_MULTIPLY);
311
+ continue;
312
+ case "^":
313
+ this.tokens.push(TOKEN_POWER);
314
+ continue;
315
+ case "&":
316
+ this.tokens.push(TOKEN_CONCAT);
317
+ continue;
318
+ case "=":
319
+ this.tokens.push(TOKEN_EQ);
320
+ continue;
321
+ case ">":
322
+ if (this.get() === "=") {
323
+ this.next();
324
+ this.tokens.push(TOKEN_GTE);
313
325
  continue;
314
326
  }
315
- case "/":
316
- this.tokens.push(TOKEN_DIVIDE);
317
- continue;
318
- case "*":
319
- this.tokens.push(TOKEN_MULTIPLY);
320
- continue;
321
- case "^":
322
- this.tokens.push(TOKEN_POWER);
323
- continue;
324
- case "&":
325
- this.tokens.push(TOKEN_CONCAT);
326
- continue;
327
- case "=":
328
- this.tokens.push(TOKEN_EQ);
329
- continue;
330
- case ">":
331
- if (this.get() === "=") {
332
- this.next();
333
- this.tokens.push(TOKEN_GTE);
334
- continue;
335
- }
336
- this.tokens.push(TOKEN_GT);
337
- continue;
338
- case "<":
339
- if (this.get() === "=") {
340
- this.next();
341
- this.tokens.push(TOKEN_LTE);
342
- continue;
343
- }
344
- if (this.get() === ">") {
345
- this.next();
346
- this.tokens.push(TOKEN_NE);
347
- continue;
348
- }
349
- this.tokens.push(TOKEN_LT);
350
- continue;
351
- case '"': {
352
- const buf = this.getString();
353
- this.tokens.push(new Token("VALUE", buf));
327
+ this.tokens.push(TOKEN_GT);
328
+ continue;
329
+ case "<":
330
+ if (this.get() === "=") {
331
+ this.next();
332
+ this.tokens.push(TOKEN_LTE);
354
333
  continue;
355
334
  }
356
- } // switch end
357
- let buf = char;
358
- while (true) {
359
- const c = this.get();
360
- if (c === "(") {
361
- this.tokens.push(new Token("FUNCTION", buf), TOKEN_OPEN);
335
+ if (this.get() === ">") {
362
336
  this.next();
337
+ this.tokens.push(TOKEN_NE);
338
+ continue;
339
+ }
340
+ this.tokens.push(TOKEN_LT);
341
+ continue;
342
+ case '"': {
343
+ const buf = this.getString();
344
+ this.tokens.push(new Token("VALUE", buf));
345
+ continue;
346
+ }
347
+ } // switch end
348
+ let buf = char;
349
+ while (true) {
350
+ const c = this.get();
351
+ if (c === "(") {
352
+ this.tokens.push(new Token("FUNCTION", buf), TOKEN_OPEN);
353
+ this.next();
354
+ break;
355
+ }
356
+ if (c == null || c.match(/[ +\-/*^&=<>),]/)) {
357
+ if (buf.length === 0) {
363
358
  break;
364
359
  }
365
- if (c == null || c.match(/[ +\-/*^&=<>),]/)) {
366
- if (buf.length === 0) {
367
- break;
360
+ if (buf.match(/^[+-]?(\d*[.])?\d+$/)) {
361
+ this.tokens.push(new Token("VALUE", parseFloat(buf)));
362
+ }
363
+ else {
364
+ // @ts-ignore
365
+ const bool = BOOLS[buf.toLowerCase()];
366
+ if (bool != null) {
367
+ this.tokens.push(new Token("VALUE", bool));
368
+ }
369
+ else if (buf.startsWith("#")) {
370
+ if (buf === "#REF!") {
371
+ this.tokens.push(new Token("UNREFERENCED", buf));
372
+ }
373
+ else if (buf.indexOf(":") !== -1) {
374
+ this.tokens.push(new Token("ID_RANGE", buf));
375
+ }
376
+ else {
377
+ this.tokens.push(new Token("ID", buf));
378
+ }
368
379
  }
369
- if (buf.match(/^[+-]?(\d*[.])?\d+$/)) {
370
- this.tokens.push(new Token("VALUE", parseFloat(buf)));
380
+ else if (buf.indexOf(":") !== -1) {
381
+ this.tokens.push(new Token("RANGE", buf));
371
382
  }
372
383
  else {
373
384
  // @ts-ignore
374
- const bool = BOOLS[buf.toLowerCase()];
375
- if (bool != null) {
376
- this.tokens.push(new Token("VALUE", bool));
377
- }
378
- else if (buf.startsWith("#")) {
379
- if (buf === "#REF!") {
380
- this.tokens.push(new Token("UNREFERENCED", buf));
381
- }
382
- else if (buf.indexOf(":") !== -1) {
383
- this.tokens.push(new Token("ID_RANGE", buf));
384
- }
385
- else {
386
- this.tokens.push(new Token("ID", buf));
387
- }
388
- }
389
- else if (buf.indexOf(":") !== -1) {
390
- this.tokens.push(new Token("RANGE", buf));
385
+ if (isNaN(buf[buf.length - 1])) {
386
+ this.tokens.push(new Token("INVALID_REF", buf));
391
387
  }
392
388
  else {
393
- // @ts-ignore
394
- if (isNaN(buf[buf.length - 1])) {
395
- this.tokens.push(new Token("INVALID_REF", buf));
396
- }
397
- else {
398
- this.tokens.push(new Token("REF", buf));
399
- }
389
+ this.tokens.push(new Token("REF", buf));
400
390
  }
401
391
  }
402
- break;
403
392
  }
404
- buf += c;
405
- this.next();
393
+ break;
406
394
  }
395
+ buf += c;
396
+ this.next();
407
397
  }
408
398
  }
409
- skipSpaces() {
410
- let space = "";
411
- while (this.isWhiteSpace()) {
412
- space += this.formula[this.index++];
413
- }
414
- if (space !== "") {
415
- this.tokens.push(new Token("SPACE", space));
416
- }
399
+ }
400
+ skipSpaces() {
401
+ let space = "";
402
+ while (this.isWhiteSpace()) {
403
+ space += this.formula[this.index++];
417
404
  }
418
- getString() {
419
- let buf = "";
420
- while (true) {
421
- const c = this.get();
422
- this.next();
423
- if (c == null) {
424
- break;
425
- }
426
- if (c === '"') {
427
- if (this.get() === '"') {
428
- // escape
429
- buf += '"';
430
- this.next();
431
- continue;
432
- }
433
- else {
434
- break;
435
- }
405
+ if (space !== "") {
406
+ this.tokens.push(new Token("SPACE", space));
407
+ }
408
+ }
409
+ getString() {
410
+ let buf = "";
411
+ while (true) {
412
+ const c = this.get();
413
+ this.next();
414
+ if (c == null) {
415
+ break;
416
+ }
417
+ if (c === '"') {
418
+ if (this.get() === '"') {
419
+ // escape
420
+ buf += '"';
421
+ this.next();
422
+ continue;
436
423
  }
437
424
  else {
438
- buf += c;
425
+ break;
439
426
  }
440
427
  }
441
- return buf;
428
+ else {
429
+ buf += c;
430
+ }
442
431
  }
432
+ return buf;
443
433
  }
444
- exports.Lexer = Lexer;
445
- class Parser {
446
- constructor(tokens) {
447
- this.index = 0;
448
- this.depth = 0;
449
- this.tokens = tokens;
450
- }
451
- build() {
452
- const { expr } = this.parse(false);
453
- return expr;
454
- }
455
- parse(underFunction) {
456
- const stack = [];
457
- let lastOperator;
458
- const complement = (hasNext = false) => {
459
- if (lastOperator) {
460
- const outer = stack.pop();
461
- lastOperator.args.push(outer);
462
- }
463
- return { hasNext, expr: stack.shift() };
464
- };
465
- while (this.tokens.length > this.index) {
466
- const token = this.tokens[this.index++];
467
- if (token.type === "SPACE") {
468
- continue;
434
+ }
435
+ exports.Lexer = Lexer;
436
+ class Parser {
437
+ constructor(tokens) {
438
+ this.index = 0;
439
+ this.depth = 0;
440
+ this.tokens = tokens;
441
+ }
442
+ build() {
443
+ const { expr } = this.parse(false);
444
+ return expr;
445
+ }
446
+ parse(underFunction) {
447
+ const stack = [];
448
+ let lastOperator;
449
+ const complement = (hasNext = false) => {
450
+ if (lastOperator) {
451
+ const outer = stack.pop();
452
+ lastOperator.args.push(outer);
453
+ }
454
+ return { hasNext, expr: stack.shift() };
455
+ };
456
+ while (this.tokens.length > this.index) {
457
+ const token = this.tokens[this.index++];
458
+ if (token.type === "SPACE") {
459
+ continue;
460
+ }
461
+ if (token.type === "COMMA") {
462
+ if (!underFunction) {
463
+ throw new FormulaError("#ERROR!", "Invalid comma");
469
464
  }
470
- if (token.type === "COMMA") {
471
- if (!underFunction) {
472
- throw new FormulaError("#ERROR!", "Invalid comma");
465
+ return complement(true);
466
+ }
467
+ else if (token.type === "VALUE" ||
468
+ token.type === "ID" ||
469
+ token.type === "ID_RANGE" ||
470
+ token.type === "REF" ||
471
+ token.type === "RANGE" ||
472
+ token.type === "UNREFERENCED" ||
473
+ token.type === "INVALID_REF") {
474
+ const expr = token.convert();
475
+ stack.push(expr);
476
+ }
477
+ else if (token.type === "FUNCTION") {
478
+ this.index++;
479
+ this.depth++;
480
+ const func = token.convert();
481
+ stack.push(func);
482
+ while (true) {
483
+ const { expr, hasNext } = this.parse(true);
484
+ if (expr) {
485
+ func.args.push(expr);
473
486
  }
474
- return complement(true);
475
- }
476
- else if (token.type === "VALUE" ||
477
- token.type === "ID" ||
478
- token.type === "ID_RANGE" ||
479
- token.type === "REF" ||
480
- token.type === "RANGE" ||
481
- token.type === "UNREFERENCED" ||
482
- token.type === "INVALID_REF") {
483
- const expr = token.convert();
484
- stack.push(expr);
485
- }
486
- else if (token.type === "FUNCTION") {
487
- this.index++;
488
- this.depth++;
489
- const func = token.convert();
490
- stack.push(func);
491
- while (true) {
492
- const { expr, hasNext } = this.parse(true);
493
- if (expr) {
494
- func.args.push(expr);
495
- }
496
- if (!hasNext) {
497
- break;
498
- }
487
+ if (!hasNext) {
488
+ break;
499
489
  }
500
490
  }
501
- else if (token.type === "OPEN") {
502
- this.depth++;
503
- const { expr } = this.parse(false);
504
- stack.push(expr);
505
- }
506
- else if (token.type === "CLOSE") {
507
- if (this.depth-- === 0) {
508
- throw new FormulaError("#ERROR!", "Unexpected end paren");
509
- }
510
- return complement();
491
+ }
492
+ else if (token.type === "OPEN") {
493
+ this.depth++;
494
+ const { expr } = this.parse(false);
495
+ stack.push(expr);
496
+ }
497
+ else if (token.type === "CLOSE") {
498
+ if (this.depth-- === 0) {
499
+ throw new FormulaError("#ERROR!", "Unexpected end paren");
511
500
  }
512
- else if (token.type === "INFIX_OPERATOR") {
513
- const operator = token.convert();
514
- let left = stack.pop();
515
- if (left == null) {
516
- if (operator.name === "minus" || operator.name === "add") {
517
- left = ZERO;
518
- }
519
- else {
520
- throw new FormulaError("#ERROR!", "Missing left expression");
521
- }
522
- }
523
- if (lastOperator == null) {
524
- operator.args.push(left);
525
- stack.unshift(operator);
526
- }
527
- else if (operator.precedence > lastOperator.precedence) {
528
- operator.args.push(left);
529
- lastOperator.args.push(operator);
530
- stack.unshift(lastOperator);
501
+ return complement();
502
+ }
503
+ else if (token.type === "INFIX_OPERATOR") {
504
+ const operator = token.convert();
505
+ let left = stack.pop();
506
+ if (left == null) {
507
+ if (operator.name === "minus" || operator.name === "add") {
508
+ left = ZERO;
531
509
  }
532
510
  else {
533
- const outer = stack.shift();
534
- operator.args.push(outer);
535
- lastOperator.args.push(left);
536
- stack.unshift(operator);
511
+ throw new FormulaError("#ERROR!", "Missing left expression");
537
512
  }
538
- lastOperator = operator;
539
513
  }
540
- else if (token.type === "PREFIX_OPERATOR") {
541
- const operator = token.convert();
542
- if (lastOperator) {
543
- lastOperator.args.push(operator);
544
- }
545
- else {
546
- stack.unshift(operator);
547
- }
548
- lastOperator = operator;
514
+ if (lastOperator == null) {
515
+ operator.args.push(left);
516
+ stack.unshift(operator);
517
+ }
518
+ else if (operator.precedence > lastOperator.precedence) {
519
+ operator.args.push(left);
520
+ lastOperator.args.push(operator);
521
+ stack.unshift(lastOperator);
522
+ }
523
+ else {
524
+ const outer = stack.shift();
525
+ operator.args.push(outer);
526
+ lastOperator.args.push(left);
527
+ stack.unshift(operator);
549
528
  }
529
+ lastOperator = operator;
530
+ }
531
+ else if (token.type === "PREFIX_OPERATOR") {
532
+ const operator = token.convert();
533
+ if (lastOperator) {
534
+ lastOperator.args.push(operator);
535
+ }
536
+ else {
537
+ stack.unshift(operator);
538
+ }
539
+ lastOperator = operator;
550
540
  }
551
- return complement();
552
541
  }
542
+ return complement();
553
543
  }
554
- exports.Parser = Parser;
555
- const convertFormulaAbsolute = ({ value, table, slideY = 0, slideX = 0, }) => {
556
- if (typeof value === "string" || value instanceof String) {
557
- if (value.charAt(0) === "=") {
558
- const lexer = new Lexer(value.substring(1));
559
- lexer.tokenize();
560
- return "=" + lexer.stringifyToId(table, slideY, slideX);
561
- }
544
+ }
545
+ exports.Parser = Parser;
546
+ const convertFormulaAbsolute = ({ value, table, slideY = 0, slideX = 0, }) => {
547
+ if (typeof value === "string" || value instanceof String) {
548
+ if (value.charAt(0) === "=") {
549
+ const lexer = new Lexer(value.substring(1));
550
+ lexer.tokenize();
551
+ return "=" + lexer.stringifyToId(table, slideY, slideX);
562
552
  }
563
- return value;
564
- };
565
- exports.convertFormulaAbsolute = convertFormulaAbsolute;
566
- });
553
+ }
554
+ return value;
555
+ };
556
+ exports.convertFormulaAbsolute = convertFormulaAbsolute;
567
557
  //# sourceMappingURL=evaluator.js.map