@cuxt/sandboxjs 0.1.0 → 0.1.3

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 (226) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +198 -185
  3. package/{build → dist/cjs}/Sandbox.d.ts +15 -6
  4. package/dist/cjs/Sandbox.js +126 -0
  5. package/dist/{SandboxExec.d.ts → cjs/SandboxExec.d.ts} +8 -17
  6. package/dist/cjs/SandboxExec.js +227 -0
  7. package/{build/eval.d.ts → dist/cjs/eval/index.d.ts} +10 -2
  8. package/dist/cjs/eval/index.js +233 -0
  9. package/dist/cjs/executor/executorUtils.d.ts +161 -0
  10. package/dist/cjs/executor/executorUtils.js +930 -0
  11. package/dist/cjs/executor/index.d.ts +1 -0
  12. package/dist/cjs/executor/index.js +2 -0
  13. package/dist/cjs/executor/ops/assignment.d.ts +1 -0
  14. package/dist/cjs/executor/ops/assignment.js +88 -0
  15. package/dist/cjs/executor/ops/call.d.ts +1 -0
  16. package/dist/cjs/executor/ops/call.js +160 -0
  17. package/dist/cjs/executor/ops/comparison.d.ts +1 -0
  18. package/dist/cjs/executor/ops/comparison.js +36 -0
  19. package/dist/cjs/executor/ops/control.d.ts +1 -0
  20. package/dist/cjs/executor/ops/control.js +203 -0
  21. package/dist/cjs/executor/ops/functions.d.ts +1 -0
  22. package/dist/cjs/executor/ops/functions.js +55 -0
  23. package/dist/cjs/executor/ops/index.d.ts +0 -0
  24. package/dist/cjs/executor/ops/index.js +11 -0
  25. package/dist/cjs/executor/ops/literals.d.ts +1 -0
  26. package/dist/cjs/executor/ops/literals.js +45 -0
  27. package/dist/cjs/executor/ops/misc.d.ts +1 -0
  28. package/dist/cjs/executor/ops/misc.js +25 -0
  29. package/dist/cjs/executor/ops/object.d.ts +1 -0
  30. package/dist/cjs/executor/ops/object.js +51 -0
  31. package/dist/cjs/executor/ops/prop.d.ts +1 -0
  32. package/dist/cjs/executor/ops/prop.js +70 -0
  33. package/dist/cjs/executor/ops/unary.d.ts +1 -0
  34. package/dist/cjs/executor/ops/unary.js +48 -0
  35. package/dist/cjs/executor/ops/variables.d.ts +1 -0
  36. package/dist/cjs/executor/ops/variables.js +16 -0
  37. package/dist/cjs/executor/opsRegistry.d.ts +33 -0
  38. package/dist/cjs/executor/opsRegistry.js +8 -0
  39. package/dist/cjs/package.json +3 -0
  40. package/dist/cjs/parser/index.d.ts +3 -0
  41. package/dist/cjs/parser/index.js +1 -0
  42. package/dist/{parser.d.ts → cjs/parser/lisp.d.ts} +29 -42
  43. package/dist/cjs/parser/lispTypes/conditionals.d.ts +2 -0
  44. package/dist/cjs/parser/lispTypes/conditionals.js +135 -0
  45. package/dist/cjs/parser/lispTypes/control.d.ts +2 -0
  46. package/dist/cjs/parser/lispTypes/control.js +204 -0
  47. package/dist/cjs/parser/lispTypes/declarations.d.ts +2 -0
  48. package/dist/cjs/parser/lispTypes/declarations.js +99 -0
  49. package/dist/cjs/parser/lispTypes/index.d.ts +3 -0
  50. package/dist/cjs/parser/lispTypes/index.js +17 -0
  51. package/dist/cjs/parser/lispTypes/operators.d.ts +2 -0
  52. package/dist/cjs/parser/lispTypes/operators.js +252 -0
  53. package/dist/cjs/parser/lispTypes/shared.d.ts +38 -0
  54. package/dist/cjs/parser/lispTypes/structures.d.ts +2 -0
  55. package/dist/cjs/parser/lispTypes/structures.js +188 -0
  56. package/dist/cjs/parser/lispTypes/values.d.ts +2 -0
  57. package/dist/cjs/parser/lispTypes/values.js +89 -0
  58. package/dist/cjs/parser/parserUtils.d.ts +34 -0
  59. package/dist/cjs/parser/parserUtils.js +968 -0
  60. package/dist/cjs/utils/CodeString.d.ts +16 -0
  61. package/dist/cjs/utils/CodeString.js +64 -0
  62. package/dist/cjs/utils/ExecContext.d.ts +34 -0
  63. package/dist/cjs/utils/ExecContext.js +171 -0
  64. package/dist/cjs/utils/Prop.d.ts +16 -0
  65. package/dist/cjs/utils/Prop.js +81 -0
  66. package/dist/cjs/utils/Scope.d.ts +47 -0
  67. package/dist/cjs/utils/Scope.js +127 -0
  68. package/dist/cjs/utils/errors.d.ts +10 -0
  69. package/dist/cjs/utils/errors.js +12 -0
  70. package/dist/cjs/utils/functionReplacements.d.ts +11 -0
  71. package/dist/cjs/utils/functionReplacements.js +362 -0
  72. package/dist/cjs/utils/index.d.ts +7 -0
  73. package/dist/cjs/utils/index.js +7 -0
  74. package/dist/cjs/utils/types.d.ts +221 -0
  75. package/dist/cjs/utils/types.js +164 -0
  76. package/dist/cjs/utils/unraw.js +145 -0
  77. package/dist/{node → esm}/Sandbox.d.ts +15 -6
  78. package/dist/esm/Sandbox.js +115 -0
  79. package/dist/esm/Sandbox.js.map +1 -0
  80. package/{build → dist/esm}/SandboxExec.d.ts +8 -17
  81. package/dist/esm/SandboxExec.js +224 -0
  82. package/dist/esm/SandboxExec.js.map +1 -0
  83. package/dist/{eval.d.ts → esm/eval/index.d.ts} +10 -2
  84. package/dist/esm/eval/index.js +235 -0
  85. package/dist/esm/eval/index.js.map +1 -0
  86. package/dist/esm/executor/executorUtils.d.ts +161 -0
  87. package/dist/esm/executor/executorUtils.js +898 -0
  88. package/dist/esm/executor/executorUtils.js.map +1 -0
  89. package/dist/esm/executor/index.d.ts +1 -0
  90. package/dist/esm/executor/index.js +2 -0
  91. package/dist/esm/executor/ops/assignment.d.ts +1 -0
  92. package/dist/esm/executor/ops/assignment.js +90 -0
  93. package/dist/esm/executor/ops/assignment.js.map +1 -0
  94. package/dist/esm/executor/ops/call.d.ts +1 -0
  95. package/dist/esm/executor/ops/call.js +162 -0
  96. package/dist/esm/executor/ops/call.js.map +1 -0
  97. package/dist/esm/executor/ops/comparison.d.ts +1 -0
  98. package/dist/esm/executor/ops/comparison.js +38 -0
  99. package/dist/esm/executor/ops/comparison.js.map +1 -0
  100. package/dist/esm/executor/ops/control.d.ts +1 -0
  101. package/dist/esm/executor/ops/control.js +205 -0
  102. package/dist/esm/executor/ops/control.js.map +1 -0
  103. package/dist/esm/executor/ops/functions.d.ts +1 -0
  104. package/dist/esm/executor/ops/functions.js +57 -0
  105. package/dist/esm/executor/ops/functions.js.map +1 -0
  106. package/dist/esm/executor/ops/index.d.ts +0 -0
  107. package/dist/esm/executor/ops/index.js +11 -0
  108. package/dist/esm/executor/ops/literals.d.ts +1 -0
  109. package/dist/esm/executor/ops/literals.js +47 -0
  110. package/dist/esm/executor/ops/literals.js.map +1 -0
  111. package/dist/esm/executor/ops/misc.d.ts +1 -0
  112. package/dist/esm/executor/ops/misc.js +27 -0
  113. package/dist/esm/executor/ops/misc.js.map +1 -0
  114. package/dist/esm/executor/ops/object.d.ts +1 -0
  115. package/dist/esm/executor/ops/object.js +53 -0
  116. package/dist/esm/executor/ops/object.js.map +1 -0
  117. package/dist/esm/executor/ops/prop.d.ts +1 -0
  118. package/dist/esm/executor/ops/prop.js +72 -0
  119. package/dist/esm/executor/ops/prop.js.map +1 -0
  120. package/dist/esm/executor/ops/unary.d.ts +1 -0
  121. package/dist/esm/executor/ops/unary.js +50 -0
  122. package/dist/esm/executor/ops/unary.js.map +1 -0
  123. package/dist/esm/executor/ops/variables.d.ts +1 -0
  124. package/dist/esm/executor/ops/variables.js +18 -0
  125. package/dist/esm/executor/ops/variables.js.map +1 -0
  126. package/dist/esm/executor/opsRegistry.d.ts +33 -0
  127. package/dist/esm/executor/opsRegistry.js +9 -0
  128. package/dist/esm/executor/opsRegistry.js.map +1 -0
  129. package/dist/esm/package.json +3 -0
  130. package/dist/esm/parser/index.d.ts +3 -0
  131. package/dist/esm/parser/index.js +1 -0
  132. package/{build/parser.d.ts → dist/esm/parser/lisp.d.ts} +29 -42
  133. package/dist/esm/parser/lispTypes/conditionals.d.ts +2 -0
  134. package/dist/esm/parser/lispTypes/conditionals.js +137 -0
  135. package/dist/esm/parser/lispTypes/conditionals.js.map +1 -0
  136. package/dist/esm/parser/lispTypes/control.d.ts +2 -0
  137. package/dist/esm/parser/lispTypes/control.js +206 -0
  138. package/dist/esm/parser/lispTypes/control.js.map +1 -0
  139. package/dist/esm/parser/lispTypes/declarations.d.ts +2 -0
  140. package/dist/esm/parser/lispTypes/declarations.js +101 -0
  141. package/dist/esm/parser/lispTypes/declarations.js.map +1 -0
  142. package/dist/esm/parser/lispTypes/index.d.ts +3 -0
  143. package/dist/esm/parser/lispTypes/index.js +19 -0
  144. package/dist/esm/parser/lispTypes/index.js.map +1 -0
  145. package/dist/esm/parser/lispTypes/operators.d.ts +2 -0
  146. package/dist/esm/parser/lispTypes/operators.js +254 -0
  147. package/dist/esm/parser/lispTypes/operators.js.map +1 -0
  148. package/dist/esm/parser/lispTypes/shared.d.ts +38 -0
  149. package/dist/esm/parser/lispTypes/structures.d.ts +2 -0
  150. package/dist/esm/parser/lispTypes/structures.js +190 -0
  151. package/dist/esm/parser/lispTypes/structures.js.map +1 -0
  152. package/dist/esm/parser/lispTypes/values.d.ts +2 -0
  153. package/dist/esm/parser/lispTypes/values.js +91 -0
  154. package/dist/esm/parser/lispTypes/values.js.map +1 -0
  155. package/dist/esm/parser/parserUtils.d.ts +34 -0
  156. package/dist/esm/parser/parserUtils.js +959 -0
  157. package/dist/esm/parser/parserUtils.js.map +1 -0
  158. package/dist/esm/utils/CodeString.d.ts +16 -0
  159. package/dist/esm/utils/CodeString.js +66 -0
  160. package/dist/esm/utils/CodeString.js.map +1 -0
  161. package/dist/esm/utils/ExecContext.d.ts +34 -0
  162. package/dist/esm/utils/ExecContext.js +168 -0
  163. package/dist/esm/utils/ExecContext.js.map +1 -0
  164. package/dist/esm/utils/Prop.d.ts +16 -0
  165. package/dist/esm/utils/Prop.js +80 -0
  166. package/dist/esm/utils/Prop.js.map +1 -0
  167. package/dist/esm/utils/Scope.d.ts +47 -0
  168. package/dist/esm/utils/Scope.js +122 -0
  169. package/dist/esm/utils/Scope.js.map +1 -0
  170. package/dist/esm/utils/errors.d.ts +10 -0
  171. package/dist/esm/utils/errors.js +10 -0
  172. package/dist/esm/utils/errors.js.map +1 -0
  173. package/dist/esm/utils/functionReplacements.d.ts +11 -0
  174. package/dist/esm/utils/functionReplacements.js +361 -0
  175. package/dist/esm/utils/functionReplacements.js.map +1 -0
  176. package/dist/esm/utils/index.d.ts +7 -0
  177. package/dist/esm/utils/index.js +7 -0
  178. package/dist/esm/utils/types.d.ts +221 -0
  179. package/dist/esm/utils/types.js +160 -0
  180. package/dist/esm/utils/types.js.map +1 -0
  181. package/dist/esm/utils/unraw.js +147 -0
  182. package/dist/esm/utils/unraw.js.map +1 -0
  183. package/dist/umd/Sandbox.min.js +2 -0
  184. package/dist/umd/Sandbox.min.js.map +1 -0
  185. package/dist/umd/SandboxExec.min.js +2 -0
  186. package/dist/umd/SandboxExec.min.js.map +1 -0
  187. package/package.json +70 -68
  188. package/build/Sandbox.js +0 -62
  189. package/build/SandboxExec.js +0 -214
  190. package/build/eval.js +0 -205
  191. package/build/executor.d.ts +0 -124
  192. package/build/executor.js +0 -1546
  193. package/build/parser.js +0 -1527
  194. package/build/unraw.js +0 -168
  195. package/build/utils.d.ts +0 -264
  196. package/build/utils.js +0 -362
  197. package/dist/Sandbox.d.ts +0 -25
  198. package/dist/Sandbox.js +0 -270
  199. package/dist/Sandbox.js.map +0 -1
  200. package/dist/Sandbox.min.js +0 -2
  201. package/dist/Sandbox.min.js.map +0 -1
  202. package/dist/SandboxExec.js +0 -218
  203. package/dist/SandboxExec.js.map +0 -1
  204. package/dist/SandboxExec.min.js +0 -2
  205. package/dist/SandboxExec.min.js.map +0 -1
  206. package/dist/executor.d.ts +0 -124
  207. package/dist/executor.js +0 -1550
  208. package/dist/executor.js.map +0 -1
  209. package/dist/node/Sandbox.js +0 -277
  210. package/dist/node/SandboxExec.d.ts +0 -66
  211. package/dist/node/SandboxExec.js +0 -225
  212. package/dist/node/eval.d.ts +0 -27
  213. package/dist/node/executor.d.ts +0 -124
  214. package/dist/node/executor.js +0 -1567
  215. package/dist/node/parser.d.ts +0 -154
  216. package/dist/node/parser.js +0 -1704
  217. package/dist/node/utils.d.ts +0 -264
  218. package/dist/node/utils.js +0 -385
  219. package/dist/parser.js +0 -1690
  220. package/dist/parser.js.map +0 -1
  221. package/dist/unraw.d.ts +0 -11
  222. package/dist/utils.d.ts +0 -264
  223. package/dist/utils.js +0 -365
  224. package/dist/utils.js.map +0 -1
  225. /package/{build → dist/cjs/utils}/unraw.d.ts +0 -0
  226. /package/dist/{node → esm/utils}/unraw.d.ts +0 -0
@@ -0,0 +1,206 @@
1
+ import { CodeString } from "../../utils/CodeString.js";
2
+ import { LispType } from "../../utils/types.js";
3
+ import "../../utils/index.js";
4
+ //#region src/parser/lispTypes/control.ts
5
+ function registerControlLispTypes({ ParseError, createLisp, emptyString, expandDestructure, extractStatementLabels, insertSemicolons, lispify, lispifyBlock, lispifyExpr, lispifyReturnExpr, restOfExp, semiColon, setLispType, startingExecpted, wrapLabeledStatement }) {
6
+ const iteratorRegex = /^((let|var|const|internal)\s+)?\s*([a-zA-Z$_][a-zA-Z\d$_]*)\s+(in|of)(?![\w$])/;
7
+ const iteratorDestructureRegex = /^((let|var|const|internal)\s+)\s*([[{])/;
8
+ const ofStart2 = lispify({ maxDepth: 10 }, new CodeString("let $$iterator = $$obj[Symbol.iterator]()"), ["initialize"]);
9
+ const ofStart3 = lispify({ maxDepth: 10 }, new CodeString("let $$next = $$iterator.next()"), ["initialize"]);
10
+ const ofCondition = lispify({ maxDepth: 10 }, new CodeString("return !$$next.done"), ["initialize"]);
11
+ const ofStep = lispify({ maxDepth: 10 }, new CodeString("$$next = $$iterator.next()"));
12
+ const asyncOfStart2 = lispify({ maxDepth: 10 }, new CodeString("let $$iterator = $$obj"), ["initialize"]);
13
+ const asyncOfStart3 = lispify({ maxDepth: 10 }, new CodeString("let $$next = $$iterator.next()"), ["initialize"]);
14
+ const asyncOfStep = lispify({ maxDepth: 10 }, new CodeString("$$next = $$iterator.next()"));
15
+ const inStart2 = lispify({ maxDepth: 10 }, new CodeString("let $$keys = Object.keys($$obj)"), ["initialize"]);
16
+ const inStart3 = lispify({ maxDepth: 10 }, new CodeString("let $$keyIndex = 0"), ["initialize"]);
17
+ const inStep = lispify({ maxDepth: 10 }, new CodeString("$$keyIndex++"));
18
+ const inCondition = lispify({ maxDepth: 10 }, new CodeString("return $$keyIndex < $$keys.length"), ["initialize"]);
19
+ setLispType([
20
+ "for",
21
+ "do",
22
+ "while"
23
+ ], (ctx) => {
24
+ const { constants, type, part, res } = ctx;
25
+ const labels = extractStatementLabels(res[1]);
26
+ let i = 0;
27
+ let startStep = LispType.True;
28
+ let startInternal = [];
29
+ let getIterator = LispType.None;
30
+ let beforeStep = LispType.None;
31
+ let checkFirst = LispType.True;
32
+ let condition;
33
+ let step = LispType.True;
34
+ let body;
35
+ const isForAwait = type === "for" && res[2] ? LispType.True : LispType.None;
36
+ switch (type) {
37
+ case "while": {
38
+ i = part.toString().indexOf("(") + 1;
39
+ const extract = restOfExp(constants, part.substring(i), [], "(");
40
+ if (!extract.trimStart().length) throw new SyntaxError("Unexpected end of expression");
41
+ condition = lispifyReturnExpr(constants, extract);
42
+ body = restOfExp(constants, part.substring(i + extract.length + 1)).trim();
43
+ if (body.char(0) === "{") body = body.slice(1, -1);
44
+ break;
45
+ }
46
+ case "for": {
47
+ i = part.toString().indexOf("(") + 1;
48
+ const args = [];
49
+ let extract2 = emptyString;
50
+ for (let k = 0; k < 3; k++) {
51
+ extract2 = restOfExp(constants, part.substring(i), [/^[;)]/]);
52
+ args.push(extract2.trim());
53
+ i += extract2.length + 1;
54
+ if (part.char(i - 1) === ")") break;
55
+ }
56
+ let iterator;
57
+ let iteratorDestructure;
58
+ if (args.length === 1 && (iterator = iteratorRegex.exec(args[0].toString()))) {
59
+ const iterableExpr = args[0].substring(iterator[0].length);
60
+ if (!iterableExpr.trimStart().length) throw new SyntaxError("Unexpected end of expression");
61
+ if (iterator[4] === "of") {
62
+ getIterator = lispifyReturnExpr(constants, iterableExpr);
63
+ startInternal = isForAwait ? [asyncOfStart2, asyncOfStart3] : [ofStart2, ofStart3];
64
+ condition = ofCondition;
65
+ step = isForAwait ? asyncOfStep : ofStep;
66
+ beforeStep = lispify(constants, new CodeString((iterator[1] || "let ") + iterator[3] + " = $$next.value"), ["initialize"]);
67
+ } else {
68
+ if (isForAwait) throw new SyntaxError("Unexpected token 'in'");
69
+ getIterator = lispifyReturnExpr(constants, iterableExpr);
70
+ startInternal = [inStart2, inStart3];
71
+ step = inStep;
72
+ condition = inCondition;
73
+ beforeStep = lispify(constants, new CodeString((iterator[1] || "let ") + iterator[3] + " = $$keys[$$keyIndex]"), ["initialize"]);
74
+ }
75
+ } else if (args.length === 1 && (iteratorDestructure = iteratorDestructureRegex.exec(args[0].toString()))) {
76
+ const keyword = iteratorDestructure[1].trim();
77
+ const openBracket = iteratorDestructure[3];
78
+ const closeBracket = openBracket === "[" ? "]" : "}";
79
+ const keywordPrefixLen = iteratorDestructure[0].length - 1;
80
+ const patternContent = restOfExp(constants, args[0].substring(keywordPrefixLen + 1), [], openBracket);
81
+ const patternStr = openBracket + patternContent.toString() + closeBracket;
82
+ const afterClose = args[0].substring(keywordPrefixLen + 1 + patternContent.length + 1).trimStart();
83
+ const inOfMatch = /^(in|of)(?![\w$])\s*/.exec(afterClose.toString());
84
+ if (!inOfMatch) throw new SyntaxError("Invalid for loop definition");
85
+ const inOf = inOfMatch[1];
86
+ const iterExpr = afterClose.substring(inOfMatch[0].length);
87
+ if (!iterExpr.trimStart().length) throw new SyntaxError("Unexpected end of expression");
88
+ const tempVarName = "$$_fv";
89
+ if (inOf === "of") {
90
+ getIterator = lispifyReturnExpr(constants, iterExpr);
91
+ startInternal = isForAwait ? [asyncOfStart2, asyncOfStart3] : [ofStart2, ofStart3];
92
+ condition = ofCondition;
93
+ step = isForAwait ? asyncOfStep : ofStep;
94
+ const stmts = lispifyBlock(new CodeString(expandDestructure(keyword, patternStr, tempVarName)), constants, false, ctx);
95
+ beforeStep = createLisp({
96
+ op: LispType.InternalBlock,
97
+ a: [lispify(constants, new CodeString(`${keyword} ${tempVarName} = $$next.value`), ["initialize"]), ...stmts],
98
+ b: LispType.None
99
+ });
100
+ } else {
101
+ getIterator = lispifyReturnExpr(constants, iterExpr);
102
+ startInternal = [inStart2, inStart3];
103
+ step = inStep;
104
+ condition = inCondition;
105
+ const stmts = lispifyBlock(new CodeString(expandDestructure(keyword, patternStr, tempVarName)), constants, false, ctx);
106
+ beforeStep = createLisp({
107
+ op: LispType.InternalBlock,
108
+ a: [lispify(constants, new CodeString(`${keyword} ${tempVarName} = $$keys[$$keyIndex]`), ["initialize"]), ...stmts],
109
+ b: LispType.None
110
+ });
111
+ }
112
+ } else if (args.length === 3) {
113
+ const [startArg, conditionArg, stepArg] = args;
114
+ if (startArg.length) startStep = lispifyExpr(constants, startArg, startingExecpted, ctx);
115
+ condition = conditionArg.length ? lispifyReturnExpr(constants, conditionArg) : LispType.True;
116
+ if (stepArg.length) step = lispifyExpr(constants, stepArg, void 0, ctx);
117
+ } else throw new SyntaxError("Invalid for loop definition");
118
+ body = restOfExp(constants, part.substring(i)).trim();
119
+ if (body.char(0) === "{") body = body.slice(1, -1);
120
+ break;
121
+ }
122
+ case "do": {
123
+ checkFirst = LispType.None;
124
+ const isBlock = !!res[2];
125
+ body = restOfExp(constants, part.substring(res[0].length), isBlock ? [/^\}/] : [semiColon]);
126
+ condition = lispifyReturnExpr(constants, restOfExp(constants, part.substring(part.toString().indexOf("(", res[0].length + body.length) + 1), [], "("));
127
+ break;
128
+ }
129
+ }
130
+ const a = [
131
+ checkFirst,
132
+ startInternal,
133
+ getIterator,
134
+ startStep,
135
+ step,
136
+ condition,
137
+ beforeStep,
138
+ isForAwait,
139
+ labels
140
+ ];
141
+ ctx.lispTree = createLisp({
142
+ op: LispType.Loop,
143
+ a,
144
+ b: lispifyBlock(body, constants, false, ctx)
145
+ });
146
+ });
147
+ setLispType(["block"], (ctx) => {
148
+ const { constants, part, res } = ctx;
149
+ ctx.lispTree = wrapLabeledStatement(extractStatementLabels(res[1]), createLisp({
150
+ op: LispType.Block,
151
+ a: lispifyBlock(restOfExp(constants, part.substring(res[0].length), [], "{"), constants, false, ctx),
152
+ b: LispType.None
153
+ }));
154
+ });
155
+ setLispType(["loopAction"], (ctx) => {
156
+ const { part, res } = ctx;
157
+ const remaining = part.substring(res[0].length).trimStart();
158
+ if (remaining.length && !res[2]) throw new SyntaxError(`Unexpected token '${remaining.char(0)}'`);
159
+ ctx.lispTree = createLisp({
160
+ op: LispType.LoopAction,
161
+ a: res[1],
162
+ b: res[2] || LispType.None
163
+ });
164
+ });
165
+ const catchReg = /^\s*(catch\s*(\(\s*([a-zA-Z$_][a-zA-Z\d$_]*)\s*\))?|finally)\s*\{/;
166
+ const catchEmptyBindingReg = /^\s*catch\s*\(\s*\)/;
167
+ const catchReservedBindingReg = /^\s*catch\s*\(\s*(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with|class|const|enum|export|extends|implements|import|interface|let|package|private|protected|public|static|super|yield|await)\s*\)/;
168
+ const finallyKeywordReg = /^\s*finally\b/;
169
+ setLispType(["try"], (ctx) => {
170
+ const { constants, part, res } = ctx;
171
+ const body = restOfExp(constants, part.substring(res[0].length), [], "{");
172
+ const afterBody = part.substring(res[0].length + body.length + 1).toString();
173
+ if (catchEmptyBindingReg.test(afterBody)) throw new ParseError("Unexpected token ')'", part.toString());
174
+ const reservedMatch = catchReservedBindingReg.exec(afterBody);
175
+ if (reservedMatch) throw new ParseError(`Unexpected token '${reservedMatch[1]}'`, part.toString());
176
+ const finallyMatch = finallyKeywordReg.exec(afterBody);
177
+ if (finallyMatch && !/^\s*\{/.test(afterBody.substring(finallyMatch[0].length))) throw new ParseError("Unexpected token", part.toString());
178
+ let catchRes = catchReg.exec(afterBody);
179
+ let finallyBody;
180
+ let exception = "";
181
+ let catchBody;
182
+ let offset = 0;
183
+ if (!catchRes) throw new ParseError("Missing catch or finally after try", part.toString());
184
+ if (catchRes[1].startsWith("catch")) {
185
+ catchRes = catchReg.exec(part.substring(res[0].length + body.length + 1).toString());
186
+ exception = catchRes[3] || "";
187
+ catchBody = restOfExp(constants, part.substring(res[0].length + body.length + 1 + catchRes[0].length), [], "{");
188
+ offset = res[0].length + body.length + 1 + catchRes[0].length + catchBody.length + 1;
189
+ if ((catchRes = catchReg.exec(part.substring(offset).toString())) && catchRes[1].startsWith("finally")) finallyBody = restOfExp(constants, part.substring(offset + catchRes[0].length), [], "{");
190
+ } else finallyBody = restOfExp(constants, part.substring(res[0].length + body.length + 1 + catchRes[0].length), [], "{");
191
+ const b = [
192
+ exception,
193
+ lispifyBlock(insertSemicolons(constants, catchBody || emptyString), constants, false, ctx),
194
+ lispifyBlock(insertSemicolons(constants, finallyBody || emptyString), constants, false, ctx)
195
+ ];
196
+ ctx.lispTree = wrapLabeledStatement(extractStatementLabels(res[1]), createLisp({
197
+ op: LispType.Try,
198
+ a: lispifyBlock(insertSemicolons(constants, body), constants, false, ctx),
199
+ b
200
+ }));
201
+ });
202
+ }
203
+ //#endregion
204
+ export { registerControlLispTypes };
205
+
206
+ //# sourceMappingURL=control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.js","names":[],"sources":["../../../../src/parser/lispTypes/control.ts"],"sourcesContent":["import { CodeString, LispType } from '../../utils';\nimport type {\n Block,\n InternalCode,\n Lisp,\n LispItem,\n Loop,\n LoopAction,\n StatementLabel,\n Try,\n} from '../lisp';\nimport type { RegisterLispTypesDeps } from './shared';\n\nexport function registerControlLispTypes({\n ParseError,\n createLisp,\n emptyString,\n expandDestructure,\n extractStatementLabels,\n insertSemicolons,\n lispify,\n lispifyBlock,\n lispifyExpr,\n lispifyReturnExpr,\n restOfExp,\n semiColon,\n setLispType,\n startingExecpted,\n wrapLabeledStatement,\n}: RegisterLispTypesDeps) {\n const iteratorRegex =\n /^((let|var|const|internal)\\s+)?\\s*([a-zA-Z$_][a-zA-Z\\d$_]*)\\s+(in|of)(?![\\w$])/;\n const iteratorDestructureRegex = /^((let|var|const|internal)\\s+)\\s*([[{])/;\n\n const ofStart2 = lispify(\n { maxDepth: 10 } as any,\n new CodeString('let $$iterator = $$obj[Symbol.iterator]()'),\n ['initialize'],\n );\n const ofStart3 = lispify(\n { maxDepth: 10 } as any,\n new CodeString('let $$next = $$iterator.next()'),\n ['initialize'],\n );\n const ofCondition = lispify({ maxDepth: 10 } as any, new CodeString('return !$$next.done'), [\n 'initialize',\n ]);\n const ofStep = lispify({ maxDepth: 10 } as any, new CodeString('$$next = $$iterator.next()'));\n const asyncOfStart2 = lispify({ maxDepth: 10 } as any, new CodeString('let $$iterator = $$obj'), [\n 'initialize',\n ]);\n const asyncOfStart3 = lispify(\n { maxDepth: 10 } as any,\n new CodeString('let $$next = $$iterator.next()'),\n ['initialize'],\n );\n const asyncOfStep = lispify(\n { maxDepth: 10 } as any,\n new CodeString('$$next = $$iterator.next()'),\n );\n const inStart2 = lispify(\n { maxDepth: 10 } as any,\n new CodeString('let $$keys = Object.keys($$obj)'),\n ['initialize'],\n );\n const inStart3 = lispify({ maxDepth: 10 } as any, new CodeString('let $$keyIndex = 0'), [\n 'initialize',\n ]);\n const inStep = lispify({ maxDepth: 10 } as any, new CodeString('$$keyIndex++'));\n const inCondition = lispify(\n { maxDepth: 10 } as any,\n new CodeString('return $$keyIndex < $$keys.length'),\n ['initialize'],\n );\n\n setLispType(['for', 'do', 'while'] as const, (ctx) => {\n const { constants, type, part, res } = ctx;\n const labels = extractStatementLabels(res[1]);\n let i = 0;\n let startStep: LispItem = LispType.True;\n let startInternal: Lisp[] = [];\n let getIterator: Lisp | LispType.None = LispType.None;\n let beforeStep: LispItem = LispType.None;\n let checkFirst = LispType.True;\n let condition: LispItem;\n let step: LispItem = LispType.True;\n let body: CodeString;\n const isForAwait: LispItem = type === 'for' && res[2] ? LispType.True : LispType.None;\n switch (type) {\n case 'while': {\n i = part.toString().indexOf('(') + 1;\n const extract = restOfExp(constants, part.substring(i), [], '(');\n if (!extract.trimStart().length) {\n throw new SyntaxError('Unexpected end of expression');\n }\n condition = lispifyReturnExpr(constants, extract);\n body = restOfExp(constants, part.substring(i + extract.length + 1)).trim();\n if (body.char(0) === '{') body = body.slice(1, -1);\n break;\n }\n case 'for': {\n i = part.toString().indexOf('(') + 1;\n const args: CodeString[] = [];\n let extract2 = emptyString;\n for (let k = 0; k < 3; k++) {\n extract2 = restOfExp(constants, part.substring(i), [/^[;)]/]);\n args.push(extract2.trim());\n i += extract2.length + 1;\n if (part.char(i - 1) === ')') break;\n }\n let iterator: RegExpExecArray | null;\n let iteratorDestructure: RegExpExecArray | null;\n if (args.length === 1 && (iterator = iteratorRegex.exec(args[0].toString()))) {\n const iterableExpr = args[0].substring(iterator[0].length);\n if (!iterableExpr.trimStart().length) {\n throw new SyntaxError('Unexpected end of expression');\n }\n if (iterator[4] === 'of') {\n getIterator = lispifyReturnExpr(constants, iterableExpr);\n startInternal = isForAwait ? [asyncOfStart2, asyncOfStart3] : [ofStart2, ofStart3];\n condition = ofCondition;\n step = isForAwait ? asyncOfStep : ofStep;\n beforeStep = lispify(\n constants,\n new CodeString((iterator[1] || 'let ') + iterator[3] + ' = $$next.value'),\n ['initialize'],\n );\n } else {\n if (isForAwait) {\n throw new SyntaxError(\"Unexpected token 'in'\");\n }\n getIterator = lispifyReturnExpr(constants, iterableExpr);\n startInternal = [inStart2, inStart3];\n step = inStep;\n condition = inCondition;\n beforeStep = lispify(\n constants,\n new CodeString((iterator[1] || 'let ') + iterator[3] + ' = $$keys[$$keyIndex]'),\n ['initialize'],\n );\n }\n } else if (\n args.length === 1 &&\n (iteratorDestructure = iteratorDestructureRegex.exec(args[0].toString()))\n ) {\n const keyword = iteratorDestructure[1].trim();\n const openBracket = iteratorDestructure[3];\n const closeBracket = openBracket === '[' ? ']' : '}';\n const keywordPrefixLen = iteratorDestructure[0].length - 1;\n const patternContent = restOfExp(\n constants,\n args[0].substring(keywordPrefixLen + 1),\n [],\n openBracket,\n );\n const patternStr = openBracket + patternContent.toString() + closeBracket;\n const afterClose = args[0]\n .substring(keywordPrefixLen + 1 + patternContent.length + 1)\n .trimStart();\n const inOfMatch = /^(in|of)(?![\\w$])\\s*/.exec(afterClose.toString());\n if (!inOfMatch) throw new SyntaxError('Invalid for loop definition');\n const inOf = inOfMatch[1];\n const iterExpr = afterClose.substring(inOfMatch[0].length);\n if (!iterExpr.trimStart().length) {\n throw new SyntaxError('Unexpected end of expression');\n }\n const tempVarName = '$$_fv';\n if (inOf === 'of') {\n getIterator = lispifyReturnExpr(constants, iterExpr);\n startInternal = isForAwait ? [asyncOfStart2, asyncOfStart3] : [ofStart2, ofStart3];\n condition = ofCondition;\n step = isForAwait ? asyncOfStep : ofStep;\n const expandedCode = expandDestructure(keyword, patternStr, tempVarName);\n const stmts = lispifyBlock(new CodeString(expandedCode), constants, false, ctx);\n beforeStep = createLisp<InternalCode>({\n op: LispType.InternalBlock,\n a: [\n lispify(constants, new CodeString(`${keyword} ${tempVarName} = $$next.value`), [\n 'initialize',\n ]),\n ...stmts,\n ],\n b: LispType.None,\n });\n } else {\n getIterator = lispifyReturnExpr(constants, iterExpr);\n startInternal = [inStart2, inStart3];\n step = inStep;\n condition = inCondition;\n const expandedCode = expandDestructure(keyword, patternStr, tempVarName);\n const stmts = lispifyBlock(new CodeString(expandedCode), constants, false, ctx);\n beforeStep = createLisp<InternalCode>({\n op: LispType.InternalBlock,\n a: [\n lispify(\n constants,\n new CodeString(`${keyword} ${tempVarName} = $$keys[$$keyIndex]`),\n ['initialize'],\n ),\n ...stmts,\n ],\n b: LispType.None,\n });\n }\n } else if (args.length === 3) {\n const [startArg, conditionArg, stepArg] = args;\n if (startArg.length) {\n startStep = lispifyExpr(constants, startArg, startingExecpted, ctx);\n }\n condition = conditionArg.length\n ? lispifyReturnExpr(constants, conditionArg)\n : LispType.True;\n if (stepArg.length) {\n step = lispifyExpr(constants, stepArg, undefined, ctx);\n }\n } else {\n throw new SyntaxError('Invalid for loop definition');\n }\n body = restOfExp(constants, part.substring(i)).trim();\n if (body.char(0) === '{') body = body.slice(1, -1);\n break;\n }\n case 'do': {\n checkFirst = LispType.None;\n const isBlock = !!res[2];\n body = restOfExp(constants, part.substring(res[0].length), isBlock ? [/^\\}/] : [semiColon]);\n condition = lispifyReturnExpr(\n constants,\n restOfExp(\n constants,\n part.substring(part.toString().indexOf('(', res[0].length + body.length) + 1),\n [],\n '(',\n ),\n );\n break;\n }\n }\n const a = [\n checkFirst,\n startInternal,\n getIterator,\n startStep,\n step,\n condition,\n beforeStep,\n isForAwait,\n labels,\n ] as LispItem;\n ctx.lispTree = createLisp<Loop>({\n op: LispType.Loop,\n a,\n b: lispifyBlock(body, constants, false, ctx),\n });\n });\n\n setLispType(['block'] as const, (ctx) => {\n const { constants, part, res } = ctx;\n const labels = extractStatementLabels(res[1]);\n ctx.lispTree = wrapLabeledStatement(\n labels,\n createLisp<Block>({\n op: LispType.Block,\n a: lispifyBlock(\n restOfExp(constants, part.substring(res[0].length), [], '{'),\n constants,\n false,\n ctx,\n ),\n b: LispType.None,\n }),\n ) as Lisp;\n });\n\n setLispType(['loopAction'] as const, (ctx) => {\n const { part, res } = ctx;\n const remaining = part.substring(res[0].length).trimStart();\n if (remaining.length && !res[2]) {\n throw new SyntaxError(`Unexpected token '${remaining.char(0)}'`);\n }\n ctx.lispTree = createLisp<LoopAction>({\n op: LispType.LoopAction,\n a: res[1],\n b: (res[2] || LispType.None) as StatementLabel,\n });\n });\n\n const catchReg = /^\\s*(catch\\s*(\\(\\s*([a-zA-Z$_][a-zA-Z\\d$_]*)\\s*\\))?|finally)\\s*\\{/;\n const catchEmptyBindingReg = /^\\s*catch\\s*\\(\\s*\\)/;\n const catchReservedBindingReg =\n /^\\s*catch\\s*\\(\\s*(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with|class|const|enum|export|extends|implements|import|interface|let|package|private|protected|public|static|super|yield|await)\\s*\\)/;\n const finallyKeywordReg = /^\\s*finally\\b/;\n\n setLispType(['try'] as const, (ctx) => {\n const { constants, part, res } = ctx;\n const body = restOfExp(constants, part.substring(res[0].length), [], '{');\n const afterBody = part.substring(res[0].length + body.length + 1).toString();\n\n if (catchEmptyBindingReg.test(afterBody)) {\n throw new ParseError(\"Unexpected token ')'\", part.toString());\n }\n\n const reservedMatch = catchReservedBindingReg.exec(afterBody);\n if (reservedMatch) {\n throw new ParseError(`Unexpected token '${reservedMatch[1]}'`, part.toString());\n }\n\n const finallyMatch = finallyKeywordReg.exec(afterBody);\n if (finallyMatch && !/^\\s*\\{/.test(afterBody.substring(finallyMatch[0].length))) {\n throw new ParseError('Unexpected token', part.toString());\n }\n\n let catchRes = catchReg.exec(afterBody);\n let finallyBody;\n let exception = '';\n let catchBody;\n let offset = 0;\n\n if (!catchRes) {\n throw new ParseError('Missing catch or finally after try', part.toString());\n }\n\n if (catchRes[1].startsWith('catch')) {\n catchRes = catchReg.exec(part.substring(res[0].length + body.length + 1).toString());\n exception = catchRes![3] || '';\n catchBody = restOfExp(\n constants,\n part.substring(res[0].length + body.length + 1 + catchRes![0].length),\n [],\n '{',\n );\n offset = res[0].length + body.length + 1 + catchRes![0].length + catchBody.length + 1;\n if (\n (catchRes = catchReg.exec(part.substring(offset).toString())) &&\n catchRes[1].startsWith('finally')\n ) {\n finallyBody = restOfExp(constants, part.substring(offset + catchRes[0].length), [], '{');\n }\n } else {\n finallyBody = restOfExp(\n constants,\n part.substring(res[0].length + body.length + 1 + catchRes![0].length),\n [],\n '{',\n );\n }\n const b = [\n exception,\n lispifyBlock(insertSemicolons(constants, catchBody || emptyString), constants, false, ctx),\n lispifyBlock(insertSemicolons(constants, finallyBody || emptyString), constants, false, ctx),\n ] as LispItem;\n ctx.lispTree = wrapLabeledStatement(\n extractStatementLabels(res[1]),\n createLisp<Try>({\n op: LispType.Try,\n a: lispifyBlock(insertSemicolons(constants, body), constants, false, ctx),\n b,\n }),\n ) as Lisp;\n });\n}\n"],"mappings":";;;;AAaA,SAAgB,yBAAyB,EACvC,YACA,YACA,aACA,mBACA,wBACA,kB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AAU,IAAI,GAAG,SAAS,KAAK,SAAS,IAAI,SAAU,GAAG,OAAO,EACrE,EAAE,EACF,IACD;EAEH,MAAM,IAAI;GACR;GACA,aAAa,iBAAiB,WAAW,aAAa,YAAY,EAAE,WAAW,OAAO,IAAI;GAC1F,aAAa,iBAAiB,WAAW,eAAe,YAAY,EAAE,WAAW,OAAO,IAAI;GAC7F;AACD,MAAI,WAAW,qBACb,uBAAuB,IAAI,GAAG,EAC9B,WAAgB;GACd,IAAI,SAAS;GACb,GAAG,aAAa,iBAAiB,WAAW,KAAK,EAAE,WAAW,OAAO,IAAI;GACzE;GACD,CAAC,CACH;GACD"}
@@ -0,0 +1,2 @@
1
+ import { RegisterLispTypesDeps } from './shared';
2
+ export declare function registerDeclarationLispTypes({ createLisp, expectTypes, expandDestructure, expandFunctionParamDestructure, lispify, lispifyBlock, lispifyFunction, restOfExp, semiColon, setLispType, splitByCommasDestructure, }: RegisterLispTypesDeps): void;
@@ -0,0 +1,101 @@
1
+ import { CodeString } from "../../utils/CodeString.js";
2
+ import { LispType, reservedWords } from "../../utils/types.js";
3
+ import "../../utils/index.js";
4
+ //#region src/parser/lispTypes/declarations.ts
5
+ function registerDeclarationLispTypes({ createLisp, expectTypes, expandDestructure, expandFunctionParamDestructure, lispify, lispifyBlock, lispifyFunction, restOfExp, semiColon, setLispType, splitByCommasDestructure }) {
6
+ setLispType(["initializeDestructure"], (ctx) => {
7
+ const { constants, part, res } = ctx;
8
+ const keyword = res[1];
9
+ const openBracket = res[2];
10
+ const closeBracket = openBracket === "[" ? "]" : "}";
11
+ const patternContent = restOfExp(constants, part.substring(res[0].length), [], openBracket);
12
+ const patternStr = openBracket + patternContent.toString() + closeBracket;
13
+ const afterClose = part.substring(res[0].length + patternContent.length + 1).trimStart();
14
+ if (!afterClose.length || afterClose.char(0) !== "=") throw new SyntaxError("Destructuring declaration requires an initializer");
15
+ const stmts = lispifyBlock(new CodeString(expandDestructure(keyword, patternStr, restOfExp(constants, afterClose.substring(1).trimStart(), [semiColon]).toString())), constants, false, ctx);
16
+ ctx.lispTree = createLisp({
17
+ op: LispType.InternalBlock,
18
+ a: stmts,
19
+ b: LispType.None
20
+ });
21
+ });
22
+ setLispType(["initialize"], (ctx) => {
23
+ const { constants, part, res, expect } = ctx;
24
+ const lt = res[1] === "var" ? LispType.Var : res[1] === "let" ? LispType.Let : res[1] === "const" ? LispType.Const : LispType.Internal;
25
+ if (!res[3]) ctx.lispTree = lispify(constants, part.substring(res[0].length), expectTypes[expect].next, createLisp({
26
+ op: lt,
27
+ a: res[2],
28
+ b: LispType.None
29
+ }), false, ctx);
30
+ else {
31
+ const initExpr = part.substring(res[0].length);
32
+ if (!initExpr.trimStart().length) throw new SyntaxError("Unexpected end of expression");
33
+ ctx.lispTree = createLisp({
34
+ op: lt,
35
+ a: res[2],
36
+ b: lispify(constants, initExpr, expectTypes[expect].next, void 0, false, ctx)
37
+ });
38
+ }
39
+ });
40
+ setLispType([
41
+ "function",
42
+ "inlineFunction",
43
+ "arrowFunction",
44
+ "arrowFunctionSingle"
45
+ ], (ctx) => {
46
+ const { constants, type, part, res, expect, generatorDepth, asyncDepth } = ctx;
47
+ const isArrow = type !== "function" && type !== "inlineFunction";
48
+ const isReturn = isArrow && !res[res.length - 1];
49
+ const isGenerator = !isArrow && res[2] && res[2].trimStart().startsWith("*") ? LispType.True : LispType.None;
50
+ const isAsync = res[1] ? LispType.True : LispType.None;
51
+ let rawArgStr;
52
+ let bodyOffset;
53
+ if (type === "function" || type === "inlineFunction") {
54
+ const argsCode = restOfExp(constants, part.substring(res[0].length), [], "(");
55
+ rawArgStr = argsCode.toString().trim();
56
+ bodyOffset = res[0].length + argsCode.length + 1;
57
+ const afterParen = part.substring(bodyOffset).trimStart();
58
+ bodyOffset = part.length - afterParen.length + 1;
59
+ } else {
60
+ rawArgStr = res[2] ?? "";
61
+ bodyOffset = 0;
62
+ }
63
+ const args = [...rawArgStr ? splitByCommasDestructure(rawArgStr).map((a) => a.trim()).filter(Boolean) : []];
64
+ if (!isArrow) args.unshift((res[3] || "").trimStart());
65
+ let ended = false;
66
+ args.forEach((arg) => {
67
+ if (ended) throw new SyntaxError("Rest parameter must be last formal parameter");
68
+ if (arg.startsWith("...")) ended = true;
69
+ });
70
+ const f = restOfExp(constants, isArrow ? part.substring(res[0].length) : part.substring(bodyOffset), !isReturn ? [/^}/] : [/^[,)}\]]/, semiColon]);
71
+ let funcBody = isReturn ? "return " + f : f.toString();
72
+ const expanded = expandFunctionParamDestructure(isArrow ? args : args.slice(1), funcBody);
73
+ const finalArgs = isArrow ? expanded.args : [args[0], ...expanded.args];
74
+ funcBody = expanded.body;
75
+ finalArgs.forEach((arg) => {
76
+ if (reservedWords.has(arg.replace(/^\.\.\./, ""))) throw new SyntaxError(`Unexpected token '${arg}'`);
77
+ });
78
+ const afterFunc = isArrow ? res[0].length + f.length + 1 : bodyOffset + f.length + 1;
79
+ ctx.lispTree = lispify(constants, part.substring(afterFunc), expectTypes[expect].next, createLisp({
80
+ op: isArrow ? LispType.ArrowFunction : type === "function" ? LispType.Function : LispType.InlineFunction,
81
+ a: isArrow ? [isAsync, ...finalArgs] : [
82
+ isAsync,
83
+ isGenerator,
84
+ ...finalArgs
85
+ ],
86
+ b: constants.eager ? lispifyFunction(new CodeString(funcBody), constants, false, isArrow ? {
87
+ generatorDepth: 0,
88
+ asyncDepth: 0,
89
+ lispDepth: 0
90
+ } : {
91
+ generatorDepth: isGenerator === LispType.True ? generatorDepth + 1 : 0,
92
+ asyncDepth: isAsync === LispType.True ? asyncDepth + 1 : 0,
93
+ lispDepth: 0
94
+ }) : funcBody
95
+ }), false, ctx);
96
+ });
97
+ }
98
+ //#endregion
99
+ export { registerDeclarationLispTypes };
100
+
101
+ //# sourceMappingURL=declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.js","names":[],"sources":["../../../../src/parser/lispTypes/declarations.ts"],"sourcesContent":["import { CodeString, LispType, reservedWords } from '../../utils';\nimport type {\n ArrowFunction,\n Const,\n Function as FunctionLisp,\n InlineFunction,\n Internal,\n InternalCode,\n Let,\n Var,\n} from '../lisp';\nimport type { RegisterLispTypesDeps } from './shared';\n\nexport function registerDeclarationLispTypes({\n createLisp,\n expectTypes,\n expandDestructure,\n expandFunctionParamDestructure,\n lispify,\n lispifyBlock,\n lispifyFunction,\n restOfExp,\n semiColon,\n setLispType,\n splitByCommasDestructure,\n}: RegisterLispTypesDeps) {\n setLispType(['initializeDestructure'] as const, (ctx) => {\n const { constants, part, res } = ctx;\n const keyword = res[1] as string;\n const openBracket = res[2] as string;\n const closeBracket = openBracket === '[' ? ']' : '}';\n\n const patternContent = restOfExp(constants, part.substring(res[0].length), [], openBracket);\n const patternStr = openBracket + patternContent.toString() + closeBracket;\n\n const afterClose = part.substring(res[0].length + patternContent.length + 1).trimStart();\n if (!afterClose.length || afterClose.char(0) !== '=') {\n throw new SyntaxError('Destructuring declaration requires an initializer');\n }\n\n const rhsCode = restOfExp(constants, afterClose.substring(1).trimStart(), [semiColon]);\n const rhsStr = rhsCode.toString();\n const expandedCode = expandDestructure(keyword, patternStr, rhsStr);\n const stmts = lispifyBlock(new CodeString(expandedCode), constants, false, ctx);\n\n ctx.lispTree = createLisp<InternalCode>({\n op: LispType.InternalBlock,\n a: stmts,\n b: LispType.None,\n });\n });\n\n setLispType(['initialize'] as const, (ctx) => {\n const { constants, part, res, expect } = ctx;\n const lt =\n res[1] === 'var'\n ? LispType.Var\n : res[1] === 'let'\n ? LispType.Let\n : res[1] === 'const'\n ? LispType.Const\n : LispType.Internal;\n if (!res[3]) {\n ctx.lispTree = lispify(\n constants,\n part.substring(res[0].length),\n expectTypes[expect].next,\n createLisp<Var | Let | Const | Internal>({\n op: lt,\n a: res[2],\n b: LispType.None,\n }),\n false,\n ctx,\n );\n } else {\n const initExpr = part.substring(res[0].length);\n if (!initExpr.trimStart().length) {\n throw new SyntaxError('Unexpected end of expression');\n }\n ctx.lispTree = createLisp<Var | Let | Const | Internal>({\n op: lt,\n a: res[2],\n b: lispify(constants, initExpr, expectTypes[expect].next, undefined, false, ctx),\n });\n }\n });\n\n setLispType(\n ['function', 'inlineFunction', 'arrowFunction', 'arrowFunctionSingle'] as const,\n (ctx) => {\n const { constants, type, part, res, expect, generatorDepth, asyncDepth } = ctx;\n const isArrow = type !== 'function' && type !== 'inlineFunction';\n const isReturn = isArrow && !res[res.length - 1];\n const isGenerator =\n !isArrow && res[2] && res[2].trimStart().startsWith('*') ? LispType.True : LispType.None;\n const isAsync = res[1] ? LispType.True : LispType.None;\n let rawArgStr: string;\n let bodyOffset: number;\n if (type === 'function' || type === 'inlineFunction') {\n const argsCode = restOfExp(constants, part.substring(res[0].length), [], '(');\n rawArgStr = argsCode.toString().trim();\n bodyOffset = res[0].length + argsCode.length + 1;\n const afterParen = part.substring(bodyOffset).trimStart();\n bodyOffset = part.length - afterParen.length + 1;\n } else {\n rawArgStr = res[2] ?? '';\n bodyOffset = 0;\n }\n const rawArgs: string[] = rawArgStr\n ? splitByCommasDestructure(rawArgStr)\n .map((a) => a.trim())\n .filter(Boolean)\n : [];\n const args: string[] = [...rawArgs];\n if (!isArrow) {\n args.unshift((res[3] || '').trimStart());\n }\n let ended = false;\n args.forEach((arg: string) => {\n if (ended) throw new SyntaxError('Rest parameter must be last formal parameter');\n if (arg.startsWith('...')) ended = true;\n });\n const f = restOfExp(\n constants,\n isArrow ? part.substring(res[0].length) : part.substring(bodyOffset),\n !isReturn ? [/^}/] : [/^[,)}\\]]/, semiColon],\n );\n let funcBody = isReturn ? 'return ' + f : f.toString();\n const funcArgs = isArrow ? args : args.slice(1);\n const expanded = expandFunctionParamDestructure(funcArgs, funcBody);\n const finalArgs = isArrow ? expanded.args : [args[0], ...expanded.args];\n funcBody = expanded.body;\n finalArgs.forEach((arg: string) => {\n if (reservedWords.has(arg.replace(/^\\.\\.\\./, ''))) {\n throw new SyntaxError(`Unexpected token '${arg}'`);\n }\n });\n const afterFunc = isArrow ? res[0].length + f.length + 1 : bodyOffset + f.length + 1;\n ctx.lispTree = lispify(\n constants,\n part.substring(afterFunc),\n expectTypes[expect].next,\n createLisp<FunctionLisp | InlineFunction | ArrowFunction>({\n op: isArrow\n ? LispType.ArrowFunction\n : type === 'function'\n ? LispType.Function\n : LispType.InlineFunction,\n a: isArrow ? [isAsync, ...finalArgs] : [isAsync, isGenerator, ...finalArgs],\n b: constants.eager\n ? lispifyFunction(\n new CodeString(funcBody),\n constants,\n false,\n isArrow\n ? { generatorDepth: 0, asyncDepth: 0, lispDepth: 0 }\n : {\n generatorDepth: isGenerator === LispType.True ? generatorDepth + 1 : 0,\n asyncDepth: isAsync === LispType.True ? asyncDepth + 1 : 0,\n lispDepth: 0,\n },\n )\n : funcBody,\n }),\n false,\n ctx,\n );\n },\n );\n}\n"],"mappings":";;;;AAaA,SAAgB,6BAA6B,EAC3C,YACA,aACA,mBACA,gCACA,SACA,cACA,iBACA,WACA,WACA,aACA,4BACwB;AACxB,aAAY,CAAC,wBAAwB,GAAY,QAAQ;EACvD,MAAM,EAAE,WAAW,MAAM,QAAQ;EACjC,MAAM,UAAU,IAAI;EACpB,MAAM,cAAc,IAAI;EACxB,MAAM,eAAe,gBAAgB,MAAM,MAAM;EAEjD,MAAM,iBAAiB,UAAU,WAAW,KAAK,UAAU,IAAI,GAAG,OAAO,EAAE,EAAE,EAAE,YAAY;EAC3F,MAAM,aAAa,cAAc,eAAe,UAAU,GAAG;EAE7D,MAAM,aAAa,KAAK,UAAU,IAAI,GAAG,SAAS,eAAe,SAAS,EAAE,CAAC,WAAW;AACxF,MAAI,CAAC,WAAW,UAAU,WAAW,KAAK,EAAE,KAAK,IAC/C,OAAM,IAAI,YAAY,oDAAoD;EAM5E,MAAM,QAAQ,aAAa,IAAI,WADV,kBAAkB,SAAS,YAFhC,UAAU,WAAW,WAAW,UAAU,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,CAC/D,UAAU,CACkC,CACZ,EAAE,WAAW,OAAO,IAAI;AAE/E,MAAI,WAAW,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AAG,UAAU,CAAC,SAAS,GAAG,UAAU,GAAG;IAAC;IAAS;IAAa,GAAG;IAAU;GAC3E,GAAG,UAAU,QACT,gBACE,IAAI,WAAW,SAAS,EACxB,WACA,OACA,UACI;IAAE,gBAAgB;IAAG,YAAY;IAAG,WAAW;IAAG,GAClD;IACE,gBAAgB,gBAAgB,SAAS,OAAO,iBAAiB,IAAI;IACrE,YAAY,YAAY,SAAS,OAAO,aAAa,IAAI;IACzD,WAAW;IACZ,CACN,GACD;GACL,CAAC,EACF,OACA,IACD;GAEJ"}
@@ -0,0 +1,3 @@
1
+ import { RegisterLispTypesDeps } from './shared';
2
+ export declare function registerLispTypes(deps: RegisterLispTypesDeps): void;
3
+ export type { RegisterLispTypesDeps } from './shared';
@@ -0,0 +1,19 @@
1
+ import { registerConditionalLispTypes } from "./conditionals.js";
2
+ import { registerControlLispTypes } from "./control.js";
3
+ import { registerDeclarationLispTypes } from "./declarations.js";
4
+ import { registerOperatorLispTypes } from "./operators.js";
5
+ import { registerStructureLispTypes } from "./structures.js";
6
+ import { registerValueLispTypes } from "./values.js";
7
+ //#region src/parser/lispTypes/index.ts
8
+ function registerLispTypes(deps) {
9
+ registerStructureLispTypes(deps);
10
+ registerOperatorLispTypes(deps);
11
+ registerConditionalLispTypes(deps);
12
+ registerValueLispTypes(deps);
13
+ registerDeclarationLispTypes(deps);
14
+ registerControlLispTypes(deps);
15
+ }
16
+ //#endregion
17
+ export { registerLispTypes };
18
+
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/parser/lispTypes/index.ts"],"sourcesContent":["import type { RegisterLispTypesDeps } from './shared';\nimport { registerConditionalLispTypes } from './conditionals';\nimport { registerControlLispTypes } from './control';\nimport { registerDeclarationLispTypes } from './declarations';\nimport { registerOperatorLispTypes } from './operators';\nimport { registerStructureLispTypes } from './structures';\nimport { registerValueLispTypes } from './values';\n\nexport function registerLispTypes(deps: RegisterLispTypesDeps) {\n registerStructureLispTypes(deps);\n registerOperatorLispTypes(deps);\n registerConditionalLispTypes(deps);\n registerValueLispTypes(deps);\n registerDeclarationLispTypes(deps);\n registerControlLispTypes(deps);\n}\n\nexport type { RegisterLispTypesDeps } from './shared';\n"],"mappings":";;;;;;;AAQA,SAAgB,kBAAkB,MAA6B;AAC7D,4BAA2B,KAAK;AAChC,2BAA0B,KAAK;AAC/B,8BAA6B,KAAK;AAClC,wBAAuB,KAAK;AAC5B,8BAA6B,KAAK;AAClC,0BAAyB,KAAK"}
@@ -0,0 +1,2 @@
1
+ import { RegisterLispTypesDeps } from './shared';
2
+ export declare function registerOperatorLispTypes({ createLisp, expandDestructure, expectTypes, getDestructurePatternSource, lispifyBlock, restOfExp, lispify, lispifyExpr, setLispType, }: RegisterLispTypesDeps): void;