@rsconcept/domain 1.0.0 → 1.2.0

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 (185) hide show
  1. package/README.md +3 -3
  2. package/dist/analyzer-DlSq3Y3r.d.ts +39 -0
  3. package/dist/arguments-extractor-1acwjQNc.d.ts +38 -0
  4. package/dist/ast-C8sIpKdL.d.ts +51 -0
  5. package/dist/ast-annotations-BiMjkKvz.d.ts +16 -0
  6. package/dist/branded-ZlzIcxzu.d.ts +9 -0
  7. package/dist/calculator-C9W2jkSx.d.ts +39 -0
  8. package/dist/cctext/index.d.ts +2 -1
  9. package/dist/cctext/index.js +2 -42
  10. package/dist/cctext/language-api.d.ts +10 -12
  11. package/dist/cctext/language-api.js +157 -227
  12. package/dist/cctext/language-api.js.map +1 -1
  13. package/dist/cctext/language.d.ts +24 -22
  14. package/dist/cctext/language.js +43 -39
  15. package/dist/cctext/language.js.map +1 -1
  16. package/dist/error-E1LVq_3w.d.ts +87 -0
  17. package/dist/graph/graph.d.ts +2 -62
  18. package/dist/graph/graph.js +339 -382
  19. package/dist/graph/graph.js.map +1 -1
  20. package/dist/graph/index.d.ts +2 -1
  21. package/dist/graph/index.js +2 -384
  22. package/dist/graph-DR8rL2o3.d.ts +64 -0
  23. package/dist/hash-Y8I4c6Al.d.ts +8 -0
  24. package/dist/index-BKZ67WMa.d.ts +1 -0
  25. package/dist/index-BVVgDSdq.d.ts +1 -0
  26. package/dist/index-DmtQKWjk.d.ts +1 -0
  27. package/dist/index-_6s0AX1B.d.ts +1 -0
  28. package/dist/index.d.ts +27 -28
  29. package/dist/index.js +23 -5851
  30. package/dist/lezer-tree-iS7LpLBJ.d.ts +14 -0
  31. package/dist/library/folder-tree.d.ts +22 -20
  32. package/dist/library/folder-tree.js +108 -130
  33. package/dist/library/folder-tree.js.map +1 -1
  34. package/dist/library/index.d.ts +8 -17
  35. package/dist/library/index.js +7 -2800
  36. package/dist/library/library-api.d.ts +3 -1
  37. package/dist/library/library-api.js +9 -8
  38. package/dist/library/library-api.js.map +1 -1
  39. package/dist/library/library.d.ts +2 -56
  40. package/dist/library/library.js +23 -19
  41. package/dist/library/library.js.map +1 -1
  42. package/dist/library/oss-api.d.ts +26 -37
  43. package/dist/library/oss-api.js +258 -1096
  44. package/dist/library/oss-api.js.map +1 -1
  45. package/dist/library/oss-layout-api.d.ts +28 -28
  46. package/dist/library/oss-layout-api.js +239 -316
  47. package/dist/library/oss-layout-api.js.map +1 -1
  48. package/dist/library/oss-layout.d.ts +2 -25
  49. package/dist/library/oss-layout.js +1 -1
  50. package/dist/library/oss.d.ts +87 -89
  51. package/dist/library/oss.js +27 -26
  52. package/dist/library/oss.js.map +1 -1
  53. package/dist/library/rsengine.d.ts +100 -106
  54. package/dist/library/rsengine.js +439 -2599
  55. package/dist/library/rsengine.js.map +1 -1
  56. package/dist/library/rsform-api.d.ts +11 -16
  57. package/dist/library/rsform-api.js +313 -825
  58. package/dist/library/rsform-api.js.map +1 -1
  59. package/dist/library/rsform.d.ts +159 -167
  60. package/dist/library/rsform.js +29 -28
  61. package/dist/library/rsform.js.map +1 -1
  62. package/dist/library/rsmodel-api.d.ts +8 -15
  63. package/dist/library/rsmodel-api.js +172 -813
  64. package/dist/library/rsmodel-api.js.map +1 -1
  65. package/dist/library/rsmodel.d.ts +27 -33
  66. package/dist/library/rsmodel.js +16 -23
  67. package/dist/library/rsmodel.js.map +1 -1
  68. package/dist/library/structure-planner.d.ts +20 -26
  69. package/dist/library/structure-planner.js +106 -474
  70. package/dist/library/structure-planner.js.map +1 -1
  71. package/dist/library-CYun28Xz.d.ts +58 -0
  72. package/dist/oss-layout-3glgAqfn.d.ts +27 -0
  73. package/dist/parser-Bwd8LxJ1.d.ts +7 -0
  74. package/dist/parsing/ast.d.ts +2 -49
  75. package/dist/parsing/ast.js +68 -76
  76. package/dist/parsing/ast.js.map +1 -1
  77. package/dist/parsing/index.d.ts +3 -3
  78. package/dist/parsing/index.js +3 -141
  79. package/dist/parsing/lezer-tree.d.ts +2 -13
  80. package/dist/parsing/lezer-tree.js +50 -43
  81. package/dist/parsing/lezer-tree.js.map +1 -1
  82. package/dist/rslang/api.d.ts +9 -14
  83. package/dist/rslang/api.js +114 -827
  84. package/dist/rslang/api.js.map +1 -1
  85. package/dist/rslang/ast-annotations.d.ts +2 -18
  86. package/dist/rslang/ast-annotations.js +34 -45
  87. package/dist/rslang/ast-annotations.js.map +1 -1
  88. package/dist/rslang/error.d.ts +2 -85
  89. package/dist/rslang/error.js +88 -150
  90. package/dist/rslang/error.js.map +1 -1
  91. package/dist/rslang/eval/calculator.d.ts +2 -43
  92. package/dist/rslang/eval/calculator.js +81 -1636
  93. package/dist/rslang/eval/calculator.js.map +1 -1
  94. package/dist/rslang/eval/evaluation-cache.d.ts +22 -26
  95. package/dist/rslang/eval/evaluation-cache.js +168 -287
  96. package/dist/rslang/eval/evaluation-cache.js.map +1 -1
  97. package/dist/rslang/eval/evaluator.d.ts +59 -63
  98. package/dist/rslang/eval/evaluator.js +602 -1509
  99. package/dist/rslang/eval/evaluator.js.map +1 -1
  100. package/dist/rslang/eval/value-api.d.ts +2 -48
  101. package/dist/rslang/eval/value-api.js +2 -490
  102. package/dist/rslang/eval/value.d.ts +2 -36
  103. package/dist/rslang/eval/value.js +2 -118
  104. package/dist/rslang/index.d.ts +14 -17
  105. package/dist/rslang/index.js +12 -4314
  106. package/dist/rslang/labels.d.ts +6 -6
  107. package/dist/rslang/labels.js +139 -305
  108. package/dist/rslang/labels.js.map +1 -1
  109. package/dist/rslang/parser/expression-generator.d.ts +5 -5
  110. package/dist/rslang/parser/expression-generator.js +248 -446
  111. package/dist/rslang/parser/expression-generator.js.map +1 -1
  112. package/dist/rslang/parser/normalize.d.ts +4 -8
  113. package/dist/rslang/parser/normalize.js +286 -481
  114. package/dist/rslang/parser/normalize.js.map +1 -1
  115. package/dist/rslang/parser/parser.d.ts +2 -5
  116. package/dist/rslang/parser/parser.js +30 -21
  117. package/dist/rslang/parser/parser.js.map +1 -1
  118. package/dist/rslang/parser/parser.terms.d.ts +43 -41
  119. package/dist/rslang/parser/parser.terms.js +44 -83
  120. package/dist/rslang/parser/parser.terms.js.map +1 -1
  121. package/dist/rslang/parser/syntax-errors.d.ts +5 -8
  122. package/dist/rslang/parser/syntax-errors.js +113 -382
  123. package/dist/rslang/parser/syntax-errors.js.map +1 -1
  124. package/dist/rslang/parser/token.d.ts +2 -79
  125. package/dist/rslang/parser/token.js +81 -93
  126. package/dist/rslang/parser/token.js.map +1 -1
  127. package/dist/rslang/semantic/analyzer.d.ts +2 -39
  128. package/dist/rslang/semantic/analyzer.js +186 -2600
  129. package/dist/rslang/semantic/analyzer.js.map +1 -1
  130. package/dist/rslang/semantic/arguments-extractor.d.ts +2 -42
  131. package/dist/rslang/semantic/arguments-extractor.js +202 -361
  132. package/dist/rslang/semantic/arguments-extractor.js.map +1 -1
  133. package/dist/rslang/semantic/type-auditor.d.ts +64 -68
  134. package/dist/rslang/semantic/type-auditor.js +594 -1564
  135. package/dist/rslang/semantic/type-auditor.js.map +1 -1
  136. package/dist/rslang/semantic/typification-api.d.ts +4 -7
  137. package/dist/rslang/semantic/typification-api.js +162 -303
  138. package/dist/rslang/semantic/typification-api.js.map +1 -1
  139. package/dist/rslang/semantic/typification-parser.d.ts +2 -12
  140. package/dist/rslang/semantic/typification-parser.js +165 -219
  141. package/dist/rslang/semantic/typification-parser.js.map +1 -1
  142. package/dist/rslang/semantic/typification.d.ts +2 -119
  143. package/dist/rslang/semantic/typification.js +66 -52
  144. package/dist/rslang/semantic/typification.js.map +1 -1
  145. package/dist/rslang/semantic/value-auditor.d.ts +32 -38
  146. package/dist/rslang/semantic/value-auditor.js +206 -518
  147. package/dist/rslang/semantic/value-auditor.js.map +1 -1
  148. package/dist/rslang/semantic/value-class.d.ts +2 -10
  149. package/dist/rslang/semantic/value-class.js +8 -7
  150. package/dist/rslang/semantic/value-class.js.map +1 -1
  151. package/dist/rslang/typification-graph.d.ts +2 -33
  152. package/dist/rslang/typification-graph.js +94 -306
  153. package/dist/rslang/typification-graph.js.map +1 -1
  154. package/dist/shared/branded.d.ts +2 -7
  155. package/dist/shared/branded.js +1 -1
  156. package/dist/shared/hash.d.ts +2 -6
  157. package/dist/shared/hash.js +13 -13
  158. package/dist/shared/hash.js.map +1 -1
  159. package/dist/shared/index.d.ts +3 -2
  160. package/dist/shared/index.js +2 -18
  161. package/dist/token-DeXAmzwr.d.ts +81 -0
  162. package/dist/typification-Dk-fisgO.d.ts +120 -0
  163. package/dist/typification-graph-6HcZ-rKH.d.ts +30 -0
  164. package/dist/typification-parser-BBVx1RxP.d.ts +13 -0
  165. package/dist/value-B8UtCqaK.js +366 -0
  166. package/dist/value-B8UtCqaK.js.map +1 -0
  167. package/dist/value-CTjX6825.d.ts +33 -0
  168. package/dist/value-api-Bw-SgaYY.d.ts +49 -0
  169. package/dist/value-class-CNI-lqXJ.d.ts +12 -0
  170. package/package.json +8 -8
  171. package/src/library/oss-api.test.ts +76 -0
  172. package/src/library/oss-api.ts +4 -1
  173. package/src/library/rsform-api.test.ts +24 -0
  174. package/src/library/rsform-api.ts +12 -4
  175. package/dist/cctext/index.js.map +0 -1
  176. package/dist/graph/index.js.map +0 -1
  177. package/dist/index.js.map +0 -1
  178. package/dist/library/index.js.map +0 -1
  179. package/dist/library/oss-layout.js.map +0 -1
  180. package/dist/parsing/index.js.map +0 -1
  181. package/dist/rslang/eval/value-api.js.map +0 -1
  182. package/dist/rslang/eval/value.js.map +0 -1
  183. package/dist/rslang/index.js.map +0 -1
  184. package/dist/shared/branded.js.map +0 -1
  185. package/dist/shared/index.js.map +0 -1
@@ -1,490 +1,2 @@
1
- // src/shared/hash.ts
2
- function applyHash_fnv1a(str) {
3
- let hash = 2166136261;
4
- for (let i = 0; i < str.length; i++) {
5
- hash ^= str.charCodeAt(i);
6
- hash = Math.imul(hash, 16777619);
7
- }
8
- return hash >>> 0;
9
- }
10
- function generateStub(text) {
11
- const hash = applyHash_fnv1a(text);
12
- return hash.toString(16).padStart(8, "0").slice(0, 8);
13
- }
14
-
15
- // src/rslang/semantic/typification.ts
16
- var TypeID = {
17
- anyTypification: 1,
18
- integer: 2,
19
- basic: 3,
20
- tuple: 4,
21
- collection: 5,
22
- logic: 6,
23
- function: 7,
24
- predicate: 8
25
- };
26
- var LogicT = { typeID: TypeID.logic };
27
- var IntegerT = {
28
- typeID: TypeID.integer,
29
- isOrdered: true,
30
- isArithmetic: true,
31
- isIntegerCompatible: true
32
- };
33
- var AnyTypificationT = { typeID: TypeID.anyTypification };
34
- var EmptySetT = bool(AnyTypificationT);
35
- function bool(base) {
36
- return { typeID: TypeID.collection, base };
37
- }
38
-
39
- // src/rslang/eval/value.ts
40
- var TUPLE_ID = -111;
41
- var INVALID_ELEMENT = -1;
42
- var VALUE_TRUE = 1;
43
- var VALUE_FALSE = 0;
44
- var SET_INFINITY = 1e7;
45
- var BOOL_INFINITY = 18;
46
- function makeValuePath(path) {
47
- return path;
48
- }
49
- var EmptySetV = [];
50
- function compare(v1, v2) {
51
- const stack1 = [v1];
52
- const stack2 = [v2];
53
- while (stack1.length > 0 && stack2.length > 0) {
54
- const el1 = stack1.pop();
55
- const el2 = stack2.pop();
56
- if (el1 === el2) {
57
- continue;
58
- }
59
- const type1 = typeof el1;
60
- const type2 = typeof el2;
61
- if (type1 === "number" && type2 === "number") {
62
- const numDiff = el1 - el2;
63
- if (numDiff !== 0) return numDiff;
64
- continue;
65
- }
66
- const isArray1 = Array.isArray(el1);
67
- const isArray2 = Array.isArray(el2);
68
- if (!isArray1 || !isArray2) {
69
- throw new Error(`Cannot compare different types ${printValue(el1)} and ${printValue(el2)}`);
70
- }
71
- const arr1 = el1;
72
- const arr2 = el2;
73
- const len1 = arr1.length;
74
- const len2 = arr2.length;
75
- if (len1 !== len2) {
76
- return len1 - len2;
77
- }
78
- for (let i = len1 - 1; i >= 0; i--) {
79
- stack1.push(arr1[i]);
80
- stack2.push(arr2[i]);
81
- }
82
- }
83
- return 0;
84
- }
85
- function tuple(components) {
86
- return [TUPLE_ID, ...components];
87
- }
88
- function set(elements) {
89
- const sorted = [...elements].sort(compare);
90
- for (let i = 1; i < sorted.length; ) {
91
- if (compare(sorted[i - 1], sorted[i]) === 0) {
92
- sorted.splice(i, 1);
93
- } else {
94
- i++;
95
- }
96
- }
97
- return sorted;
98
- }
99
-
100
- // src/rslang/eval/value-api.ts
101
- function cartesianProduct(factors) {
102
- const cardinality = factors.reduce((acc, f) => acc * f.length, 1);
103
- if (cardinality > SET_INFINITY) {
104
- return null;
105
- }
106
- if (cardinality === 0 || factors.length === 0) {
107
- return EmptySetV;
108
- }
109
- let accumulator = [[]];
110
- for (const factor of factors) {
111
- const next = [];
112
- for (const prefix of accumulator) {
113
- for (const value of factor) {
114
- next.push([...prefix, value]);
115
- }
116
- }
117
- accumulator = next;
118
- }
119
- return accumulator.map(tuple);
120
- }
121
- function boolean(base) {
122
- if (base.length > BOOL_INFINITY) {
123
- return null;
124
- }
125
- return powerset(base);
126
- }
127
- function powerset(arr) {
128
- const result = [[]];
129
- if (arr.length === 0) {
130
- return result;
131
- }
132
- let current = [[]];
133
- let maxIndex = [-1];
134
- while (current.length > 0) {
135
- const next = [];
136
- const nextMaxIndex = [];
137
- for (let i = 0; i < current.length; i++) {
138
- for (let j = maxIndex[i] + 1; j < arr.length; j++) {
139
- const subset = [...current[i], arr[j]];
140
- result.push(subset);
141
- if (j < arr.length - 1) {
142
- next.push(subset);
143
- nextMaxIndex.push(j);
144
- }
145
- }
146
- }
147
- current = next;
148
- maxIndex = nextMaxIndex;
149
- }
150
- return result;
151
- }
152
- function contains(setData, element) {
153
- let left = 0;
154
- let right = setData.length - 1;
155
- while (left <= right) {
156
- const mid = Math.floor((left + right) / 2);
157
- const cmp = compare(setData[mid], element);
158
- if (cmp === 0) {
159
- return true;
160
- } else if (cmp < 0) {
161
- left = mid + 1;
162
- } else {
163
- right = mid - 1;
164
- }
165
- }
166
- return false;
167
- }
168
- function isSubsetOrEq(a, b) {
169
- let i = 0, j = 0;
170
- while (i < a.length && j < b.length) {
171
- const cmp = compare(a[i], b[j]);
172
- if (cmp === 0) {
173
- i++;
174
- j++;
175
- } else if (cmp > 0) {
176
- j++;
177
- } else {
178
- return false;
179
- }
180
- }
181
- return i === a.length;
182
- }
183
- function reduce(target) {
184
- const result = [];
185
- for (const element of target) {
186
- result.push(...element);
187
- }
188
- return set(result);
189
- }
190
- function setUnion(set1, set2) {
191
- const result = [];
192
- let i = 0, j = 0;
193
- while (i < set1.length && j < set2.length) {
194
- const cmp = compare(set1[i], set2[j]);
195
- if (cmp < 0) {
196
- result.push(set1[i]);
197
- i++;
198
- } else if (cmp > 0) {
199
- result.push(set2[j]);
200
- j++;
201
- } else {
202
- result.push(set1[i]);
203
- i++;
204
- j++;
205
- }
206
- }
207
- while (i < set1.length) {
208
- result.push(set1[i]);
209
- i++;
210
- }
211
- while (j < set2.length) {
212
- result.push(set2[j]);
213
- j++;
214
- }
215
- return result;
216
- }
217
- function setIntersection(set1, set2) {
218
- const result = [];
219
- for (let i = 0, j = 0; i < set1.length && j < set2.length; ) {
220
- const cmp = compare(set1[i], set2[j]);
221
- if (cmp < 0) {
222
- i++;
223
- } else if (cmp > 0) {
224
- j++;
225
- } else {
226
- result.push(set1[i]);
227
- i++;
228
- j++;
229
- }
230
- }
231
- return result;
232
- }
233
- function setDiff(set1, set2) {
234
- const result = [];
235
- let i = 0, j = 0;
236
- while (i < set1.length && j < set2.length) {
237
- const cmp = compare(set1[i], set2[j]);
238
- if (cmp < 0) {
239
- result.push(set1[i]);
240
- i++;
241
- } else if (cmp > 0) {
242
- j++;
243
- } else {
244
- i++;
245
- j++;
246
- }
247
- }
248
- while (i < set1.length) {
249
- result.push(set1[i]);
250
- i++;
251
- }
252
- return result;
253
- }
254
- function setSymDiff(set1, set2) {
255
- const result = [];
256
- let i = 0, j = 0;
257
- while (i < set1.length && j < set2.length) {
258
- const cmp = compare(set1[i], set2[j]);
259
- if (cmp < 0) {
260
- result.push(set1[i]);
261
- i++;
262
- } else if (cmp > 0) {
263
- result.push(set2[j]);
264
- j++;
265
- } else {
266
- i++;
267
- j++;
268
- }
269
- }
270
- while (i < set1.length) {
271
- result.push(set1[i]);
272
- i++;
273
- }
274
- while (j < set2.length) {
275
- result.push(set2[j]);
276
- j++;
277
- }
278
- return result;
279
- }
280
- function projection(target, indices) {
281
- const projectedElements = target.map((element) => {
282
- const newComponents = indices.map((idx) => element[idx]);
283
- return indices.length === 1 ? newComponents[0] : tuple(newComponents);
284
- });
285
- return set(projectedElements);
286
- }
287
- function printValue(data) {
288
- if (!Array.isArray(data)) {
289
- return String(data);
290
- }
291
- const len = data.length;
292
- if (data.length === 0) {
293
- return "{}";
294
- }
295
- const isTuple = data[0] === TUPLE_ID;
296
- const start = isTuple ? 1 : 0;
297
- let result = isTuple ? "(" : "{";
298
- for (let i = start; i < len; i++) {
299
- if (i > start) result += ", ";
300
- result += printValue(data[i]);
301
- }
302
- result += isTuple ? ")" : "}";
303
- return result;
304
- }
305
- function valueStub(value) {
306
- if (value == null) {
307
- return "";
308
- }
309
- const str = printValue(value);
310
- return generateStub(str);
311
- }
312
- function isSetValue(data) {
313
- return Array.isArray(data) && (data.length === 0 || data[0] !== TUPLE_ID);
314
- }
315
- function isTupleValue(data) {
316
- return Array.isArray(data) && data.length > 1 && data[0] === TUPLE_ID;
317
- }
318
- function normalizeValue(data) {
319
- if (!Array.isArray(data) || data.length === 0) {
320
- return;
321
- }
322
- if (data[0] === TUPLE_ID) {
323
- for (let i2 = 1; i2 < data.length; i2++) {
324
- normalizeValue(data[i2]);
325
- }
326
- return;
327
- }
328
- for (const item of data) {
329
- normalizeValue(item);
330
- }
331
- data.sort((a, b) => compare(a, b));
332
- let i = 1;
333
- while (i < data.length) {
334
- if (compare(data[i - 1], data[i]) === 0) {
335
- data.splice(i, 1);
336
- } else {
337
- i++;
338
- }
339
- }
340
- }
341
- function validateValue(value, type, basics) {
342
- switch (type.typeID) {
343
- case TypeID.integer:
344
- return typeof value === "number";
345
- case TypeID.logic: {
346
- if (typeof value !== "number") {
347
- return false;
348
- }
349
- return value === VALUE_TRUE || value === VALUE_FALSE;
350
- }
351
- case TypeID.basic: {
352
- if (typeof value !== "number") {
353
- return false;
354
- }
355
- const domain = basics.get(type.baseID);
356
- return !!domain && Array.isArray(domain) && domain.includes(value);
357
- }
358
- case TypeID.tuple: {
359
- if (!Array.isArray(value) || value.length !== type.factors.length + 1 || value[0] !== TUPLE_ID) {
360
- return false;
361
- }
362
- for (let i = 0; i < type.factors.length; i++) {
363
- if (!validateValue(value[i + 1], type.factors[i], basics)) {
364
- return false;
365
- }
366
- }
367
- return true;
368
- }
369
- case TypeID.collection: {
370
- if (!isSetValue(value)) {
371
- return false;
372
- }
373
- for (const item of value) {
374
- if (!validateValue(item, type.base, basics)) {
375
- return false;
376
- }
377
- }
378
- return true;
379
- }
380
- case TypeID.anyTypification:
381
- case TypeID.predicate:
382
- case TypeID.function:
383
- return false;
384
- }
385
- }
386
- function convertPathToType(path, type) {
387
- const result = [];
388
- if (path.length === 0) {
389
- return result;
390
- }
391
- let curType = type;
392
- let index = 0;
393
- while (index < path.length) {
394
- switch (curType.typeID) {
395
- case TypeID.collection: {
396
- result.push(0);
397
- curType = curType.base;
398
- index++;
399
- break;
400
- }
401
- case TypeID.tuple: {
402
- const tupleIdx = path[index];
403
- if (typeof tupleIdx !== "number" || tupleIdx < 1 || tupleIdx > curType.factors.length) {
404
- return null;
405
- }
406
- result.push(tupleIdx);
407
- curType = curType.factors[tupleIdx - 1];
408
- index++;
409
- break;
410
- }
411
- case TypeID.basic:
412
- case TypeID.integer:
413
- case TypeID.anyTypification:
414
- return null;
415
- }
416
- }
417
- return result;
418
- }
419
- function extractValue(target, path) {
420
- let current = target;
421
- let i = 0;
422
- while (i < path.length) {
423
- if (!Array.isArray(current) || current.length <= path[i]) {
424
- return null;
425
- }
426
- current = current[path[i]];
427
- i++;
428
- }
429
- return current;
430
- }
431
- function makeDefaultValue(type) {
432
- switch (type.typeID) {
433
- case TypeID.anyTypification:
434
- case TypeID.integer:
435
- case TypeID.basic:
436
- return INVALID_ELEMENT;
437
- case TypeID.collection:
438
- return [];
439
- case TypeID.tuple:
440
- return tuple(type.factors.map((item) => makeDefaultValue(item)));
441
- }
442
- }
443
- function setNestedValue(target, path, newVal) {
444
- if (path.length === 0) {
445
- return newVal;
446
- }
447
- const [head, ...rest] = path;
448
- const arr = Array.isArray(target) ? [...target] : [];
449
- arr[head] = setNestedValue(arr[head], makeValuePath(rest), newVal);
450
- return arr;
451
- }
452
- function testInvalid(value) {
453
- const stack = [value];
454
- while (stack.length > 0) {
455
- const current = stack.pop();
456
- if (current === INVALID_ELEMENT) {
457
- return true;
458
- }
459
- if (Array.isArray(current)) {
460
- for (const element of current) {
461
- stack.push(element);
462
- }
463
- }
464
- }
465
- return false;
466
- }
467
- export {
468
- boolean,
469
- cartesianProduct,
470
- contains,
471
- convertPathToType,
472
- extractValue,
473
- isSetValue,
474
- isSubsetOrEq,
475
- isTupleValue,
476
- makeDefaultValue,
477
- normalizeValue,
478
- printValue,
479
- projection,
480
- reduce,
481
- setDiff,
482
- setIntersection,
483
- setNestedValue,
484
- setSymDiff,
485
- setUnion,
486
- testInvalid,
487
- validateValue,
488
- valueStub
489
- };
490
- //# sourceMappingURL=value-api.js.map
1
+ import { A as testInvalid, C as projection, D as setNestedValue, E as setIntersection, M as valueStub, O as setSymDiff, S as printValue, T as setDiff, _ as isSetValue, b as makeDefaultValue, f as boolean, g as extractValue, h as convertPathToType, j as validateValue, k as setUnion, m as contains, p as cartesianProduct, v as isSubsetOrEq, w as reduce, x as normalizeValue, y as isTupleValue } from "../../value-B8UtCqaK.js";
2
+ export { boolean, cartesianProduct, contains, convertPathToType, extractValue, isSetValue, isSubsetOrEq, isTupleValue, makeDefaultValue, normalizeValue, printValue, projection, reduce, setDiff, setIntersection, setNestedValue, setSymDiff, setUnion, testInvalid, validateValue, valueStub };
@@ -1,36 +1,2 @@
1
- import { Branded } from '../../shared/branded.js';
2
-
3
- /**
4
- * Module: Structured data for RSLang expression evaluation.
5
- */
6
-
7
- /** Tuple ID for array distinction. */
8
- declare const TUPLE_ID = -111;
9
- /** Invalid value for structured data. */
10
- declare const INVALID_ELEMENT = -1;
11
- /** Boolean values: true. */
12
- declare const VALUE_TRUE = 1;
13
- /** Boolean values: false. */
14
- declare const VALUE_FALSE = 0;
15
- /** Cardinality threshold for "infinite" sets (e.g. Z). */
16
- declare const SET_INFINITY = 10000000;
17
- /** Cardinality threshold for Boolean power set. */
18
- declare const BOOL_INFINITY = 18;
19
- /** Expression evaluation result: structured data. */
20
- type Value = number | Value[];
21
- /** Values context. */
22
- type ValueContext = Map<string, Value>;
23
- /** Value extraction path. */
24
- type ValuePath = Branded<number[], 'ValuePath'>;
25
- /** Creates value path. */
26
- declare function makeValuePath(path: number[]): ValuePath;
27
- /** Empty set ∅. */
28
- declare const EmptySetV: never[];
29
- /** Compare two structured data without recursive calls. */
30
- declare function compare(v1: Value, v2: Value): number;
31
- /** Tuple from components. */
32
- declare function tuple(components: Value[]): Value;
33
- /** Set from elements (unique). Value[] - materialized. */
34
- declare function set(elements: Value[]): Value[];
35
-
36
- export { BOOL_INFINITY, EmptySetV, INVALID_ELEMENT, SET_INFINITY, TUPLE_ID, VALUE_FALSE, VALUE_TRUE, type Value, type ValueContext, type ValuePath, compare, makeValuePath, set, tuple };
1
+ import { a as TUPLE_ID, c as Value, d as compare, f as makeValuePath, i as SET_INFINITY, l as ValueContext, m as tuple, n as EmptySetV, o as VALUE_FALSE, p as set, r as INVALID_ELEMENT, s as VALUE_TRUE, t as BOOL_INFINITY, u as ValuePath } from "../../value-CTjX6825.js";
2
+ export { BOOL_INFINITY, EmptySetV, INVALID_ELEMENT, SET_INFINITY, TUPLE_ID, VALUE_FALSE, VALUE_TRUE, Value, ValueContext, ValuePath, compare, makeValuePath, set, tuple };
@@ -1,118 +1,2 @@
1
- // src/rslang/semantic/typification.ts
2
- var TypeID = {
3
- anyTypification: 1,
4
- integer: 2,
5
- basic: 3,
6
- tuple: 4,
7
- collection: 5,
8
- logic: 6,
9
- function: 7,
10
- predicate: 8
11
- };
12
- var LogicT = { typeID: TypeID.logic };
13
- var IntegerT = {
14
- typeID: TypeID.integer,
15
- isOrdered: true,
16
- isArithmetic: true,
17
- isIntegerCompatible: true
18
- };
19
- var AnyTypificationT = { typeID: TypeID.anyTypification };
20
- var EmptySetT = bool(AnyTypificationT);
21
- function bool(base) {
22
- return { typeID: TypeID.collection, base };
23
- }
24
-
25
- // src/rslang/eval/value-api.ts
26
- function printValue(data) {
27
- if (!Array.isArray(data)) {
28
- return String(data);
29
- }
30
- const len = data.length;
31
- if (data.length === 0) {
32
- return "{}";
33
- }
34
- const isTuple = data[0] === TUPLE_ID;
35
- const start = isTuple ? 1 : 0;
36
- let result = isTuple ? "(" : "{";
37
- for (let i = start; i < len; i++) {
38
- if (i > start) result += ", ";
39
- result += printValue(data[i]);
40
- }
41
- result += isTuple ? ")" : "}";
42
- return result;
43
- }
44
-
45
- // src/rslang/eval/value.ts
46
- var TUPLE_ID = -111;
47
- var INVALID_ELEMENT = -1;
48
- var VALUE_TRUE = 1;
49
- var VALUE_FALSE = 0;
50
- var SET_INFINITY = 1e7;
51
- var BOOL_INFINITY = 18;
52
- function makeValuePath(path) {
53
- return path;
54
- }
55
- var EmptySetV = [];
56
- function compare(v1, v2) {
57
- const stack1 = [v1];
58
- const stack2 = [v2];
59
- while (stack1.length > 0 && stack2.length > 0) {
60
- const el1 = stack1.pop();
61
- const el2 = stack2.pop();
62
- if (el1 === el2) {
63
- continue;
64
- }
65
- const type1 = typeof el1;
66
- const type2 = typeof el2;
67
- if (type1 === "number" && type2 === "number") {
68
- const numDiff = el1 - el2;
69
- if (numDiff !== 0) return numDiff;
70
- continue;
71
- }
72
- const isArray1 = Array.isArray(el1);
73
- const isArray2 = Array.isArray(el2);
74
- if (!isArray1 || !isArray2) {
75
- throw new Error(`Cannot compare different types ${printValue(el1)} and ${printValue(el2)}`);
76
- }
77
- const arr1 = el1;
78
- const arr2 = el2;
79
- const len1 = arr1.length;
80
- const len2 = arr2.length;
81
- if (len1 !== len2) {
82
- return len1 - len2;
83
- }
84
- for (let i = len1 - 1; i >= 0; i--) {
85
- stack1.push(arr1[i]);
86
- stack2.push(arr2[i]);
87
- }
88
- }
89
- return 0;
90
- }
91
- function tuple(components) {
92
- return [TUPLE_ID, ...components];
93
- }
94
- function set(elements) {
95
- const sorted = [...elements].sort(compare);
96
- for (let i = 1; i < sorted.length; ) {
97
- if (compare(sorted[i - 1], sorted[i]) === 0) {
98
- sorted.splice(i, 1);
99
- } else {
100
- i++;
101
- }
102
- }
103
- return sorted;
104
- }
105
- export {
106
- BOOL_INFINITY,
107
- EmptySetV,
108
- INVALID_ELEMENT,
109
- SET_INFINITY,
110
- TUPLE_ID,
111
- VALUE_FALSE,
112
- VALUE_TRUE,
113
- compare,
114
- makeValuePath,
115
- set,
116
- tuple
117
- };
118
- //# sourceMappingURL=value.js.map
1
+ import { a as TUPLE_ID, c as compare, d as tuple, i as SET_INFINITY, l as makeValuePath, n as EmptySetV, o as VALUE_FALSE, r as INVALID_ELEMENT, s as VALUE_TRUE, t as BOOL_INFINITY, u as set } from "../../value-B8UtCqaK.js";
2
+ export { BOOL_INFINITY, EmptySetV, INVALID_ELEMENT, SET_INFINITY, TUPLE_ID, VALUE_FALSE, VALUE_TRUE, compare, makeValuePath, set, tuple };
@@ -1,17 +1,14 @@
1
- export { readErrorAnnotation, readTypeAnnotation } from './ast-annotations.js';
2
- export { RSErrorCode, RSErrorDescription } from './error.js';
3
- export { CalculatorEvaluateOptions, CalculatorResult, RSCalculator } from './eval/calculator.js';
4
- export { Value, ValuePath, makeValuePath } from './eval/value.js';
5
- export { printValue } from './eval/value-api.js';
6
- export { parser as rslangParser } from './parser/parser.js';
7
- export { TokenID } from './parser/token.js';
8
- export { AnalysisBase, AnalysisFast, AnalysisFull, RSLangAnalyzer } from './semantic/analyzer.js';
9
- export { ArgumentsType } from './semantic/arguments-extractor.js';
10
- export { AnyTypificationT, EmptySetT, ExpressionType, LogicT, TypeClass, TypeID, TypePath, Typification, makeTypePath } from './semantic/typification.js';
11
- export { applyAsciiTypeSubstitutions, parseTypeText } from './semantic/typification-parser.js';
12
- export { ValueClass } from './semantic/value-class.js';
13
- export { TypificationGraph, TypificationNodeData } from './typification-graph.js';
14
- import '../parsing/ast.js';
15
- import '@lezer/common';
16
- import '../shared/branded.js';
17
- import '@lezer/lr';
1
+ import { O as makeTypePath, b as Typification, d as EmptySetT, f as ExpressionType, g as TypeClass, m as LogicT, t as AnyTypificationT, v as TypeID, y as TypePath } from "../typification-Dk-fisgO.js";
2
+ import { i as RSErrorDescription, r as RSErrorCode } from "../error-E1LVq_3w.js";
3
+ import { i as readTypeAnnotation, r as readErrorAnnotation } from "../ast-annotations-BiMjkKvz.js";
4
+ import { c as Value, f as makeValuePath, u as ValuePath } from "../value-CTjX6825.js";
5
+ import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-C9W2jkSx.js";
6
+ import { d as printValue } from "../value-api-Bw-SgaYY.js";
7
+ import { t as parser } from "../parser-Bwd8LxJ1.js";
8
+ import { t as TokenID } from "../token-DeXAmzwr.js";
9
+ import { t as ValueClass } from "../value-class-CNI-lqXJ.js";
10
+ import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "../analyzer-DlSq3Y3r.js";
11
+ import { n as ArgumentsType } from "../arguments-extractor-1acwjQNc.js";
12
+ import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "../typification-parser-BBVx1RxP.js";
13
+ import { n as TypificationNodeData, t as TypificationGraph } from "../typification-graph-6HcZ-rKH.js";
14
+ export { type AnalysisBase, type AnalysisFast, type AnalysisFull, AnyTypificationT, type ArgumentsType, type CalculatorEvaluateOptions, type CalculatorResult, EmptySetT, type ExpressionType, LogicT, RSCalculator, RSErrorCode, type RSErrorDescription, RSLangAnalyzer, TokenID, TypeClass, TypeID, type TypePath, type Typification, TypificationGraph, type TypificationNodeData, type Value, ValueClass, type ValuePath, applyAsciiTypeSubstitutions, makeTypePath, makeValuePath, parseTypeText, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser };