enyosx-ai 0.1.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 (41) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +740 -0
  3. package/dist/chunk-2WM5L76D.js +320 -0
  4. package/dist/chunk-3BNDFBX3.js +324 -0
  5. package/dist/chunk-4LJILSCT.js +30 -0
  6. package/dist/chunk-4ZV5JV6W.js +298 -0
  7. package/dist/chunk-76PHNPTY.js +631 -0
  8. package/dist/chunk-BSSA33NY.js +677 -0
  9. package/dist/chunk-EK6IDRY7.js +105 -0
  10. package/dist/chunk-FI2EBH2N.js +2232 -0
  11. package/dist/chunk-GAKKLY4M.js +276 -0
  12. package/dist/chunk-HR4G5XQI.js +319 -0
  13. package/dist/chunk-HROGCEE5.js +30 -0
  14. package/dist/chunk-MMH7M7MG.js +30 -0
  15. package/dist/chunk-NGLRXS6G.js +2079 -0
  16. package/dist/chunk-NSE6LQJC.js +681 -0
  17. package/dist/chunk-O5XZOSBW.js +2484 -0
  18. package/dist/chunk-OVCMUPMP.js +677 -0
  19. package/dist/chunk-P2YBRE3X.js +2484 -0
  20. package/dist/chunk-VVIL5NIM.js +318 -0
  21. package/dist/chunk-ZNGEBY33.js +273 -0
  22. package/dist/cli.cjs +2509 -0
  23. package/dist/cli.d.ts +1 -0
  24. package/dist/cli.js +99 -0
  25. package/dist/index.cjs +2912 -0
  26. package/dist/index.d.ts +672 -0
  27. package/dist/index.js +379 -0
  28. package/dist/parser-4JXKOWKY.js +8 -0
  29. package/dist/parser-UUB6D2CZ.js +8 -0
  30. package/dist/parser-V44AIVNI.js +8 -0
  31. package/examples/README.md +13 -0
  32. package/examples/ia-demo.eny +37 -0
  33. package/examples/sample.eny +15 -0
  34. package/examples/simple/system.eny +7 -0
  35. package/examples/spec/sample.eny +19 -0
  36. package/examples/starter/README.md +96 -0
  37. package/examples/starter/main.eny +39 -0
  38. package/examples/starter/run.js +68 -0
  39. package/examples/starter.eny +16 -0
  40. package/examples/wasm-demo.eny +34 -0
  41. package/package.json +49 -0
@@ -0,0 +1,320 @@
1
+ // src/parser.ts
2
+ async function writeWithRetry(entry, filePath, attempts = 3, delay = 1e3, onLog) {
3
+ const fsPromises = await import("fs/promises");
4
+ let attempt = 0;
5
+ const tryWrite = async () => {
6
+ attempt++;
7
+ try {
8
+ await fsPromises.appendFile(filePath, JSON.stringify(entry) + "\n", { encoding: "utf8" });
9
+ if (onLog)
10
+ onLog({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "info", event: "logfile.write.success", detail: { file: filePath } });
11
+ return;
12
+ } catch (err) {
13
+ const errEntry = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "logfile.write.retry", detail: { attempt, error: String(err) } };
14
+ if (onLog)
15
+ onLog(errEntry);
16
+ if (attempt < attempts) {
17
+ setTimeout(() => {
18
+ tryWrite().catch(() => {
19
+ });
20
+ }, delay);
21
+ } else {
22
+ const fatal = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "error", event: "logfile.write.fatal", detail: { attempt, error: String(err) } };
23
+ if (onLog)
24
+ onLog(fatal);
25
+ }
26
+ }
27
+ };
28
+ tryWrite().catch(() => {
29
+ });
30
+ }
31
+ function parse(code, options) {
32
+ const logs = [];
33
+ const log = (entry) => {
34
+ const e = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), ...entry };
35
+ logs.push(e);
36
+ if (options?.onLog)
37
+ options.onLog(e);
38
+ if (options?.logFile) {
39
+ const attempts = options?.logRetryAttempts ?? 3;
40
+ const delay = options?.logRetryDelayMs ?? 1e3;
41
+ writeWithRetry(e, options.logFile, attempts, delay, options?.onLog).catch(() => {
42
+ });
43
+ }
44
+ };
45
+ log({ level: "info", event: "parse.start", detail: { length: code.length } });
46
+ const ast = {
47
+ raw: code,
48
+ functions: [],
49
+ ias: [],
50
+ nodes: [],
51
+ modules: [],
52
+ objects: [],
53
+ forms: [],
54
+ animations: [],
55
+ logic: [],
56
+ parallels: [],
57
+ build: null,
58
+ evolve: null,
59
+ targets: [],
60
+ version: null,
61
+ logs
62
+ };
63
+ const lines = code.split(/\r?\n/);
64
+ let i = 0;
65
+ while (i < lines.length) {
66
+ const raw = lines[i];
67
+ const line = raw.trim();
68
+ if (!line) {
69
+ i++;
70
+ continue;
71
+ }
72
+ if (/^Σ\s+SYSTEM/i.test(line)) {
73
+ const m = line.match(/^Σ\s+SYSTEM\s+"([^"]+)"/i);
74
+ ast.system = m ? m[1] : line.replace(/^Σ\s+SYSTEM\s*/i, "");
75
+ log({ level: "info", event: "parse.system", i, line: ast.system });
76
+ i++;
77
+ continue;
78
+ }
79
+ if (/^Σ\s+VERSION/i.test(line)) {
80
+ const m = line.match(/^Σ\s+VERSION\s+([\d\.]+)/i);
81
+ ast.version = m ? m[1] : null;
82
+ i++;
83
+ continue;
84
+ }
85
+ if (/^Σ\s+TARGET/i.test(line)) {
86
+ const m = line.match(/^Σ\s+TARGET\s+(.+)/i);
87
+ if (m) {
88
+ const parts = m[1].split(/[+,\s]+/).map((s) => s.trim()).filter(Boolean);
89
+ ast.targets = [...ast.targets || [], ...parts];
90
+ }
91
+ i++;
92
+ continue;
93
+ }
94
+ if (/^Σ\s+MODE/i.test(line)) {
95
+ const m = line.match(/^Σ\s+MODE\s+([\w-]+)/i);
96
+ ast.mode = m ? m[1] : null;
97
+ i++;
98
+ continue;
99
+ }
100
+ if (/^Σ\s+UI/i.test(line)) {
101
+ const m = line.match(/^Σ\s+UI\s+([\w-]+)/i);
102
+ ast.ui = m ? m[1] : null;
103
+ i++;
104
+ continue;
105
+ }
106
+ if (/^Δ\s+([\w_]+)\s*\(([^)]*)\)/.test(line)) {
107
+ const m = line.match(/^Δ\s+([\w_]+)\s*\(([^)]*)\)/);
108
+ const name = m ? m[1] : "anonymous";
109
+ const argsRaw = m ? m[2] : "";
110
+ const args = argsRaw ? argsRaw.split(",").map((s) => s.trim()).filter(Boolean) : [];
111
+ const steps = [];
112
+ log({ level: "info", event: "parse.function.start", i, detail: { name, args } });
113
+ i++;
114
+ while (i < lines.length) {
115
+ const l = lines[i];
116
+ if (!l.trim()) {
117
+ i++;
118
+ continue;
119
+ }
120
+ if (/^→/.test(l.trim()) || /^\s+→/.test(l) || /^\s+/.test(l)) {
121
+ const step = l.trim().replace(/^→\s?/, "");
122
+ steps.push({ raw: step });
123
+ log({ level: "debug", event: "parse.function.step", i, line: step });
124
+ i++;
125
+ } else {
126
+ break;
127
+ }
128
+ }
129
+ const fn = { type: "function", name, args, steps };
130
+ log({ level: "info", event: "parse.function.end", detail: fn });
131
+ ast.functions.push(fn);
132
+ ast.nodes.push(fn);
133
+ continue;
134
+ }
135
+ if (/^Ψ\s+IA\s+([\w-]+)\s*\{?/.test(line)) {
136
+ const m = line.match(/^Ψ\s+IA\s+([\w-]+)\s*\{?/);
137
+ const name = m ? m[1] : "ia";
138
+ const body = [];
139
+ if (/\{$/.test(line)) {
140
+ i++;
141
+ while (i < lines.length && !/\}/.test(lines[i])) {
142
+ body.push(lines[i].trim());
143
+ i++;
144
+ }
145
+ if (i < lines.length && /\}/.test(lines[i]))
146
+ i++;
147
+ } else {
148
+ i++;
149
+ while (i < lines.length) {
150
+ const l = lines[i];
151
+ if (!l.trim()) {
152
+ i++;
153
+ break;
154
+ }
155
+ if (/^Σ|^Δ|^Ψ/.test(l.trim()))
156
+ break;
157
+ body.push(l.trim());
158
+ i++;
159
+ }
160
+ }
161
+ const ia = { type: "ia", name, body };
162
+ log({ level: "info", event: "parse.ia", i, detail: ia });
163
+ ast.ias.push(ia);
164
+ ast.nodes.push(ia);
165
+ continue;
166
+ }
167
+ if (/^Σ\s+EVOLVE/i.test(line)) {
168
+ const steps = [];
169
+ i++;
170
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
171
+ steps.push(lines[i].trim());
172
+ i++;
173
+ }
174
+ const ev = { type: "evolve", steps };
175
+ ast.evolve = ev;
176
+ ast.nodes.push(ev);
177
+ continue;
178
+ }
179
+ if (/^Σ\s+BUILD/i.test(line)) {
180
+ const targets = [];
181
+ i++;
182
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
183
+ const m = lines[i].trim().match(/target:\s*([\w-]+)/);
184
+ if (m)
185
+ targets.push(m[1]);
186
+ i++;
187
+ }
188
+ const b = { type: "build", targets };
189
+ log({ level: "info", event: "parse.build", i, detail: b });
190
+ ast.build = b;
191
+ ast.nodes.push(b);
192
+ continue;
193
+ }
194
+ if (/^Σ\s+MODULE/i.test(line)) {
195
+ const m = line.match(/^Σ\s+MODULE\s+"([^"]+)"/i);
196
+ const name = m ? m[1] : line.replace(/^Σ\s+MODULE\s*/i, "");
197
+ const module = { type: "module", name };
198
+ ast.modules.push(module);
199
+ ast.nodes.push(module);
200
+ i++;
201
+ continue;
202
+ }
203
+ if (/^Ω\s+([\w_]+)\s*\{?/.test(line)) {
204
+ const m = line.match(/^Ω\s+([\w_]+)\s*\{?/);
205
+ const name = m ? m[1] : "object";
206
+ const props = {};
207
+ if (/\{$/.test(line)) {
208
+ i++;
209
+ while (i < lines.length && !/\}/.test(lines[i])) {
210
+ const p = lines[i].trim();
211
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
212
+ if (ma)
213
+ props[ma[1]] = ma[2];
214
+ else if (p)
215
+ props[p] = null;
216
+ i++;
217
+ }
218
+ if (i < lines.length && /\}/.test(lines[i]))
219
+ i++;
220
+ }
221
+ const obj = { type: "object", name, props };
222
+ ast.objects.push(obj);
223
+ ast.nodes.push(obj);
224
+ continue;
225
+ }
226
+ if (/^Φ\s+([\w_]+)\s*\{?/.test(line)) {
227
+ const m = line.match(/^Φ\s+([\w_]+)\s*\{?/);
228
+ const name = m ? m[1] : "form";
229
+ const props = {};
230
+ if (/\{$/.test(line)) {
231
+ i++;
232
+ while (i < lines.length && !/\}/.test(lines[i])) {
233
+ const p = lines[i].trim();
234
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
235
+ if (ma)
236
+ props[ma[1]] = ma[2];
237
+ else if (p)
238
+ props[p] = true;
239
+ i++;
240
+ }
241
+ if (i < lines.length && /\}/.test(lines[i]))
242
+ i++;
243
+ }
244
+ const form = { type: "form", name, props };
245
+ ast.forms.push(form);
246
+ ast.nodes.push(form);
247
+ continue;
248
+ }
249
+ if (/^Θ\s+animation\s+"([^"]+)"/.test(line)) {
250
+ const m = line.match(/^Θ\s+animation\s+"([^"]+)"/);
251
+ const name = m ? m[1] : "anim";
252
+ const props = {};
253
+ i++;
254
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Λ|⊗/.test(lines[i].trim())) {
255
+ const p = lines[i].trim();
256
+ const ma = p.match(/^([\w_]+)\s*:\s*(.+)/);
257
+ if (ma)
258
+ props[ma[1]] = ma[2].trim();
259
+ i++;
260
+ }
261
+ const anim = { type: "animation", name, props };
262
+ ast.animations.push(anim);
263
+ ast.nodes.push(anim);
264
+ continue;
265
+ }
266
+ if (/^Λ\s+if\s+/.test(line)) {
267
+ const ruleLines = [];
268
+ let trueFlow = [];
269
+ let falseFlow = [];
270
+ let rule = line.replace(/^Λ\s+/, "");
271
+ i++;
272
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
273
+ const l = lines[i].trim();
274
+ if (/^else/i.test(l)) {
275
+ i++;
276
+ break;
277
+ }
278
+ if (/^→/.test(l))
279
+ trueFlow.push(l.replace(/^→\s?/, "").trim());
280
+ ruleLines.push(l);
281
+ i++;
282
+ }
283
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
284
+ const l = lines[i].trim();
285
+ if (/^→/.test(l))
286
+ falseFlow.push(l.replace(/^→\s?/, "").trim());
287
+ i++;
288
+ }
289
+ const logic = { type: "logic", rule, trueFlow, falseFlow };
290
+ ast.logic.push(logic);
291
+ ast.nodes.push(logic);
292
+ continue;
293
+ }
294
+ if (/^⊗\s*\{?/.test(line)) {
295
+ const items = [];
296
+ if (/\{$/.test(line)) {
297
+ i++;
298
+ while (i < lines.length && !/\}/.test(lines[i])) {
299
+ const l = lines[i].trim();
300
+ if (l)
301
+ items.push(l);
302
+ i++;
303
+ }
304
+ if (i < lines.length && /\}/.test(lines[i]))
305
+ i++;
306
+ }
307
+ const par = { type: "parallel", items };
308
+ ast.parallels.push(par);
309
+ ast.nodes.push(par);
310
+ continue;
311
+ }
312
+ i++;
313
+ }
314
+ return ast;
315
+ }
316
+
317
+ export {
318
+ writeWithRetry,
319
+ parse
320
+ };
@@ -0,0 +1,324 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // src/parser.ts
10
+ function parse(code, options) {
11
+ const logs = [];
12
+ const fs = __require("fs");
13
+ const log = (entry) => {
14
+ const e = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), ...entry };
15
+ logs.push(e);
16
+ if (options?.onLog)
17
+ options.onLog(e);
18
+ if (options?.logFile) {
19
+ try {
20
+ fs.appendFileSync(options.logFile, JSON.stringify(e) + "\n", { encoding: "utf8" });
21
+ } catch (err) {
22
+ const errEntry = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "error", event: "logfile.write.error", detail: String(err) };
23
+ logs.push(errEntry);
24
+ if (options?.onLog)
25
+ options.onLog(errEntry);
26
+ }
27
+ }
28
+ };
29
+ log({ level: "info", event: "parse.start", detail: { length: code.length } });
30
+ const ast = {
31
+ raw: code,
32
+ functions: [],
33
+ ias: [],
34
+ nodes: [],
35
+ modules: [],
36
+ objects: [],
37
+ forms: [],
38
+ animations: [],
39
+ logic: [],
40
+ parallels: [],
41
+ build: null,
42
+ evolve: null,
43
+ targets: [],
44
+ version: null,
45
+ logs
46
+ };
47
+ const lines = code.split(/\r?\n/);
48
+ let i = 0;
49
+ while (i < lines.length) {
50
+ const raw = lines[i];
51
+ const line = raw.trim();
52
+ if (!line) {
53
+ i++;
54
+ continue;
55
+ }
56
+ if (/^Σ\s+SYSTEM/i.test(line)) {
57
+ const m = line.match(/^Σ\s+SYSTEM\s+"([^"]+)"/i);
58
+ ast.system = m ? m[1] : line.replace(/^Σ\s+SYSTEM\s*/i, "");
59
+ log({ level: "info", event: "parse.system", i, line: ast.system });
60
+ i++;
61
+ continue;
62
+ }
63
+ if (/^Σ\s+VERSION/i.test(line)) {
64
+ const m = line.match(/^Σ\s+VERSION\s+([\d\.]+)/i);
65
+ ast.version = m ? m[1] : null;
66
+ i++;
67
+ continue;
68
+ }
69
+ if (/^Σ\s+TARGET/i.test(line)) {
70
+ const m = line.match(/^Σ\s+TARGET\s+(.+)/i);
71
+ if (m) {
72
+ const parts = m[1].split(/[+,\s]+/).map((s) => s.trim()).filter(Boolean);
73
+ ast.targets = [...ast.targets || [], ...parts];
74
+ }
75
+ i++;
76
+ continue;
77
+ }
78
+ if (/^Σ\s+MODE/i.test(line)) {
79
+ const m = line.match(/^Σ\s+MODE\s+([\w-]+)/i);
80
+ ast.mode = m ? m[1] : null;
81
+ i++;
82
+ continue;
83
+ }
84
+ if (/^Σ\s+UI/i.test(line)) {
85
+ const m = line.match(/^Σ\s+UI\s+([\w-]+)/i);
86
+ ast.ui = m ? m[1] : null;
87
+ i++;
88
+ continue;
89
+ }
90
+ if (/^Δ\s+([\w_]+)\s*\(([^)]*)\)/.test(line)) {
91
+ const m = line.match(/^Δ\s+([\w_]+)\s*\(([^)]*)\)/);
92
+ const name = m ? m[1] : "anonymous";
93
+ const argsRaw = m ? m[2] : "";
94
+ const args = argsRaw ? argsRaw.split(",").map((s) => s.trim()).filter(Boolean) : [];
95
+ const steps = [];
96
+ log({ level: "info", event: "parse.function.start", i, detail: { name, args } });
97
+ i++;
98
+ while (i < lines.length) {
99
+ const l = lines[i];
100
+ if (!l.trim()) {
101
+ i++;
102
+ continue;
103
+ }
104
+ if (/^→/.test(l.trim()) || /^\s+→/.test(l) || /^\s+/.test(l)) {
105
+ const step = l.trim().replace(/^→\s?/, "");
106
+ steps.push({ raw: step });
107
+ log({ level: "debug", event: "parse.function.step", i, line: step });
108
+ i++;
109
+ } else {
110
+ break;
111
+ }
112
+ }
113
+ const fn = { type: "function", name, args, steps };
114
+ log({ level: "info", event: "parse.function.end", detail: fn });
115
+ ast.functions.push(fn);
116
+ ast.nodes.push(fn);
117
+ continue;
118
+ }
119
+ if (/^Ψ\s+IA\s+([\w-]+)\s*\{?/.test(line)) {
120
+ const m = line.match(/^Ψ\s+IA\s+([\w-]+)\s*\{?/);
121
+ const name = m ? m[1] : "ia";
122
+ const body = [];
123
+ if (/\{$/.test(line)) {
124
+ i++;
125
+ while (i < lines.length && !/\}/.test(lines[i])) {
126
+ body.push(lines[i].trim());
127
+ i++;
128
+ }
129
+ if (i < lines.length && /\}/.test(lines[i]))
130
+ i++;
131
+ } else {
132
+ i++;
133
+ while (i < lines.length) {
134
+ const l = lines[i];
135
+ if (!l.trim()) {
136
+ i++;
137
+ break;
138
+ }
139
+ if (/^Σ|^Δ|^Ψ/.test(l.trim()))
140
+ break;
141
+ body.push(l.trim());
142
+ i++;
143
+ }
144
+ }
145
+ const ia = { type: "ia", name, body };
146
+ log({ level: "info", event: "parse.ia", i, detail: ia });
147
+ ast.ias.push(ia);
148
+ ast.nodes.push(ia);
149
+ continue;
150
+ }
151
+ if (/^Σ\s+EVOLVE/i.test(line)) {
152
+ const steps = [];
153
+ i++;
154
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
155
+ steps.push(lines[i].trim());
156
+ i++;
157
+ }
158
+ const ev = { type: "evolve", steps };
159
+ ast.evolve = ev;
160
+ ast.nodes.push(ev);
161
+ continue;
162
+ }
163
+ if (/^Σ\s+BUILD/i.test(line)) {
164
+ const targets = [];
165
+ i++;
166
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
167
+ const m = lines[i].trim().match(/target:\s*([\w-]+)/);
168
+ if (m)
169
+ targets.push(m[1]);
170
+ i++;
171
+ }
172
+ const b = { type: "build", targets };
173
+ log({ level: "info", event: "parse.build", i, detail: b });
174
+ ast.build = b;
175
+ ast.nodes.push(b);
176
+ continue;
177
+ }
178
+ if (/^Σ\s+MODULE/i.test(line)) {
179
+ const m = line.match(/^Σ\s+MODULE\s+"([^"]+)"/i);
180
+ const name = m ? m[1] : line.replace(/^Σ\s+MODULE\s*/i, "");
181
+ const module = { type: "module", name };
182
+ ast.modules.push(module);
183
+ ast.nodes.push(module);
184
+ i++;
185
+ continue;
186
+ }
187
+ if (/^Ω\s+([\w_]+)\s*\{?/.test(line)) {
188
+ const m = line.match(/^Ω\s+([\w_]+)\s*\{?/);
189
+ const name = m ? m[1] : "object";
190
+ const props = {};
191
+ if (/\{$/.test(line)) {
192
+ i++;
193
+ while (i < lines.length && !/\}/.test(lines[i])) {
194
+ const p = lines[i].trim();
195
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
196
+ if (ma)
197
+ props[ma[1]] = ma[2];
198
+ else if (p)
199
+ props[p] = null;
200
+ i++;
201
+ }
202
+ if (i < lines.length && /\}/.test(lines[i]))
203
+ i++;
204
+ }
205
+ const obj = { type: "object", name, props };
206
+ ast.objects.push(obj);
207
+ ast.nodes.push(obj);
208
+ continue;
209
+ }
210
+ if (/^Φ\s+([\w_]+)\s*\{?/.test(line)) {
211
+ const m = line.match(/^Φ\s+([\w_]+)\s*\{?/);
212
+ const name = m ? m[1] : "form";
213
+ const props = {};
214
+ if (/\{$/.test(line)) {
215
+ i++;
216
+ while (i < lines.length && !/\}/.test(lines[i])) {
217
+ const p = lines[i].trim();
218
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
219
+ if (ma)
220
+ props[ma[1]] = ma[2];
221
+ else if (p)
222
+ props[p] = true;
223
+ i++;
224
+ }
225
+ if (i < lines.length && /\}/.test(lines[i]))
226
+ i++;
227
+ }
228
+ const form = { type: "form", name, props };
229
+ ast.forms.push(form);
230
+ ast.nodes.push(form);
231
+ continue;
232
+ }
233
+ if (/^Θ\s+animation\s+"([^"]+)"/.test(line)) {
234
+ const m = line.match(/^Θ\s+animation\s+"([^"]+)"/);
235
+ const name = m ? m[1] : "anim";
236
+ const props = {};
237
+ i++;
238
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Λ|⊗/.test(lines[i].trim())) {
239
+ const p = lines[i].trim();
240
+ const ma = p.match(/^([\w_]+)\s*:\s*(.+)/);
241
+ if (ma)
242
+ props[ma[1]] = ma[2].trim();
243
+ i++;
244
+ }
245
+ const anim = { type: "animation", name, props };
246
+ ast.animations.push(anim);
247
+ ast.nodes.push(anim);
248
+ continue;
249
+ }
250
+ if (/^Λ\s+if\s+/.test(line)) {
251
+ const ruleLines = [];
252
+ let trueFlow = [];
253
+ let falseFlow = [];
254
+ let rule = line.replace(/^Λ\s+/, "");
255
+ i++;
256
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
257
+ const l = lines[i].trim();
258
+ if (/^else/i.test(l)) {
259
+ i++;
260
+ break;
261
+ }
262
+ if (/^→/.test(l))
263
+ trueFlow.push(l.replace(/^→\s?/, "").trim());
264
+ ruleLines.push(l);
265
+ i++;
266
+ }
267
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
268
+ const l = lines[i].trim();
269
+ if (/^→/.test(l))
270
+ falseFlow.push(l.replace(/^→\s?/, "").trim());
271
+ i++;
272
+ }
273
+ const logic = { type: "logic", rule, trueFlow, falseFlow };
274
+ ast.logic.push(logic);
275
+ ast.nodes.push(logic);
276
+ continue;
277
+ }
278
+ if (/^⊗\s*\{?/.test(line)) {
279
+ const items = [];
280
+ if (/\{$/.test(line)) {
281
+ i++;
282
+ while (i < lines.length && !/\}/.test(lines[i])) {
283
+ const l = lines[i].trim();
284
+ if (l)
285
+ items.push(l);
286
+ i++;
287
+ }
288
+ if (i < lines.length && /\}/.test(lines[i]))
289
+ i++;
290
+ }
291
+ const par = { type: "parallel", items };
292
+ ast.parallels.push(par);
293
+ ast.nodes.push(par);
294
+ continue;
295
+ }
296
+ i++;
297
+ }
298
+ return ast;
299
+ }
300
+
301
+ // src/runENY.ts
302
+ function runENY(code, options) {
303
+ const hasSystem = /Σ\s+SYSTEM/i.test(code);
304
+ if (!hasSystem) {
305
+ if (options?.onLog) {
306
+ options.onLog({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "runENY.no-system", detail: { length: code.length } });
307
+ }
308
+ if (options?.logFile) {
309
+ const fs = __require("fs");
310
+ try {
311
+ fs.appendFileSync(options.logFile, JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "runENY.no-system", detail: { length: code.length } }) + "\n");
312
+ } catch (e) {
313
+ }
314
+ }
315
+ return { raw: code, isEny: false, logs: [] };
316
+ }
317
+ const ast = parse(code, options);
318
+ ast.isEny = true;
319
+ return ast;
320
+ }
321
+
322
+ export {
323
+ runENY
324
+ };
@@ -0,0 +1,30 @@
1
+ import {
2
+ parse
3
+ } from "./chunk-76PHNPTY.js";
4
+
5
+ // src/runENY.ts
6
+ function runENY(code, options) {
7
+ const hasSystem = /Σ\s+SYSTEM/i.test(code);
8
+ if (!hasSystem) {
9
+ if (options?.onLog) {
10
+ options.onLog({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "runENY.no-system", detail: { length: code.length } });
11
+ }
12
+ if (options?.logFile) {
13
+ const attempts = options?.logRetryAttempts ?? 3;
14
+ const delay = options?.logRetryDelayMs ?? 1e3;
15
+ import("./parser-V44AIVNI.js").then((mod) => {
16
+ mod.writeWithRetry({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "runENY.no-system", detail: { length: code.length } }, options.logFile, attempts, delay, options?.onLog).catch(() => {
17
+ });
18
+ }).catch(() => {
19
+ });
20
+ }
21
+ return { raw: code, isEny: false, logs: [] };
22
+ }
23
+ const ast = parse(code, options);
24
+ ast.isEny = true;
25
+ return ast;
26
+ }
27
+
28
+ export {
29
+ runENY
30
+ };