arktype 1.0.16-alpha → 1.0.17-alpha

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 (247) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/src/main.js +38 -0
  3. package/dist/cjs/src/nodes/branch.js +140 -0
  4. package/dist/cjs/src/nodes/compose.js +157 -0
  5. package/dist/{nodes → cjs/src/nodes}/discriminate.js +92 -100
  6. package/dist/cjs/src/nodes/node.js +139 -0
  7. package/dist/cjs/src/nodes/predicate.js +86 -0
  8. package/dist/cjs/src/nodes/rules/class.js +25 -0
  9. package/dist/cjs/src/nodes/rules/collapsibleSet.js +48 -0
  10. package/dist/cjs/src/nodes/rules/divisor.js +29 -0
  11. package/dist/cjs/src/nodes/rules/props.js +160 -0
  12. package/dist/cjs/src/nodes/rules/range.js +105 -0
  13. package/dist/cjs/src/nodes/rules/regex.js +26 -0
  14. package/dist/cjs/src/nodes/rules/rules.js +123 -0
  15. package/dist/cjs/src/parse/ast/ast.js +4 -0
  16. package/dist/cjs/src/parse/ast/bound.js +16 -0
  17. package/dist/cjs/src/parse/ast/config.js +13 -0
  18. package/dist/cjs/src/parse/ast/distributableFunction.js +48 -0
  19. package/dist/cjs/src/parse/ast/divisor.js +9 -0
  20. package/dist/cjs/src/parse/ast/intersection.js +30 -0
  21. package/dist/cjs/src/parse/ast/keyof.js +111 -0
  22. package/dist/cjs/src/parse/ast/morph.js +58 -0
  23. package/dist/cjs/src/parse/ast/narrow.js +22 -0
  24. package/dist/cjs/src/parse/ast/node.js +4 -0
  25. package/dist/cjs/src/parse/ast/tuple.js +94 -0
  26. package/dist/cjs/src/parse/ast/union.js +9 -0
  27. package/dist/cjs/src/parse/ast/utils.js +4 -0
  28. package/dist/cjs/src/parse/definition.js +61 -0
  29. package/dist/cjs/src/parse/record.js +37 -0
  30. package/dist/cjs/src/parse/string/reduce/dynamic.js +167 -0
  31. package/dist/cjs/src/parse/string/reduce/shared.js +23 -0
  32. package/dist/cjs/src/parse/string/reduce/static.js +4 -0
  33. package/dist/cjs/src/parse/string/shift/operand/enclosed.js +54 -0
  34. package/dist/cjs/src/parse/string/shift/operand/operand.js +11 -0
  35. package/dist/cjs/src/parse/string/shift/operand/unenclosed.js +53 -0
  36. package/dist/cjs/src/parse/string/shift/operator/bounds.js +87 -0
  37. package/dist/cjs/src/parse/string/shift/operator/divisor.js +35 -0
  38. package/dist/cjs/src/parse/string/shift/operator/operator.js +26 -0
  39. package/dist/cjs/src/parse/string/shift/scanner.js +114 -0
  40. package/dist/cjs/src/parse/string/string.js +43 -0
  41. package/dist/cjs/src/scopes/ark.js +45 -0
  42. package/dist/cjs/src/scopes/cache.js +52 -0
  43. package/dist/cjs/src/scopes/expressions.js +29 -0
  44. package/dist/cjs/src/scopes/jsObjects.js +93 -0
  45. package/dist/cjs/src/scopes/scope.js +323 -0
  46. package/dist/cjs/src/scopes/tsKeywords.js +113 -0
  47. package/dist/cjs/src/scopes/type.js +50 -0
  48. package/dist/cjs/src/scopes/validation/creditCard.js +47 -0
  49. package/dist/cjs/src/scopes/validation/date.js +62 -0
  50. package/dist/cjs/src/scopes/validation/validation.js +108 -0
  51. package/dist/cjs/src/traverse/problems.js +281 -0
  52. package/dist/cjs/src/traverse/traverse.js +390 -0
  53. package/dist/cjs/src/utils/chainableNoOpProxy.js +23 -0
  54. package/dist/cjs/src/utils/data.js +53 -0
  55. package/dist/cjs/src/utils/domains.js +30 -0
  56. package/dist/cjs/src/utils/errors.js +26 -0
  57. package/dist/cjs/src/utils/freeze.js +15 -0
  58. package/dist/cjs/src/utils/generics.js +63 -0
  59. package/dist/cjs/src/utils/numericLiterals.js +75 -0
  60. package/dist/cjs/src/utils/objectKinds.js +69 -0
  61. package/dist/cjs/src/utils/paths.js +32 -0
  62. package/dist/cjs/src/utils/serialize.js +74 -0
  63. package/dist/cjs/src/utils/unionToTuple.js +4 -0
  64. package/dist/mjs/package.json +3 -0
  65. package/dist/mjs/src/main.js +8 -0
  66. package/dist/mjs/src/nodes/branch.js +123 -0
  67. package/dist/mjs/src/nodes/compose.js +135 -0
  68. package/dist/mjs/src/nodes/discriminate.js +247 -0
  69. package/dist/mjs/src/nodes/node.js +117 -0
  70. package/dist/mjs/src/nodes/predicate.js +69 -0
  71. package/dist/mjs/src/nodes/rules/class.js +11 -0
  72. package/dist/mjs/src/nodes/rules/collapsibleSet.js +34 -0
  73. package/dist/mjs/src/nodes/rules/divisor.js +15 -0
  74. package/dist/mjs/src/nodes/rules/props.js +142 -0
  75. package/dist/mjs/src/nodes/rules/range.js +86 -0
  76. package/dist/mjs/src/nodes/rules/regex.js +11 -0
  77. package/dist/mjs/src/nodes/rules/rules.js +106 -0
  78. package/dist/mjs/src/parse/ast/ast.js +1 -0
  79. package/dist/mjs/src/parse/ast/bound.js +2 -0
  80. package/dist/mjs/src/parse/ast/config.js +9 -0
  81. package/dist/mjs/src/parse/ast/distributableFunction.js +34 -0
  82. package/dist/mjs/src/parse/ast/divisor.js +1 -0
  83. package/dist/mjs/src/parse/ast/intersection.js +16 -0
  84. package/dist/mjs/src/parse/ast/keyof.js +103 -0
  85. package/dist/mjs/src/parse/ast/morph.js +44 -0
  86. package/dist/mjs/src/parse/ast/narrow.js +14 -0
  87. package/dist/mjs/src/parse/ast/node.js +1 -0
  88. package/dist/mjs/src/parse/ast/tuple.js +80 -0
  89. package/dist/mjs/src/parse/ast/union.js +1 -0
  90. package/dist/mjs/src/parse/ast/utils.js +1 -0
  91. package/dist/mjs/src/parse/definition.js +46 -0
  92. package/dist/mjs/src/parse/record.js +29 -0
  93. package/dist/mjs/src/parse/string/reduce/dynamic.js +159 -0
  94. package/dist/mjs/src/parse/string/reduce/shared.js +6 -0
  95. package/dist/mjs/src/parse/string/reduce/static.js +1 -0
  96. package/dist/mjs/src/parse/string/shift/operand/enclosed.js +39 -0
  97. package/dist/mjs/src/parse/string/shift/operand/operand.js +3 -0
  98. package/dist/mjs/src/parse/string/shift/operand/unenclosed.js +36 -0
  99. package/dist/mjs/src/parse/string/shift/operator/bounds.js +70 -0
  100. package/dist/mjs/src/parse/string/shift/operator/divisor.js +21 -0
  101. package/dist/mjs/src/parse/string/shift/operator/operator.js +13 -0
  102. package/dist/mjs/src/parse/string/shift/scanner.js +106 -0
  103. package/dist/mjs/src/parse/string/string.js +28 -0
  104. package/dist/mjs/src/scopes/ark.js +28 -0
  105. package/dist/mjs/src/scopes/cache.js +38 -0
  106. package/dist/{scopes → mjs/src/scopes}/expressions.js +9 -20
  107. package/dist/mjs/src/scopes/jsObjects.js +82 -0
  108. package/dist/mjs/src/scopes/scope.js +303 -0
  109. package/dist/mjs/src/scopes/tsKeywords.js +116 -0
  110. package/dist/mjs/src/scopes/type.js +35 -0
  111. package/dist/{scopes → mjs/src/scopes}/validation/creditCard.js +11 -15
  112. package/dist/{scopes → mjs/src/scopes}/validation/date.js +16 -21
  113. package/dist/mjs/src/scopes/validation/validation.js +112 -0
  114. package/dist/mjs/src/traverse/problems.js +260 -0
  115. package/dist/mjs/src/traverse/traverse.js +373 -0
  116. package/dist/{utils → mjs/src/utils}/chainableNoOpProxy.js +2 -6
  117. package/dist/mjs/src/utils/data.js +38 -0
  118. package/dist/mjs/src/utils/domains.js +15 -0
  119. package/dist/mjs/src/utils/errors.js +10 -0
  120. package/dist/mjs/src/utils/freeze.js +7 -0
  121. package/dist/mjs/src/utils/generics.js +38 -0
  122. package/dist/mjs/src/utils/numericLiterals.js +72 -0
  123. package/dist/mjs/src/utils/objectKinds.js +55 -0
  124. package/dist/{utils → mjs/src/utils}/paths.js +3 -8
  125. package/dist/mjs/src/utils/serialize.js +58 -0
  126. package/dist/mjs/src/utils/unionToTuple.js +1 -0
  127. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  128. package/package.json +13 -5
  129. package/dist/main.js +0 -29
  130. package/dist/nodes/branch.js +0 -135
  131. package/dist/nodes/compose.js +0 -99
  132. package/dist/nodes/node.js +0 -134
  133. package/dist/nodes/predicate.js +0 -88
  134. package/dist/nodes/rules/class.js +0 -23
  135. package/dist/nodes/rules/collapsibleSet.js +0 -34
  136. package/dist/nodes/rules/divisor.js +0 -19
  137. package/dist/nodes/rules/props.js +0 -130
  138. package/dist/nodes/rules/range.js +0 -108
  139. package/dist/nodes/rules/regex.js +0 -17
  140. package/dist/nodes/rules/rules.js +0 -102
  141. package/dist/parse/ast/ast.js +0 -2
  142. package/dist/parse/ast/bound.js +0 -7
  143. package/dist/parse/ast/config.js +0 -14
  144. package/dist/parse/ast/distributableFunction.js +0 -40
  145. package/dist/parse/ast/divisor.js +0 -5
  146. package/dist/parse/ast/intersection.js +0 -21
  147. package/dist/parse/ast/keyof.js +0 -107
  148. package/dist/parse/ast/morph.js +0 -50
  149. package/dist/parse/ast/narrow.js +0 -17
  150. package/dist/parse/ast/node.js +0 -2
  151. package/dist/parse/ast/tuple.js +0 -72
  152. package/dist/parse/ast/union.js +0 -5
  153. package/dist/parse/ast/utils.js +0 -2
  154. package/dist/parse/definition.js +0 -47
  155. package/dist/parse/record.js +0 -31
  156. package/dist/parse/string/reduce/dynamic.js +0 -159
  157. package/dist/parse/string/reduce/shared.js +0 -13
  158. package/dist/parse/string/reduce/static.js +0 -2
  159. package/dist/parse/string/shift/operand/enclosed.js +0 -37
  160. package/dist/parse/string/shift/operand/operand.js +0 -15
  161. package/dist/parse/string/shift/operand/unenclosed.js +0 -45
  162. package/dist/parse/string/shift/operator/bounds.js +0 -83
  163. package/dist/parse/string/shift/operator/divisor.js +0 -23
  164. package/dist/parse/string/shift/operator/operator.js +0 -34
  165. package/dist/parse/string/shift/scanner.js +0 -97
  166. package/dist/parse/string/string.js +0 -35
  167. package/dist/scopes/ark.js +0 -27
  168. package/dist/scopes/cache.js +0 -28
  169. package/dist/scopes/jsObjects.js +0 -20
  170. package/dist/scopes/scope.js +0 -184
  171. package/dist/scopes/tsKeywords.js +0 -49
  172. package/dist/scopes/type.js +0 -40
  173. package/dist/scopes/validation/validation.js +0 -74
  174. package/dist/traverse/problems.js +0 -234
  175. package/dist/traverse/traverse.js +0 -330
  176. package/dist/utils/data.js +0 -39
  177. package/dist/utils/domains.js +0 -27
  178. package/dist/utils/errors.js +0 -17
  179. package/dist/utils/freeze.js +0 -16
  180. package/dist/utils/generics.js +0 -53
  181. package/dist/utils/numericLiterals.js +0 -88
  182. package/dist/utils/objectKinds.js +0 -69
  183. package/dist/utils/serialize.js +0 -71
  184. package/dist/utils/unionToTuple.js +0 -2
  185. /package/dist/{package.json → cjs/package.json} +0 -0
  186. /package/dist/{main.d.ts → types/main.d.ts} +0 -0
  187. /package/dist/{nodes → types/nodes}/branch.d.ts +0 -0
  188. /package/dist/{nodes → types/nodes}/compose.d.ts +0 -0
  189. /package/dist/{nodes → types/nodes}/discriminate.d.ts +0 -0
  190. /package/dist/{nodes → types/nodes}/node.d.ts +0 -0
  191. /package/dist/{nodes → types/nodes}/predicate.d.ts +0 -0
  192. /package/dist/{nodes → types/nodes}/rules/class.d.ts +0 -0
  193. /package/dist/{nodes → types/nodes}/rules/collapsibleSet.d.ts +0 -0
  194. /package/dist/{nodes → types/nodes}/rules/divisor.d.ts +0 -0
  195. /package/dist/{nodes → types/nodes}/rules/props.d.ts +0 -0
  196. /package/dist/{nodes → types/nodes}/rules/range.d.ts +0 -0
  197. /package/dist/{nodes → types/nodes}/rules/regex.d.ts +0 -0
  198. /package/dist/{nodes → types/nodes}/rules/rules.d.ts +0 -0
  199. /package/dist/{parse → types/parse}/ast/ast.d.ts +0 -0
  200. /package/dist/{parse → types/parse}/ast/bound.d.ts +0 -0
  201. /package/dist/{parse → types/parse}/ast/config.d.ts +0 -0
  202. /package/dist/{parse → types/parse}/ast/distributableFunction.d.ts +0 -0
  203. /package/dist/{parse → types/parse}/ast/divisor.d.ts +0 -0
  204. /package/dist/{parse → types/parse}/ast/intersection.d.ts +0 -0
  205. /package/dist/{parse → types/parse}/ast/keyof.d.ts +0 -0
  206. /package/dist/{parse → types/parse}/ast/morph.d.ts +0 -0
  207. /package/dist/{parse → types/parse}/ast/narrow.d.ts +0 -0
  208. /package/dist/{parse → types/parse}/ast/node.d.ts +0 -0
  209. /package/dist/{parse → types/parse}/ast/tuple.d.ts +0 -0
  210. /package/dist/{parse → types/parse}/ast/union.d.ts +0 -0
  211. /package/dist/{parse → types/parse}/ast/utils.d.ts +0 -0
  212. /package/dist/{parse → types/parse}/definition.d.ts +0 -0
  213. /package/dist/{parse → types/parse}/record.d.ts +0 -0
  214. /package/dist/{parse → types/parse}/string/reduce/dynamic.d.ts +0 -0
  215. /package/dist/{parse → types/parse}/string/reduce/shared.d.ts +0 -0
  216. /package/dist/{parse → types/parse}/string/reduce/static.d.ts +0 -0
  217. /package/dist/{parse → types/parse}/string/shift/operand/enclosed.d.ts +0 -0
  218. /package/dist/{parse → types/parse}/string/shift/operand/operand.d.ts +0 -0
  219. /package/dist/{parse → types/parse}/string/shift/operand/unenclosed.d.ts +0 -0
  220. /package/dist/{parse → types/parse}/string/shift/operator/bounds.d.ts +0 -0
  221. /package/dist/{parse → types/parse}/string/shift/operator/divisor.d.ts +0 -0
  222. /package/dist/{parse → types/parse}/string/shift/operator/operator.d.ts +0 -0
  223. /package/dist/{parse → types/parse}/string/shift/scanner.d.ts +0 -0
  224. /package/dist/{parse → types/parse}/string/string.d.ts +0 -0
  225. /package/dist/{scopes → types/scopes}/ark.d.ts +0 -0
  226. /package/dist/{scopes → types/scopes}/cache.d.ts +0 -0
  227. /package/dist/{scopes → types/scopes}/expressions.d.ts +0 -0
  228. /package/dist/{scopes → types/scopes}/jsObjects.d.ts +0 -0
  229. /package/dist/{scopes → types/scopes}/scope.d.ts +0 -0
  230. /package/dist/{scopes → types/scopes}/tsKeywords.d.ts +0 -0
  231. /package/dist/{scopes → types/scopes}/type.d.ts +0 -0
  232. /package/dist/{scopes → types/scopes}/validation/creditCard.d.ts +0 -0
  233. /package/dist/{scopes → types/scopes}/validation/date.d.ts +0 -0
  234. /package/dist/{scopes → types/scopes}/validation/validation.d.ts +0 -0
  235. /package/dist/{traverse → types/traverse}/problems.d.ts +0 -0
  236. /package/dist/{traverse → types/traverse}/traverse.d.ts +0 -0
  237. /package/dist/{utils → types/utils}/chainableNoOpProxy.d.ts +0 -0
  238. /package/dist/{utils → types/utils}/data.d.ts +0 -0
  239. /package/dist/{utils → types/utils}/domains.d.ts +0 -0
  240. /package/dist/{utils → types/utils}/errors.d.ts +0 -0
  241. /package/dist/{utils → types/utils}/freeze.d.ts +0 -0
  242. /package/dist/{utils → types/utils}/generics.d.ts +0 -0
  243. /package/dist/{utils → types/utils}/numericLiterals.d.ts +0 -0
  244. /package/dist/{utils → types/utils}/objectKinds.d.ts +0 -0
  245. /package/dist/{utils → types/utils}/paths.d.ts +0 -0
  246. /package/dist/{utils → types/utils}/serialize.d.ts +0 -0
  247. /package/dist/{utils → types/utils}/unionToTuple.d.ts +0 -0
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConfigTuple = void 0;
4
- const definition_js_1 = require("../definition.js");
5
- /**
6
- * @operator {@link parseConfigTuple | :}
7
- * @docgenTable
8
- * @tuple ["type", ":", config]
9
- */
10
- const parseConfigTuple = (def, ctx) => ({
11
- node: ctx.type.scope.resolveTypeNode((0, definition_js_1.parseDefinition)(def[0], ctx)),
12
- config: def[2]
13
- });
14
- exports.parseConfigTuple = parseConfigTuple;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.distributeFunctionToNode = exports.writeMalformedDistributableFunctionMessage = void 0;
4
- const domains_js_1 = require("../../utils/domains.js");
5
- const errors_js_1 = require("../../utils/errors.js");
6
- const generics_js_1 = require("../../utils/generics.js");
7
- const serialize_js_1 = require("../../utils/serialize.js");
8
- const writeMalformedDistributableFunctionMessage = (def) => `Expected a Function or Record<Domain, Function> operand (${(0, serialize_js_1.stringify)(def)} was invalid)`;
9
- exports.writeMalformedDistributableFunctionMessage = writeMalformedDistributableFunctionMessage;
10
- const distributeFunctionToNode = (distributableFunction, node, ctx, ruleKey) => {
11
- const domains = (0, generics_js_1.objectKeysOf)(node);
12
- if (!(0, domains_js_1.hasDomain)(distributableFunction, "object")) {
13
- return (0, errors_js_1.throwParseError)((0, exports.writeMalformedDistributableFunctionMessage)(distributableFunction));
14
- }
15
- const distributed = {};
16
- if (typeof distributableFunction === "function") {
17
- const domainFunction = {
18
- [ruleKey]: distributableFunction
19
- };
20
- for (const domain of domains) {
21
- distributed[domain] = domainFunction;
22
- }
23
- }
24
- else {
25
- for (const domain of domains) {
26
- if (distributableFunction[domain] === undefined) {
27
- continue;
28
- }
29
- const functionInDomain = {
30
- [ruleKey]: distributableFunction[domain]
31
- };
32
- if (typeof functionInDomain[ruleKey] !== "function") {
33
- return (0, errors_js_1.throwParseError)((0, exports.writeMalformedDistributableFunctionMessage)(functionInDomain));
34
- }
35
- distributed[domain] = functionInDomain;
36
- }
37
- }
38
- return distributed;
39
- };
40
- exports.distributeFunctionToNode = distributeFunctionToNode;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeIndivisibleMessage = void 0;
4
- const writeIndivisibleMessage = (root) => `Divisibility operand ${root} must be a number`;
5
- exports.writeIndivisibleMessage = writeIndivisibleMessage;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeImplicitNeverMessage = exports.compileDisjointReasonsMessage = void 0;
4
- const compose_js_1 = require("../../nodes/compose.js");
5
- const generics_js_1 = require("../../utils/generics.js");
6
- const compileDisjointReasonsMessage = (disjoints) => {
7
- const paths = (0, generics_js_1.objectKeysOf)(disjoints);
8
- if (paths.length === 1) {
9
- const path = paths[0];
10
- return `${path === "/" ? "" : `At ${path}: `}Intersection of ${compose_js_1.disjointDescriptionWriters[disjoints[path].kind](disjoints[path])} results in an unsatisfiable type`;
11
- }
12
- let message = `
13
- "Intersection results in unsatisfiable types at the following paths:\n`;
14
- for (const path in disjoints) {
15
- message += ` ${path}: ${compose_js_1.disjointDescriptionWriters[disjoints[path].kind](disjoints[path])}\n`;
16
- }
17
- return message;
18
- };
19
- exports.compileDisjointReasonsMessage = compileDisjointReasonsMessage;
20
- const writeImplicitNeverMessage = (path, operator, description) => `${path.length ? `At ${path}: ` : ""}${operator} ${description ? `${description} ` : ""}results in an unsatisfiable type`;
21
- exports.writeImplicitNeverMessage = writeImplicitNeverMessage;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseKeyOfTuple = void 0;
4
- const props_js_1 = require("../../nodes/rules/props.js");
5
- const errors_js_1 = require("../../utils/errors.js");
6
- const freeze_js_1 = require("../../utils/freeze.js");
7
- const generics_js_1 = require("../../utils/generics.js");
8
- const numericLiterals_js_1 = require("../../utils/numericLiterals.js");
9
- const objectKinds_js_1 = require("../../utils/objectKinds.js");
10
- const serialize_js_1 = require("../../utils/serialize.js");
11
- const definition_js_1 = require("../definition.js");
12
- const intersection_js_1 = require("./intersection.js");
13
- const arrayIndexStringBranch = (0, freeze_js_1.deepFreeze)({
14
- regex: numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher.source
15
- });
16
- const arrayIndexNumberBranch = (0, freeze_js_1.deepFreeze)({
17
- range: { min: { comparator: ">=", limit: 0 } },
18
- divisor: 1
19
- });
20
- const parseKeyOfTuple = (def, ctx) => {
21
- const resolution = ctx.type.scope.resolveNode((0, definition_js_1.parseDefinition)(def[1], ctx));
22
- const predicateKeys = (0, generics_js_1.objectKeysOf)(resolution).map((domain) => keysOfPredicate(domain, resolution[domain]));
23
- const sharedKeys = sharedKeysOf(predicateKeys);
24
- if (!sharedKeys.length) {
25
- return (0, intersection_js_1.writeImplicitNeverMessage)(ctx.path, "keyof");
26
- }
27
- const keyNode = {};
28
- for (const key of sharedKeys) {
29
- const keyType = typeof key;
30
- if (keyType === "string" ||
31
- keyType === "number" ||
32
- keyType === "symbol") {
33
- keyNode[keyType] ??= [];
34
- keyNode[keyType].push({ value: key });
35
- }
36
- else if (key === numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher) {
37
- keyNode.string ??= [];
38
- keyNode.string.push(arrayIndexStringBranch);
39
- keyNode.number ??= [];
40
- keyNode.number.push(arrayIndexNumberBranch);
41
- }
42
- else {
43
- return (0, errors_js_1.throwInternalError)(`Unexpected keyof key '${(0, serialize_js_1.stringify)(key)}'`);
44
- }
45
- }
46
- return Object.fromEntries(Object.entries(keyNode).map(([domain, branches]) => [
47
- domain,
48
- branches.length === 1 ? branches[0] : branches
49
- ]));
50
- };
51
- exports.parseKeyOfTuple = parseKeyOfTuple;
52
- const baseKeysByDomain = {
53
- bigint: (0, generics_js_1.prototypeKeysOf)(0n),
54
- boolean: (0, generics_js_1.prototypeKeysOf)(false),
55
- null: [],
56
- number: (0, generics_js_1.prototypeKeysOf)(0),
57
- // TS doesn't include the Object prototype in keyof, so keyof object is never
58
- object: [],
59
- string: (0, generics_js_1.prototypeKeysOf)(""),
60
- symbol: (0, generics_js_1.prototypeKeysOf)(Symbol()),
61
- undefined: []
62
- };
63
- const keysOfPredicate = (domain, predicate) => domain !== "object" || predicate === true
64
- ? baseKeysByDomain[domain]
65
- : sharedKeysOf((0, generics_js_1.listFrom)(predicate).map((branch) => keysOfObjectBranch(branch)));
66
- const sharedKeysOf = (keyBranches) => {
67
- if (!keyBranches.length) {
68
- return [];
69
- }
70
- let sharedKeys = keyBranches[0];
71
- for (let i = 1; i < keyBranches.length; i++) {
72
- // we can filter directly by equality here because the RegExp we're
73
- // using will always be reference equal to
74
- // wellFormedNonNegativeIntegerMatcher
75
- sharedKeys = sharedKeys.filter((k) => keyBranches[i].includes(k));
76
- }
77
- return sharedKeys;
78
- };
79
- const keysOfObjectBranch = (branch) => {
80
- const result = [];
81
- if ("props" in branch) {
82
- for (const key of Object.keys(branch.props)) {
83
- if (key === props_js_1.mappedKeys.index) {
84
- // if any number is a valid key push this RegExp
85
- result.push(numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher);
86
- }
87
- else if (!result.includes(key)) {
88
- result.push(key);
89
- if (numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher.test(key)) {
90
- // allow numeric access to keys
91
- result.push((0, numericLiterals_js_1.tryParseWellFormedInteger)(key, `Unexpectedly failed to parse an integer from key '${key}'`));
92
- }
93
- }
94
- }
95
- }
96
- if ("class" in branch) {
97
- const constructor = typeof branch.class === "string"
98
- ? objectKinds_js_1.defaultObjectKinds[branch.class]
99
- : branch.class;
100
- for (const key of (0, generics_js_1.prototypeKeysOf)(constructor.prototype)) {
101
- if (!result.includes(key)) {
102
- result.push(key);
103
- }
104
- }
105
- }
106
- return result;
107
- };
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeMalformedMorphExpressionMessage = exports.parseMorphTuple = void 0;
4
- const branch_js_1 = require("../../nodes/branch.js");
5
- const errors_js_1 = require("../../utils/errors.js");
6
- const objectKinds_js_1 = require("../../utils/objectKinds.js");
7
- const serialize_js_1 = require("../../utils/serialize.js");
8
- const definition_js_1 = require("../definition.js");
9
- const parseMorphTuple = (def, ctx) => {
10
- if (typeof def[2] !== "function") {
11
- return (0, errors_js_1.throwParseError)((0, exports.writeMalformedMorphExpressionMessage)(def[2]));
12
- }
13
- const node = (0, definition_js_1.parseDefinition)(def[0], ctx);
14
- const resolution = ctx.type.scope.resolveTypeNode(node);
15
- const morph = def[2];
16
- ctx.type.includesMorph = true;
17
- let domain;
18
- const result = {};
19
- for (domain in resolution) {
20
- const predicate = resolution[domain];
21
- if (predicate === true) {
22
- result[domain] = { rules: {}, morph };
23
- }
24
- else if (typeof predicate === "object") {
25
- result[domain] = (0, objectKinds_js_1.isArray)(predicate)
26
- ? predicate.map((branch) => applyMorph(branch, morph))
27
- : applyMorph(predicate, morph);
28
- }
29
- else {
30
- (0, errors_js_1.throwInternalError)(`Unexpected predicate value for domain '${domain}': ${(0, serialize_js_1.stringify)(predicate)}`);
31
- }
32
- }
33
- return result;
34
- };
35
- exports.parseMorphTuple = parseMorphTuple;
36
- const applyMorph = (branch, morph) => (0, branch_js_1.isTransformationBranch)(branch)
37
- ? {
38
- ...branch,
39
- morph: branch.morph
40
- ? Array.isArray(branch.morph)
41
- ? [...branch.morph, morph]
42
- : [branch.morph, morph]
43
- : morph
44
- }
45
- : {
46
- rules: branch,
47
- morph
48
- };
49
- const writeMalformedMorphExpressionMessage = (value) => `Morph expression requires a function following '|>' (was ${typeof value})`;
50
- exports.writeMalformedMorphExpressionMessage = writeMalformedMorphExpressionMessage;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseNarrowTuple = void 0;
4
- const node_js_1 = require("../../nodes/node.js");
5
- const definition_js_1 = require("../definition.js");
6
- const distributableFunction_js_1 = require("./distributableFunction.js");
7
- const parseNarrowTuple = (def, ctx) => {
8
- const inputNode = (0, definition_js_1.parseDefinition)(def[0], ctx);
9
- const resolution = ctx.type.scope.resolveNode(inputNode);
10
- const hasConfig = (0, node_js_1.isConfigNode)(resolution);
11
- const typeNode = hasConfig ? resolution.node : resolution;
12
- const result = (0, node_js_1.rootIntersection)(inputNode, (0, distributableFunction_js_1.distributeFunctionToNode)(def[2], typeNode, ctx, "narrow"), ctx.type);
13
- return hasConfig
14
- ? { config: resolution.config, node: result }
15
- : result;
16
- };
17
- exports.parseNarrowTuple = parseNarrowTuple;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeMalformedFunctionalExpressionMessage = exports.parseTuple = void 0;
4
- const node_js_1 = require("../../nodes/node.js");
5
- const domains_js_1 = require("../../utils/domains.js");
6
- const errors_js_1 = require("../../utils/errors.js");
7
- const definition_js_1 = require("../definition.js");
8
- const unenclosed_js_1 = require("../string/shift/operand/unenclosed.js");
9
- const config_js_1 = require("./config.js");
10
- const keyof_js_1 = require("./keyof.js");
11
- const morph_js_1 = require("./morph.js");
12
- const narrow_js_1 = require("./narrow.js");
13
- const parseTuple = (def, ctx) => {
14
- if (isIndexOneExpression(def)) {
15
- return indexOneParsers[def[1]](def, ctx);
16
- }
17
- if (isIndexZeroExpression(def)) {
18
- return prefixParsers[def[0]](def, ctx);
19
- }
20
- const props = {
21
- // length is created as a prerequisite prop, ensuring if it is invalid,
22
- // no other props will be checked, which is usually desirable for tuple
23
- // definitions.
24
- length: ["!", { number: { value: def.length } }]
25
- };
26
- for (let i = 0; i < def.length; i++) {
27
- ctx.path.push(`${i}`);
28
- props[i] = (0, definition_js_1.parseDefinition)(def[i], ctx);
29
- ctx.path.pop();
30
- }
31
- return {
32
- object: {
33
- class: Array,
34
- props
35
- }
36
- };
37
- };
38
- exports.parseTuple = parseTuple;
39
- const parseBranchTuple = (def, ctx) => {
40
- if (def[2] === undefined) {
41
- return (0, errors_js_1.throwParseError)((0, unenclosed_js_1.writeMissingRightOperandMessage)(def[1], ""));
42
- }
43
- const l = (0, definition_js_1.parseDefinition)(def[0], ctx);
44
- const r = (0, definition_js_1.parseDefinition)(def[2], ctx);
45
- return def[1] === "&"
46
- ? (0, node_js_1.rootIntersection)(l, r, ctx.type)
47
- : (0, node_js_1.rootUnion)(l, r, ctx.type);
48
- };
49
- const parseArrayTuple = (def, scope) => (0, node_js_1.toArrayNode)((0, definition_js_1.parseDefinition)(def[0], scope));
50
- const writeMalformedFunctionalExpressionMessage = (operator, rightDef) => `Expression requires a function following '${operator}' (was ${typeof rightDef})`;
51
- exports.writeMalformedFunctionalExpressionMessage = writeMalformedFunctionalExpressionMessage;
52
- const isIndexOneExpression = (def) => indexOneParsers[def[1]] !== undefined;
53
- const indexOneParsers = {
54
- "|": parseBranchTuple,
55
- "&": parseBranchTuple,
56
- "[]": parseArrayTuple,
57
- "=>": narrow_js_1.parseNarrowTuple,
58
- "|>": morph_js_1.parseMorphTuple,
59
- ":": config_js_1.parseConfigTuple
60
- };
61
- const prefixParsers = {
62
- keyof: keyof_js_1.parseKeyOfTuple,
63
- instanceof: (def) => {
64
- if (typeof def[1] !== "function") {
65
- return (0, errors_js_1.throwParseError)(`Expected a constructor following 'instanceof' operator (was ${typeof def[1]}).`);
66
- }
67
- return { object: { class: def[1] } };
68
- },
69
- "===": (def) => ({ [(0, domains_js_1.domainOf)(def[1])]: { value: def[1] } }),
70
- node: (def) => def[1]
71
- };
72
- const isIndexZeroExpression = (def) => prefixParsers[def[0]] !== undefined;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeUndiscriminatableMorphUnionMessage = void 0;
4
- const writeUndiscriminatableMorphUnionMessage = (path) => `${path === "/" ? "A" : `At ${path}, a`} union including one or more morphs must be discriminatable`;
5
- exports.writeUndiscriminatableMorphUnionMessage = writeUndiscriminatableMorphUnionMessage;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeBadDefinitionTypeMessage = exports.as = exports.parseDefinition = void 0;
4
- const type_js_1 = require("../scopes/type.js");
5
- const domains_js_1 = require("../utils/domains.js");
6
- const errors_js_1 = require("../utils/errors.js");
7
- const objectKinds_js_1 = require("../utils/objectKinds.js");
8
- const serialize_js_1 = require("../utils/serialize.js");
9
- const tuple_js_1 = require("./ast/tuple.js");
10
- const record_js_1 = require("./record.js");
11
- const string_js_1 = require("./string/string.js");
12
- const parseDefinition = (def, ctx) => {
13
- const domain = (0, domains_js_1.domainOf)(def);
14
- if (domain === "string") {
15
- return (0, string_js_1.parseString)(def, ctx);
16
- }
17
- if (domain !== "object") {
18
- return (0, errors_js_1.throwParseError)((0, exports.writeBadDefinitionTypeMessage)(domain));
19
- }
20
- const objectKind = (0, objectKinds_js_1.objectKindOf)(def);
21
- switch (objectKind) {
22
- case "Object":
23
- return (0, record_js_1.parseRecord)(def, ctx);
24
- case "Array":
25
- return (0, tuple_js_1.parseTuple)(def, ctx);
26
- case "RegExp":
27
- return { string: { regex: def.source } };
28
- case "Function":
29
- if ((0, type_js_1.isType)(def)) {
30
- return ctx.type.scope.addAnonymousTypeReference(def, ctx);
31
- }
32
- if (isThunk(def)) {
33
- const returned = def();
34
- if ((0, type_js_1.isType)(returned)) {
35
- return ctx.type.scope.addAnonymousTypeReference(returned, ctx);
36
- }
37
- }
38
- return (0, errors_js_1.throwParseError)((0, exports.writeBadDefinitionTypeMessage)("Function"));
39
- default:
40
- return (0, errors_js_1.throwParseError)((0, exports.writeBadDefinitionTypeMessage)(objectKind ?? (0, serialize_js_1.stringify)(def)));
41
- }
42
- };
43
- exports.parseDefinition = parseDefinition;
44
- exports.as = Symbol("as");
45
- const isThunk = (def) => typeof def === "function" && def.length === 0;
46
- const writeBadDefinitionTypeMessage = (actual) => `Type definitions must be strings or objects (was ${actual})`;
47
- exports.writeBadDefinitionTypeMessage = writeBadDefinitionTypeMessage;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRecord = void 0;
4
- const definition_js_1 = require("./definition.js");
5
- const scanner_js_1 = require("./string/shift/scanner.js");
6
- const parseRecord = (def, ctx) => {
7
- const props = {};
8
- for (const definitionKey in def) {
9
- let keyName = definitionKey;
10
- let isOptional = false;
11
- if (definitionKey[definitionKey.length - 1] === "?") {
12
- if (definitionKey[definitionKey.length - 2] === scanner_js_1.Scanner.escapeToken) {
13
- keyName = `${definitionKey.slice(0, -2)}?`;
14
- }
15
- else {
16
- keyName = definitionKey.slice(0, -1);
17
- isOptional = true;
18
- }
19
- }
20
- ctx.path.push(keyName);
21
- const propNode = (0, definition_js_1.parseDefinition)(def[definitionKey], ctx);
22
- ctx.path.pop();
23
- props[keyName] = isOptional ? ["?", propNode] : propNode;
24
- }
25
- return {
26
- object: {
27
- props
28
- }
29
- };
30
- };
31
- exports.parseRecord = parseRecord;
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DynamicState = void 0;
4
- const node_js_1 = require("../../../nodes/node.js");
5
- const range_js_1 = require("../../../nodes/rules/range.js");
6
- const errors_js_1 = require("../../../utils/errors.js");
7
- const generics_js_1 = require("../../../utils/generics.js");
8
- const serialize_js_1 = require("../../../utils/serialize.js");
9
- const scanner_js_1 = require("../shift/scanner.js");
10
- const shared_js_1 = require("./shared.js");
11
- class DynamicState {
12
- ctx;
13
- scanner;
14
- root;
15
- branches = {};
16
- groups = [];
17
- constructor(def, ctx) {
18
- this.ctx = ctx;
19
- this.scanner = new scanner_js_1.Scanner(def);
20
- }
21
- error(message) {
22
- return (0, errors_js_1.throwParseError)(message);
23
- }
24
- hasRoot() {
25
- return this.root !== undefined;
26
- }
27
- resolveRoot() {
28
- this.assertHasRoot();
29
- return this.ctx.type.scope.resolveTypeNode(this.root);
30
- }
31
- rootToString() {
32
- this.assertHasRoot();
33
- return (0, serialize_js_1.stringify)(this.root);
34
- }
35
- ejectRootIfLimit() {
36
- this.assertHasRoot();
37
- const resolution = typeof this.root === "string"
38
- ? this.ctx.type.scope.resolveNode(this.root)
39
- : this.root;
40
- if ((0, node_js_1.isLiteralNode)(resolution, "number")) {
41
- const limit = resolution.number.value;
42
- this.root = undefined;
43
- return limit;
44
- }
45
- }
46
- ejectRangeIfOpen() {
47
- if (this.branches.range) {
48
- const range = this.branches.range;
49
- delete this.branches.range;
50
- return range;
51
- }
52
- }
53
- assertHasRoot() {
54
- if (this.root === undefined) {
55
- return (0, errors_js_1.throwInternalError)("Unexpected interaction with unset root");
56
- }
57
- }
58
- assertUnsetRoot() {
59
- if (this.root !== undefined) {
60
- return (0, errors_js_1.throwInternalError)("Unexpected attempt to overwrite root");
61
- }
62
- }
63
- setRoot(node) {
64
- this.assertUnsetRoot();
65
- this.root = node;
66
- }
67
- rootToArray() {
68
- this.root = (0, node_js_1.toArrayNode)(this.ejectRoot());
69
- }
70
- intersect(node) {
71
- this.root = (0, node_js_1.rootIntersection)(this.ejectRoot(), node, this.ctx.type);
72
- }
73
- ejectRoot() {
74
- this.assertHasRoot();
75
- const root = this.root;
76
- this.root = undefined;
77
- return root;
78
- }
79
- ejectFinalizedRoot() {
80
- this.assertHasRoot();
81
- const root = this.root;
82
- this.root = ejectedProxy;
83
- return root;
84
- }
85
- finalize() {
86
- if (this.groups.length) {
87
- return this.error(shared_js_1.unclosedGroupMessage);
88
- }
89
- this.finalizeBranches();
90
- this.scanner.finalized = true;
91
- }
92
- reduceLeftBound(limit, comparator) {
93
- const invertedComparator = scanner_js_1.Scanner.invertedComparators[comparator];
94
- if (!(0, generics_js_1.isKeyOf)(invertedComparator, range_js_1.minComparators)) {
95
- return this.error((0, shared_js_1.writeUnpairableComparatorMessage)(comparator));
96
- }
97
- if (this.branches.range) {
98
- return this.error((0, shared_js_1.writeMultipleLeftBoundsMessage)(`${this.branches.range.limit}`, this.branches.range.comparator, `${limit}`, invertedComparator));
99
- }
100
- this.branches.range = {
101
- limit,
102
- comparator: invertedComparator
103
- };
104
- }
105
- finalizeBranches() {
106
- this.assertRangeUnset();
107
- if (this.branches.union) {
108
- this.pushRootToBranch("|");
109
- this.setRoot(this.branches.union);
110
- }
111
- else if (this.branches.intersection) {
112
- this.setRoot((0, node_js_1.rootIntersection)(this.branches.intersection, this.ejectRoot(), this.ctx.type));
113
- }
114
- }
115
- finalizeGroup() {
116
- this.finalizeBranches();
117
- const topBranchState = this.groups.pop();
118
- if (!topBranchState) {
119
- return this.error((0, shared_js_1.writeUnmatchedGroupCloseMessage)(this.scanner.unscanned));
120
- }
121
- this.branches = topBranchState;
122
- }
123
- pushRootToBranch(token) {
124
- this.assertRangeUnset();
125
- this.branches.intersection = this.branches.intersection
126
- ? (0, node_js_1.rootIntersection)(this.branches.intersection, this.ejectRoot(), this.ctx.type)
127
- : this.ejectRoot();
128
- if (token === "|") {
129
- this.branches.union = this.branches.union
130
- ? (0, node_js_1.rootUnion)(this.branches.union, this.branches.intersection, this.ctx.type)
131
- : this.branches.intersection;
132
- delete this.branches.intersection;
133
- }
134
- }
135
- assertRangeUnset() {
136
- if (this.branches.range) {
137
- return this.error((0, shared_js_1.writeOpenRangeMessage)(`${this.branches.range.limit}`, this.branches.range.comparator));
138
- }
139
- }
140
- reduceGroupOpen() {
141
- this.groups.push(this.branches);
142
- this.branches = {};
143
- }
144
- previousOperator() {
145
- return this.branches.range?.comparator ?? this.branches.intersection
146
- ? "&"
147
- : this.branches.union
148
- ? "|"
149
- : undefined;
150
- }
151
- shiftedByOne() {
152
- this.scanner.shift();
153
- return this;
154
- }
155
- }
156
- exports.DynamicState = DynamicState;
157
- const ejectedProxy = new Proxy({}, {
158
- get: () => (0, errors_js_1.throwInternalError)(`Unexpected attempt to access ejected attributes`)
159
- });
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeMultipleLeftBoundsMessage = exports.writeUnpairableComparatorMessage = exports.writeOpenRangeMessage = exports.unclosedGroupMessage = exports.writeUnmatchedGroupCloseMessage = void 0;
4
- const scanner_js_1 = require("../shift/scanner.js");
5
- const writeUnmatchedGroupCloseMessage = (unscanned) => `Unmatched )${(unscanned === "" ? "" : ` before ${unscanned}`)}`;
6
- exports.writeUnmatchedGroupCloseMessage = writeUnmatchedGroupCloseMessage;
7
- exports.unclosedGroupMessage = "Missing )";
8
- const writeOpenRangeMessage = (min, comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
9
- exports.writeOpenRangeMessage = writeOpenRangeMessage;
10
- const writeUnpairableComparatorMessage = (comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
11
- exports.writeUnpairableComparatorMessage = writeUnpairableComparatorMessage;
12
- const writeMultipleLeftBoundsMessage = (openLimit, openComparator, limit, comparator) => `An expression may have at most one left bound (parsed ${openLimit}${scanner_js_1.Scanner.invertedComparators[openComparator]}, ${limit}${scanner_js_1.Scanner.invertedComparators[comparator]})`;
13
- exports.writeMultipleLeftBoundsMessage = writeMultipleLeftBoundsMessage;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeUnterminatedEnclosedMessage = exports.enclosingChar = exports.parseEnclosed = void 0;
4
- const regex_js_1 = require("../../../../nodes/rules/regex.js");
5
- const parseEnclosed = (s, enclosing) => {
6
- const token = s.scanner.shiftUntil(untilLookaheadIsClosing[enclosing]);
7
- if (s.scanner.lookahead === "") {
8
- return s.error((0, exports.writeUnterminatedEnclosedMessage)(token, enclosing));
9
- }
10
- // Shift the scanner one additional time for the second enclosing token
11
- if (s.scanner.shift() === "/") {
12
- // Cache the regex instance to throw right way if its invalid
13
- (0, regex_js_1.getRegex)(token);
14
- s.setRoot({ string: { regex: token } });
15
- }
16
- else {
17
- s.setRoot({ string: { value: token } });
18
- }
19
- };
20
- exports.parseEnclosed = parseEnclosed;
21
- exports.enclosingChar = {
22
- "'": 1,
23
- '"': 1,
24
- "/": 1
25
- };
26
- const untilLookaheadIsClosing = {
27
- "'": (scanner) => scanner.lookahead === `'`,
28
- '"': (scanner) => scanner.lookahead === `"`,
29
- "/": (scanner) => scanner.lookahead === `/`
30
- };
31
- const enclosingCharDescriptions = {
32
- '"': "double-quote",
33
- "'": "single-quote",
34
- "/": "forward slash"
35
- };
36
- const writeUnterminatedEnclosedMessage = (fragment, enclosing) => `${enclosing}${fragment} requires a closing ${enclosingCharDescriptions[enclosing]}`;
37
- exports.writeUnterminatedEnclosedMessage = writeUnterminatedEnclosedMessage;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseOperand = void 0;
4
- const enclosed_js_1 = require("./enclosed.js");
5
- const unenclosed_js_1 = require("./unenclosed.js");
6
- const parseOperand = (s) => s.scanner.lookahead === ""
7
- ? s.error((0, unenclosed_js_1.writeMissingOperandMessage)(s))
8
- : s.scanner.lookahead === "("
9
- ? s.shiftedByOne().reduceGroupOpen()
10
- : s.scanner.lookaheadIsIn(enclosed_js_1.enclosingChar)
11
- ? (0, enclosed_js_1.parseEnclosed)(s, s.scanner.shift())
12
- : s.scanner.lookahead === " "
13
- ? (0, exports.parseOperand)(s.shiftedByOne())
14
- : (0, unenclosed_js_1.parseUnenclosed)(s);
15
- exports.parseOperand = parseOperand;