@plasius/learning-runtime 0.0.0-stage → 0.1.2
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.
- package/LICENSE +203 -0
- package/README.md +169 -2
- package/dist/chunk-2YWUDCGJ.js +189 -0
- package/dist/chunk-2YWUDCGJ.js.map +1 -0
- package/dist/chunk-XDTWUCFP.js +213 -0
- package/dist/chunk-XDTWUCFP.js.map +1 -0
- package/dist/cpp.cjs +563 -0
- package/dist/cpp.cjs.map +1 -0
- package/dist/cpp.d.cts +33 -0
- package/dist/cpp.d.ts +33 -0
- package/dist/cpp.js +535 -0
- package/dist/cpp.js.map +1 -0
- package/dist/index.cjs +244 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/javascript.cjs +226 -0
- package/dist/javascript.cjs.map +1 -0
- package/dist/javascript.d.cts +45 -0
- package/dist/javascript.d.ts +45 -0
- package/dist/javascript.js +13 -0
- package/dist/javascript.js.map +1 -0
- package/dist/javascript.worker.cjs +252 -0
- package/dist/javascript.worker.cjs.map +1 -0
- package/dist/javascript.worker.d.cts +2 -0
- package/dist/javascript.worker.d.ts +2 -0
- package/dist/javascript.worker.js +50 -0
- package/dist/javascript.worker.js.map +1 -0
- package/dist/maze.cjs +242 -0
- package/dist/maze.cjs.map +1 -0
- package/dist/maze.d.cts +85 -0
- package/dist/maze.d.ts +85 -0
- package/dist/maze.js +17 -0
- package/dist/maze.js.map +1 -0
- package/dist/server.cjs +232 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +25 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +149 -0
- package/dist/server.js.map +1 -0
- package/dist/web.cjs +600 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.cts +80 -0
- package/dist/web.d.ts +80 -0
- package/dist/web.js +513 -0
- package/dist/web.js.map +1 -0
- package/package.json +115 -4
package/dist/cpp.cjs
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/cpp.ts
|
|
21
|
+
var cpp_exports = {};
|
|
22
|
+
__export(cpp_exports, {
|
|
23
|
+
CppProjectError: () => CppProjectError,
|
|
24
|
+
createCppProjectSession: () => createCppProjectSession
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cpp_exports);
|
|
27
|
+
|
|
28
|
+
// src/cpp-parser.ts
|
|
29
|
+
var CppProjectError = class extends Error {
|
|
30
|
+
constructor(code) {
|
|
31
|
+
super(`Robot program ${code.toLowerCase().replaceAll("_", " ")}.`);
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.name = "CppProjectError";
|
|
34
|
+
}
|
|
35
|
+
code;
|
|
36
|
+
};
|
|
37
|
+
var TYPES = /* @__PURE__ */ new Set(["int", "double", "bool", "string", "void"]);
|
|
38
|
+
var RESERVED = /* @__PURE__ */ new Set([...TYPES, "const", "if", "else", "while", "for", "return", "break", "continue", "true", "false"]);
|
|
39
|
+
var PRECEDENCE = { "||": 1, "&&": 2, "==": 3, "!=": 3, "<": 4, "<=": 4, ">": 4, ">=": 4, "+": 5, "-": 5, "*": 6, "/": 6, "%": 6 };
|
|
40
|
+
function invalid() {
|
|
41
|
+
throw new CppProjectError("INVALID_SOURCE");
|
|
42
|
+
}
|
|
43
|
+
function tokenize(source) {
|
|
44
|
+
if (typeof source !== "string" || source.length > 32768 || source.includes("\0")) invalid();
|
|
45
|
+
const tokens = [];
|
|
46
|
+
let offset = 0;
|
|
47
|
+
while (offset < source.length) {
|
|
48
|
+
const rest = source.slice(offset);
|
|
49
|
+
if (/^\s/u.test(rest)) {
|
|
50
|
+
offset++;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (rest.startsWith("//")) {
|
|
54
|
+
const end = source.indexOf("\n", offset);
|
|
55
|
+
offset = end < 0 ? source.length : end + 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (rest.startsWith("/*")) {
|
|
59
|
+
const end = source.indexOf("*/", offset + 2);
|
|
60
|
+
if (end < 0) invalid();
|
|
61
|
+
offset = end + 2;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const number2 = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/u.exec(rest);
|
|
65
|
+
const identifier = /^[A-Za-z_][A-Za-z0-9_]*/u.exec(rest);
|
|
66
|
+
if (number2) {
|
|
67
|
+
tokens.push({ text: number2[0], kind: "literal", value: Number(number2[0]), numberType: /[.eE]/u.test(number2[0]) ? "double" : "int" });
|
|
68
|
+
offset += number2[0].length;
|
|
69
|
+
} else if (identifier) {
|
|
70
|
+
if (identifier[0].length > 64) invalid();
|
|
71
|
+
tokens.push({ text: identifier[0], kind: "identifier" });
|
|
72
|
+
offset += identifier[0].length;
|
|
73
|
+
} else if (rest[0] === '"') {
|
|
74
|
+
const quoted = /^"(?:[^"\\\r\n]|\\.)*"/u.exec(rest);
|
|
75
|
+
if (!quoted) invalid();
|
|
76
|
+
let value;
|
|
77
|
+
try {
|
|
78
|
+
value = JSON.parse(quoted[0]);
|
|
79
|
+
} catch {
|
|
80
|
+
invalid();
|
|
81
|
+
}
|
|
82
|
+
if (typeof value !== "string" || value.length > 256 || value.includes("\0")) invalid();
|
|
83
|
+
tokens.push({ text: quoted[0], kind: "literal", value });
|
|
84
|
+
offset += quoted[0].length;
|
|
85
|
+
} else {
|
|
86
|
+
const operator = /^(?:==|!=|<=|>=|&&|\|\||\+\+|--|\+=|-=|\*=|\/=|%=|[{}();,=+*/%!<>-])/u.exec(rest);
|
|
87
|
+
if (!operator) invalid();
|
|
88
|
+
tokens.push({ text: operator[0], kind: "symbol" });
|
|
89
|
+
offset += operator[0].length;
|
|
90
|
+
}
|
|
91
|
+
if (tokens.length > 4096) invalid();
|
|
92
|
+
}
|
|
93
|
+
tokens.push({ text: "<end>", kind: "symbol" });
|
|
94
|
+
return tokens;
|
|
95
|
+
}
|
|
96
|
+
var Parser = class {
|
|
97
|
+
constructor(tokens) {
|
|
98
|
+
this.tokens = tokens;
|
|
99
|
+
}
|
|
100
|
+
tokens;
|
|
101
|
+
#offset = 0;
|
|
102
|
+
#depth = 0;
|
|
103
|
+
current() {
|
|
104
|
+
return this.tokens[this.#offset];
|
|
105
|
+
}
|
|
106
|
+
is(text) {
|
|
107
|
+
return this.current().text === text;
|
|
108
|
+
}
|
|
109
|
+
take() {
|
|
110
|
+
if (this.is("<end>")) invalid();
|
|
111
|
+
return this.tokens[this.#offset++];
|
|
112
|
+
}
|
|
113
|
+
accept(text) {
|
|
114
|
+
if (!this.is(text)) return false;
|
|
115
|
+
this.take();
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
expect(text) {
|
|
119
|
+
if (!this.accept(text)) invalid();
|
|
120
|
+
}
|
|
121
|
+
name() {
|
|
122
|
+
const token = this.take();
|
|
123
|
+
if (token.kind !== "identifier" || RESERVED.has(token.text)) invalid();
|
|
124
|
+
return token.text;
|
|
125
|
+
}
|
|
126
|
+
type() {
|
|
127
|
+
const token = this.take();
|
|
128
|
+
if (!TYPES.has(token.text)) invalid();
|
|
129
|
+
return token.text;
|
|
130
|
+
}
|
|
131
|
+
nested(operation) {
|
|
132
|
+
if (++this.#depth > 64) invalid();
|
|
133
|
+
try {
|
|
134
|
+
return operation();
|
|
135
|
+
} finally {
|
|
136
|
+
this.#depth--;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
program() {
|
|
140
|
+
const globals = [];
|
|
141
|
+
const functions = /* @__PURE__ */ new Map();
|
|
142
|
+
const names = /* @__PURE__ */ new Set();
|
|
143
|
+
while (!this.is("<end>")) {
|
|
144
|
+
const constant = this.accept("const");
|
|
145
|
+
const type = this.type();
|
|
146
|
+
const name = this.name();
|
|
147
|
+
if (names.has(name) || names.size >= 64) invalid();
|
|
148
|
+
names.add(name);
|
|
149
|
+
if (this.accept("(")) {
|
|
150
|
+
if (constant || functions.size >= 32) invalid();
|
|
151
|
+
const parameters = [];
|
|
152
|
+
if (!this.is(")")) {
|
|
153
|
+
do {
|
|
154
|
+
const parameterType = this.type();
|
|
155
|
+
const parameterName = this.name();
|
|
156
|
+
if (parameterType === "void" || parameters.some((parameter) => parameter.name === parameterName) || parameters.length >= 8) invalid();
|
|
157
|
+
parameters.push({ type: parameterType, name: parameterName });
|
|
158
|
+
} while (this.accept(","));
|
|
159
|
+
}
|
|
160
|
+
this.expect(")");
|
|
161
|
+
if (!this.is("{")) invalid();
|
|
162
|
+
functions.set(name, { name, type, parameters, body: this.statement() });
|
|
163
|
+
} else {
|
|
164
|
+
if (type === "void") invalid();
|
|
165
|
+
const value = this.accept("=") ? this.expression() : void 0;
|
|
166
|
+
if (constant && !value) invalid();
|
|
167
|
+
this.expect(";");
|
|
168
|
+
globals.push({ kind: "declare", type, constant, name, value });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const loop = functions.get("loop");
|
|
172
|
+
const setup = functions.get("setup");
|
|
173
|
+
if (!loop || loop.type !== "void" || loop.parameters.length !== 0 || setup && (setup.type !== "void" || setup.parameters.length !== 0)) invalid();
|
|
174
|
+
return { globals, functions };
|
|
175
|
+
}
|
|
176
|
+
declaration() {
|
|
177
|
+
const constant = this.accept("const");
|
|
178
|
+
const type = this.type();
|
|
179
|
+
const name = this.name();
|
|
180
|
+
if (type === "void") invalid();
|
|
181
|
+
const value = this.accept("=") ? this.expression() : void 0;
|
|
182
|
+
if (constant && !value) invalid();
|
|
183
|
+
return { kind: "declare", type, constant, name, value };
|
|
184
|
+
}
|
|
185
|
+
simple() {
|
|
186
|
+
if (this.is("const") || TYPES.has(this.current().text)) return this.declaration();
|
|
187
|
+
const value = this.expression();
|
|
188
|
+
const operator = this.current().text;
|
|
189
|
+
if (["=", "+=", "-=", "*=", "/=", "%=", "++", "--"].includes(operator)) {
|
|
190
|
+
this.take();
|
|
191
|
+
if (value.kind !== "variable") invalid();
|
|
192
|
+
const right = operator === "++" || operator === "--" ? { kind: "literal", value: 1 } : this.expression();
|
|
193
|
+
return { kind: "assign", name: value.name, value: operator === "=" ? right : { kind: "binary", operator: operator[0], left: value, right } };
|
|
194
|
+
}
|
|
195
|
+
return { kind: "expression", value };
|
|
196
|
+
}
|
|
197
|
+
statement() {
|
|
198
|
+
return this.nested(() => {
|
|
199
|
+
if (this.accept("{")) {
|
|
200
|
+
const statements = [];
|
|
201
|
+
while (!this.accept("}")) statements.push(this.statement());
|
|
202
|
+
return { kind: "block", statements };
|
|
203
|
+
}
|
|
204
|
+
if (this.accept("if")) {
|
|
205
|
+
this.expect("(");
|
|
206
|
+
const condition = this.expression();
|
|
207
|
+
this.expect(")");
|
|
208
|
+
const then = this.statement();
|
|
209
|
+
const otherwise = this.accept("else") ? this.statement() : void 0;
|
|
210
|
+
return { kind: "if", condition, then, otherwise };
|
|
211
|
+
}
|
|
212
|
+
if (this.accept("while")) {
|
|
213
|
+
this.expect("(");
|
|
214
|
+
const condition = this.expression();
|
|
215
|
+
this.expect(")");
|
|
216
|
+
return { kind: "while", condition, body: this.statement() };
|
|
217
|
+
}
|
|
218
|
+
if (this.accept("for")) {
|
|
219
|
+
this.expect("(");
|
|
220
|
+
const initial = this.is(";") ? void 0 : this.simple();
|
|
221
|
+
this.expect(";");
|
|
222
|
+
const condition = this.is(";") ? void 0 : this.expression();
|
|
223
|
+
this.expect(";");
|
|
224
|
+
const increment = this.is(")") ? void 0 : this.simple();
|
|
225
|
+
this.expect(")");
|
|
226
|
+
return { kind: "for", initial, condition, increment, body: this.statement() };
|
|
227
|
+
}
|
|
228
|
+
if (this.accept("return")) {
|
|
229
|
+
const value = this.is(";") ? void 0 : this.expression();
|
|
230
|
+
this.expect(";");
|
|
231
|
+
return { kind: "return", value };
|
|
232
|
+
}
|
|
233
|
+
if (this.is("break") || this.is("continue")) {
|
|
234
|
+
const kind = this.take().text;
|
|
235
|
+
this.expect(";");
|
|
236
|
+
return { kind };
|
|
237
|
+
}
|
|
238
|
+
if (this.accept(";")) return { kind: "block", statements: [] };
|
|
239
|
+
const result = this.simple();
|
|
240
|
+
this.expect(";");
|
|
241
|
+
return result;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
expression(minimum = 0) {
|
|
245
|
+
return this.nested(() => {
|
|
246
|
+
let left;
|
|
247
|
+
const token = this.take();
|
|
248
|
+
if (["!", "-", "+"].includes(token.text)) left = { kind: "unary", operator: token.text, value: this.expression(7) };
|
|
249
|
+
else if (token.text === "(") {
|
|
250
|
+
left = this.expression();
|
|
251
|
+
this.expect(")");
|
|
252
|
+
} else if (token.kind === "literal") left = { kind: "literal", value: token.value, numberType: token.numberType };
|
|
253
|
+
else if (token.text === "true" || token.text === "false") left = { kind: "literal", value: token.text === "true" };
|
|
254
|
+
else if (token.kind === "identifier" && !RESERVED.has(token.text)) {
|
|
255
|
+
if (this.accept("(")) {
|
|
256
|
+
const args = [];
|
|
257
|
+
if (!this.is(")")) do {
|
|
258
|
+
if (args.length >= 8) invalid();
|
|
259
|
+
args.push(this.expression());
|
|
260
|
+
} while (this.accept(","));
|
|
261
|
+
this.expect(")");
|
|
262
|
+
left = { kind: "call", name: token.text, args };
|
|
263
|
+
} else left = { kind: "variable", name: token.text };
|
|
264
|
+
} else invalid();
|
|
265
|
+
while ((PRECEDENCE[this.current().text] ?? -1) >= minimum) {
|
|
266
|
+
const operator = this.take().text;
|
|
267
|
+
left = { kind: "binary", operator, left, right: this.expression(PRECEDENCE[operator] + 1) };
|
|
268
|
+
}
|
|
269
|
+
return left;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
function parseCppProject(source) {
|
|
274
|
+
return new Parser(tokenize(source)).program();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/cpp.ts
|
|
278
|
+
var BUILTINS = /* @__PURE__ */ new Set(["millis", "numberSensor", "boolSensor", "textSensor", "min", "max", "abs"]);
|
|
279
|
+
var NAME = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/u;
|
|
280
|
+
function fail(code = "EXECUTION_FAILED") {
|
|
281
|
+
throw new CppProjectError(code);
|
|
282
|
+
}
|
|
283
|
+
function record(value, maximum) {
|
|
284
|
+
if (typeof value !== "object" || value === null || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("INVALID_INPUT");
|
|
285
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
286
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
287
|
+
if (keys.length > maximum) fail("INVALID_INPUT");
|
|
288
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
289
|
+
for (const key of keys) {
|
|
290
|
+
if (typeof key !== "string" || !NAME.test(key)) fail("INVALID_INPUT");
|
|
291
|
+
const descriptor = descriptors[key];
|
|
292
|
+
if (!Object.hasOwn(descriptor, "value") || !descriptor.enumerable) fail("INVALID_INPUT");
|
|
293
|
+
result[key] = descriptor.value;
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
}
|
|
297
|
+
function primitive(value) {
|
|
298
|
+
if (typeof value === "boolean") return value;
|
|
299
|
+
if (typeof value === "number" && Number.isFinite(value) && Math.abs(value) <= 1e9) return value;
|
|
300
|
+
if (typeof value === "string" && value.length <= 256 && !value.includes("\0")) return value;
|
|
301
|
+
return fail("INVALID_INPUT");
|
|
302
|
+
}
|
|
303
|
+
function numeric(value) {
|
|
304
|
+
if (!value || value.type !== "int" && value.type !== "double" || typeof value.value !== "number") fail();
|
|
305
|
+
return value.value;
|
|
306
|
+
}
|
|
307
|
+
function boolean(value) {
|
|
308
|
+
if (!value || value.type !== "bool") fail();
|
|
309
|
+
return value.value;
|
|
310
|
+
}
|
|
311
|
+
function number(value, type = "double") {
|
|
312
|
+
if (!Number.isFinite(value) || Math.abs(value) > 1e9) fail();
|
|
313
|
+
return { type, value: type === "int" ? Math.trunc(value) : value };
|
|
314
|
+
}
|
|
315
|
+
function convert(type, value) {
|
|
316
|
+
if (type === "void") {
|
|
317
|
+
if (value !== void 0) fail();
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
if (!value) fail();
|
|
321
|
+
if (type === "int" || type === "double") return number(numeric(value), type);
|
|
322
|
+
if (value.type !== type) fail();
|
|
323
|
+
return value;
|
|
324
|
+
}
|
|
325
|
+
function lookup(scope, name) {
|
|
326
|
+
const binding = scope.bindings.get(name);
|
|
327
|
+
if (binding) return binding;
|
|
328
|
+
if (scope.parent) return lookup(scope.parent, name);
|
|
329
|
+
return fail();
|
|
330
|
+
}
|
|
331
|
+
function outputSignatures(value) {
|
|
332
|
+
const entries = record(value, 16);
|
|
333
|
+
const result = /* @__PURE__ */ new Map();
|
|
334
|
+
for (const [name, signature] of Object.entries(entries)) {
|
|
335
|
+
if (BUILTINS.has(name) || name === "loop" || name === "setup" || !Array.isArray(signature) || Object.getPrototypeOf(signature) !== Array.prototype || signature.length > 8) fail("INVALID_INPUT");
|
|
336
|
+
const descriptors = Object.getOwnPropertyDescriptors(signature);
|
|
337
|
+
if (Reflect.ownKeys(descriptors).length !== signature.length + 1) fail("INVALID_INPUT");
|
|
338
|
+
const types = [];
|
|
339
|
+
for (let index = 0; index < signature.length; index++) {
|
|
340
|
+
const descriptor = descriptors[String(index)];
|
|
341
|
+
if (!descriptor || !Object.hasOwn(descriptor, "value") || !["number", "boolean", "string"].includes(descriptor.value)) fail("INVALID_INPUT");
|
|
342
|
+
types.push(descriptor.value);
|
|
343
|
+
}
|
|
344
|
+
result.set(name, types);
|
|
345
|
+
}
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
function createCppProjectSession(source, options) {
|
|
349
|
+
const program = parseCppProject(source);
|
|
350
|
+
const configuration = record(options, 2);
|
|
351
|
+
if (!Object.hasOwn(configuration, "outputs") || Object.keys(configuration).some((key) => key !== "outputs" && key !== "signal") || configuration.signal !== void 0 && !(configuration.signal instanceof AbortSignal)) fail("INVALID_INPUT");
|
|
352
|
+
const signal = configuration.signal;
|
|
353
|
+
const outputs = outputSignatures(configuration.outputs);
|
|
354
|
+
for (const name of program.functions.keys()) if (BUILTINS.has(name) || outputs.has(name)) fail("INVALID_SOURCE");
|
|
355
|
+
for (const node of program.globals) if (node.kind === "declare" && (BUILTINS.has(node.name) || outputs.has(node.name))) fail("INVALID_SOURCE");
|
|
356
|
+
const globals = { bindings: /* @__PURE__ */ new Map() };
|
|
357
|
+
let closed = false;
|
|
358
|
+
let initialized = false;
|
|
359
|
+
let lastTime = -1;
|
|
360
|
+
let timeMs = 0;
|
|
361
|
+
let sensors = /* @__PURE__ */ Object.create(null);
|
|
362
|
+
let commands = [];
|
|
363
|
+
let remaining = 2e3;
|
|
364
|
+
let depth = 0;
|
|
365
|
+
function step() {
|
|
366
|
+
if (closed || signal?.aborted) fail("CLOSED");
|
|
367
|
+
if (--remaining < 0) fail("BUDGET_EXCEEDED");
|
|
368
|
+
}
|
|
369
|
+
function declare(scope, name, type, constant, value) {
|
|
370
|
+
if (type === "void" || scope.bindings.has(name) || scope.bindings.size >= 64) fail();
|
|
371
|
+
scope.bindings.set(name, { type, constant, value: convert(type, value) });
|
|
372
|
+
}
|
|
373
|
+
function expression(node, scope) {
|
|
374
|
+
step();
|
|
375
|
+
if (node.kind === "literal") {
|
|
376
|
+
if (typeof node.value === "number") return number(node.value, node.numberType ?? "int");
|
|
377
|
+
return { type: typeof node.value === "boolean" ? "bool" : "string", value: node.value };
|
|
378
|
+
}
|
|
379
|
+
if (node.kind === "variable") return lookup(scope, node.name).value;
|
|
380
|
+
if (node.kind === "call") return call(node.name, node.args.map((argument) => expression(argument, scope)));
|
|
381
|
+
if (node.kind === "unary") {
|
|
382
|
+
const value = expression(node.value, scope);
|
|
383
|
+
if (node.operator === "!") return { type: "bool", value: !boolean(value) };
|
|
384
|
+
return number(numeric(value) * (node.operator === "-" ? -1 : 1), value.type);
|
|
385
|
+
}
|
|
386
|
+
const left = expression(node.left, scope);
|
|
387
|
+
if (node.operator === "&&") return { type: "bool", value: boolean(left) && boolean(expression(node.right, scope)) };
|
|
388
|
+
if (node.operator === "||") return { type: "bool", value: boolean(left) || boolean(expression(node.right, scope)) };
|
|
389
|
+
const right = expression(node.right, scope);
|
|
390
|
+
if (!left || !right) fail();
|
|
391
|
+
if (node.operator === "==" || node.operator === "!=") {
|
|
392
|
+
if (typeof left.value !== typeof right.value) fail();
|
|
393
|
+
const equal = left.value === right.value;
|
|
394
|
+
return { type: "bool", value: node.operator === "==" ? equal : !equal };
|
|
395
|
+
}
|
|
396
|
+
const a = numeric(left);
|
|
397
|
+
const b = numeric(right);
|
|
398
|
+
const type = left.type === "int" && right.type === "int" ? "int" : "double";
|
|
399
|
+
switch (node.operator) {
|
|
400
|
+
case "<":
|
|
401
|
+
return { type: "bool", value: a < b };
|
|
402
|
+
case "<=":
|
|
403
|
+
return { type: "bool", value: a <= b };
|
|
404
|
+
case ">":
|
|
405
|
+
return { type: "bool", value: a > b };
|
|
406
|
+
case ">=":
|
|
407
|
+
return { type: "bool", value: a >= b };
|
|
408
|
+
case "+":
|
|
409
|
+
return number(a + b, type);
|
|
410
|
+
case "-":
|
|
411
|
+
return number(a - b, type);
|
|
412
|
+
case "*":
|
|
413
|
+
return number(a * b, type);
|
|
414
|
+
case "/":
|
|
415
|
+
return number(a / b, type);
|
|
416
|
+
case "%":
|
|
417
|
+
if (type !== "int") fail();
|
|
418
|
+
return number(a % b, "int");
|
|
419
|
+
default:
|
|
420
|
+
return fail();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function call(name, args) {
|
|
424
|
+
step();
|
|
425
|
+
if (args.some((argument) => !argument)) fail();
|
|
426
|
+
if (name === "millis") {
|
|
427
|
+
if (args.length !== 0) fail();
|
|
428
|
+
return number(timeMs, "int");
|
|
429
|
+
}
|
|
430
|
+
if (name === "numberSensor" || name === "boolSensor" || name === "textSensor") {
|
|
431
|
+
if (args.length !== 1 || args[0].type !== "string") fail();
|
|
432
|
+
const value = sensors[args[0].value];
|
|
433
|
+
const type = name === "numberSensor" ? "number" : name === "boolSensor" ? "boolean" : "string";
|
|
434
|
+
if (typeof value !== type) fail();
|
|
435
|
+
return { type: type === "number" ? "double" : type === "boolean" ? "bool" : "string", value };
|
|
436
|
+
}
|
|
437
|
+
if (name === "min" || name === "max" || name === "abs") {
|
|
438
|
+
if (args.length !== (name === "abs" ? 1 : 2)) fail();
|
|
439
|
+
const values = args.map(numeric);
|
|
440
|
+
return number(name === "abs" ? Math.abs(values[0]) : name === "min" ? Math.min(...values) : Math.max(...values), args.every((arg) => arg.type === "int") ? "int" : "double");
|
|
441
|
+
}
|
|
442
|
+
const signature = outputs.get(name);
|
|
443
|
+
if (signature) {
|
|
444
|
+
if (signature.length !== args.length || signature.some((type, index) => typeof args[index].value !== type)) fail();
|
|
445
|
+
if (commands.length >= 64) fail("BUDGET_EXCEEDED");
|
|
446
|
+
commands.push({ name, args: args.map((arg) => arg.value) });
|
|
447
|
+
return void 0;
|
|
448
|
+
}
|
|
449
|
+
const fn = program.functions.get(name);
|
|
450
|
+
if (!fn || fn.parameters.length !== args.length) fail();
|
|
451
|
+
if (++depth > 16) fail("BUDGET_EXCEEDED");
|
|
452
|
+
try {
|
|
453
|
+
const scope = { bindings: /* @__PURE__ */ new Map(), parent: globals };
|
|
454
|
+
fn.parameters.forEach((parameter, index) => declare(scope, parameter.name, parameter.type, false, args[index]));
|
|
455
|
+
const flow = statement(fn.body, scope);
|
|
456
|
+
if (flow && flow.kind !== "return") fail();
|
|
457
|
+
return convert(fn.type, flow?.kind === "return" ? flow.value : void 0);
|
|
458
|
+
} finally {
|
|
459
|
+
depth--;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function statement(node, scope) {
|
|
463
|
+
step();
|
|
464
|
+
switch (node.kind) {
|
|
465
|
+
case "block": {
|
|
466
|
+
const child = { bindings: /* @__PURE__ */ new Map(), parent: scope };
|
|
467
|
+
for (const item of node.statements) {
|
|
468
|
+
const flow = statement(item, child);
|
|
469
|
+
if (flow) return flow;
|
|
470
|
+
}
|
|
471
|
+
return void 0;
|
|
472
|
+
}
|
|
473
|
+
case "declare": {
|
|
474
|
+
const initial = node.type === "bool" ? { type: "bool", value: false } : node.type === "string" ? { type: "string", value: "" } : number(0, node.type === "int" ? "int" : "double");
|
|
475
|
+
declare(scope, node.name, node.type, node.constant, node.value ? expression(node.value, scope) : initial);
|
|
476
|
+
return void 0;
|
|
477
|
+
}
|
|
478
|
+
case "assign": {
|
|
479
|
+
const binding = lookup(scope, node.name);
|
|
480
|
+
if (binding.constant) fail();
|
|
481
|
+
binding.value = convert(binding.type, expression(node.value, scope));
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
case "expression":
|
|
485
|
+
expression(node.value, scope);
|
|
486
|
+
return void 0;
|
|
487
|
+
case "if": {
|
|
488
|
+
const branch = boolean(expression(node.condition, scope)) ? node.then : node.otherwise;
|
|
489
|
+
return branch ? statement(branch, { bindings: /* @__PURE__ */ new Map(), parent: scope }) : void 0;
|
|
490
|
+
}
|
|
491
|
+
case "for":
|
|
492
|
+
case "while": {
|
|
493
|
+
const loopScope = { bindings: /* @__PURE__ */ new Map(), parent: scope };
|
|
494
|
+
if (node.kind === "for" && node.initial) statement(node.initial, loopScope);
|
|
495
|
+
while (!node.condition || boolean(expression(node.condition, loopScope))) {
|
|
496
|
+
step();
|
|
497
|
+
const flow = statement(node.body, { bindings: /* @__PURE__ */ new Map(), parent: loopScope });
|
|
498
|
+
if (flow?.kind === "return") return flow;
|
|
499
|
+
if (flow?.kind === "break") return void 0;
|
|
500
|
+
if (node.kind === "for" && node.increment) statement(node.increment, loopScope);
|
|
501
|
+
}
|
|
502
|
+
return void 0;
|
|
503
|
+
}
|
|
504
|
+
case "return":
|
|
505
|
+
return { kind: "return", value: node.value ? expression(node.value, scope) : void 0 };
|
|
506
|
+
case "break":
|
|
507
|
+
case "continue":
|
|
508
|
+
return { kind: node.kind };
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function dispose() {
|
|
512
|
+
closed = true;
|
|
513
|
+
commands = [];
|
|
514
|
+
sensors = /* @__PURE__ */ Object.create(null);
|
|
515
|
+
globals.bindings.clear();
|
|
516
|
+
program.functions.clear();
|
|
517
|
+
program.globals.length = 0;
|
|
518
|
+
signal?.removeEventListener("abort", dispose);
|
|
519
|
+
}
|
|
520
|
+
signal?.addEventListener("abort", dispose, { once: true });
|
|
521
|
+
if (signal?.aborted) dispose();
|
|
522
|
+
return {
|
|
523
|
+
get closed() {
|
|
524
|
+
return closed;
|
|
525
|
+
},
|
|
526
|
+
dispose,
|
|
527
|
+
run(rawInput) {
|
|
528
|
+
try {
|
|
529
|
+
remaining = 2e3;
|
|
530
|
+
step();
|
|
531
|
+
const input = record(rawInput, 2);
|
|
532
|
+
if (Object.keys(input).length !== 2 || !Object.hasOwn(input, "timeMs") || !Object.hasOwn(input, "sensors") || !Number.isSafeInteger(input.timeMs) || input.timeMs < lastTime || input.timeMs < 0 || input.timeMs > 1e9) fail("INVALID_INPUT");
|
|
533
|
+
const snapshot = record(input.sensors, 32);
|
|
534
|
+
sensors = Object.fromEntries(Object.entries(snapshot).map(([name, value]) => [name, primitive(value)]));
|
|
535
|
+
Object.setPrototypeOf(sensors, null);
|
|
536
|
+
timeMs = input.timeMs;
|
|
537
|
+
lastTime = timeMs;
|
|
538
|
+
remaining = 2e3;
|
|
539
|
+
commands = [];
|
|
540
|
+
if (!initialized) {
|
|
541
|
+
for (const global of program.globals) statement(global, globals);
|
|
542
|
+
if (program.functions.has("setup")) call("setup", []);
|
|
543
|
+
initialized = true;
|
|
544
|
+
}
|
|
545
|
+
call("loop", []);
|
|
546
|
+
return {
|
|
547
|
+
commands: commands.map((command) => ({ name: command.name, args: [...command.args] })),
|
|
548
|
+
globals: Object.fromEntries([...globals.bindings].map(([name, binding]) => [name, binding.value.value]))
|
|
549
|
+
};
|
|
550
|
+
} catch (error) {
|
|
551
|
+
dispose();
|
|
552
|
+
if (error instanceof CppProjectError) throw error;
|
|
553
|
+
throw new CppProjectError("EXECUTION_FAILED");
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
559
|
+
0 && (module.exports = {
|
|
560
|
+
CppProjectError,
|
|
561
|
+
createCppProjectSession
|
|
562
|
+
});
|
|
563
|
+
//# sourceMappingURL=cpp.cjs.map
|
package/dist/cpp.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cpp.ts","../src/cpp-parser.ts"],"sourcesContent":["import { CppProjectError, parseCppProject, type CppExpression, type CppStatement, type CppType, type CppValue } from \"./cpp-parser.js\";\nexport { CppProjectError } from \"./cpp-parser.js\";\n\nexport type CppOutputType = \"number\" | \"boolean\" | \"string\";\nexport interface CppProjectOptions {\n outputs: Readonly<Record<string, readonly CppOutputType[]>>;\n signal?: AbortSignal;\n}\nexport interface CppProjectInput { timeMs: number; sensors: Readonly<Record<string, CppValue>> }\nexport interface CppProjectCommand { name: string; args: CppValue[] }\nexport interface CppProjectResult { commands: CppProjectCommand[]; globals: Record<string, CppValue> }\nexport interface CppProjectSession {\n readonly closed: boolean;\n run(input: CppProjectInput): CppProjectResult;\n dispose(): void;\n}\ninterface Value { type: Exclude<CppType, \"void\">; value: CppValue }\ninterface Binding { type: Exclude<CppType, \"void\">; value: Value; constant: boolean }\ninterface Scope { bindings: Map<string, Binding>; parent?: Scope }\ntype Flow = { kind: \"return\"; value?: Value } | { kind: \"break\" | \"continue\" } | undefined;\nconst BUILTINS = new Set([\"millis\", \"numberSensor\", \"boolSensor\", \"textSensor\", \"min\", \"max\", \"abs\"]);\nconst NAME = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/u;\nfunction fail(code: ConstructorParameters<typeof CppProjectError>[0] = \"EXECUTION_FAILED\"): never { throw new CppProjectError(code); }\n\n/** Snapshot data properties only; callers cannot smuggle accessor execution through inputs. */\nfunction record(value: unknown, maximum: number): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(\"INVALID_INPUT\");\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const keys = Reflect.ownKeys(descriptors);\n if (keys.length > maximum) fail(\"INVALID_INPUT\");\n const result = Object.create(null) as Record<string, unknown>;\n for (const key of keys) {\n if (typeof key !== \"string\" || !NAME.test(key)) fail(\"INVALID_INPUT\");\n const descriptor = descriptors[key]!;\n if (!Object.hasOwn(descriptor, \"value\") || !descriptor.enumerable) fail(\"INVALID_INPUT\");\n result[key] = descriptor.value;\n }\n return result;\n}\nfunction primitive(value: unknown): CppValue {\n if (typeof value === \"boolean\") return value;\n if (typeof value === \"number\" && Number.isFinite(value) && Math.abs(value) <= 1e9) return value;\n if (typeof value === \"string\" && value.length <= 256 && !value.includes(\"\\0\")) return value;\n return fail(\"INVALID_INPUT\");\n}\nfunction numeric(value: Value | undefined): number {\n if (!value || (value.type !== \"int\" && value.type !== \"double\") || typeof value.value !== \"number\") fail();\n return value.value;\n}\nfunction boolean(value: Value | undefined): boolean { if (!value || value.type !== \"bool\") fail(); return value.value as boolean; }\nfunction number(value: number, type: \"int\" | \"double\" = \"double\"): Value {\n if (!Number.isFinite(value) || Math.abs(value) > 1e9) fail();\n return { type, value: type === \"int\" ? Math.trunc(value) : value };\n}\nfunction convert(type: CppType, value: Value | undefined): Value | undefined {\n if (type === \"void\") { if (value !== undefined) fail(); return undefined; }\n if (!value) fail();\n if (type === \"int\" || type === \"double\") return number(numeric(value), type);\n if (value.type !== type) fail();\n return value;\n}\nfunction lookup(scope: Scope, name: string): Binding {\n const binding = scope.bindings.get(name);\n if (binding) return binding;\n if (scope.parent) return lookup(scope.parent, name);\n return fail();\n}\nfunction outputSignatures(value: unknown): Map<string, CppOutputType[]> {\n const entries = record(value, 16);\n const result = new Map<string, CppOutputType[]>();\n for (const [name, signature] of Object.entries(entries)) {\n if (BUILTINS.has(name) || name === \"loop\" || name === \"setup\"\n || !Array.isArray(signature) || Object.getPrototypeOf(signature) !== Array.prototype || signature.length > 8) fail(\"INVALID_INPUT\");\n const descriptors = Object.getOwnPropertyDescriptors(signature);\n if (Reflect.ownKeys(descriptors).length !== signature.length + 1) fail(\"INVALID_INPUT\");\n const types: CppOutputType[] = [];\n for (let index = 0; index < signature.length; index++) {\n const descriptor = descriptors[String(index)];\n if (!descriptor || !Object.hasOwn(descriptor, \"value\") || ![\"number\", \"boolean\", \"string\"].includes(descriptor.value)) fail(\"INVALID_INPUT\");\n types.push(descriptor.value as CppOutputType);\n }\n result.set(name, types);\n }\n return result;\n}\n\n/** Execute the closed C++ simulator subset with primitive input and structured output only. */\nexport function createCppProjectSession(source: string, options: CppProjectOptions): CppProjectSession {\n const program = parseCppProject(source);\n const configuration = record(options, 2);\n if (!Object.hasOwn(configuration, \"outputs\") || Object.keys(configuration).some(key => key !== \"outputs\" && key !== \"signal\")\n || (configuration.signal !== undefined && !(configuration.signal instanceof AbortSignal))) fail(\"INVALID_INPUT\");\n const signal = configuration.signal as AbortSignal | undefined;\n const outputs = outputSignatures(configuration.outputs);\n for (const name of program.functions.keys()) if (BUILTINS.has(name) || outputs.has(name)) fail(\"INVALID_SOURCE\");\n for (const node of program.globals) if (node.kind === \"declare\" && (BUILTINS.has(node.name) || outputs.has(node.name))) fail(\"INVALID_SOURCE\");\n const globals: Scope = { bindings: new Map() };\n let closed = false;\n let initialized = false;\n let lastTime = -1;\n let timeMs = 0;\n let sensors: Record<string, CppValue> = Object.create(null) as Record<string, CppValue>;\n let commands: CppProjectCommand[] = [];\n let remaining = 2000;\n let depth = 0;\n function step(): void {\n if (closed || signal?.aborted) fail(\"CLOSED\");\n if (--remaining < 0) fail(\"BUDGET_EXCEEDED\");\n }\n function declare(scope: Scope, name: string, type: CppType, constant: boolean, value: Value | undefined): void {\n if (type === \"void\" || scope.bindings.has(name) || scope.bindings.size >= 64) fail();\n scope.bindings.set(name, { type, constant, value: convert(type, value)! });\n }\n function expression(node: CppExpression, scope: Scope): Value | undefined {\n step();\n if (node.kind === \"literal\") {\n if (typeof node.value === \"number\") return number(node.value, node.numberType ?? \"int\");\n return { type: typeof node.value === \"boolean\" ? \"bool\" : \"string\", value: node.value };\n }\n if (node.kind === \"variable\") return lookup(scope, node.name).value;\n if (node.kind === \"call\") return call(node.name, node.args.map(argument => expression(argument, scope)));\n if (node.kind === \"unary\") {\n const value = expression(node.value, scope);\n if (node.operator === \"!\") return { type: \"bool\", value: !boolean(value) };\n return number(numeric(value) * (node.operator === \"-\" ? -1 : 1), value!.type as \"int\" | \"double\");\n }\n const left = expression(node.left, scope);\n if (node.operator === \"&&\") return { type: \"bool\", value: boolean(left) && boolean(expression(node.right, scope)) };\n if (node.operator === \"||\") return { type: \"bool\", value: boolean(left) || boolean(expression(node.right, scope)) };\n const right = expression(node.right, scope);\n if (!left || !right) fail();\n if (node.operator === \"==\" || node.operator === \"!=\") {\n if (typeof left.value !== typeof right.value) fail();\n const equal = left.value === right.value;\n return { type: \"bool\", value: node.operator === \"==\" ? equal : !equal };\n }\n const a = numeric(left); const b = numeric(right);\n const type = left.type === \"int\" && right.type === \"int\" ? \"int\" : \"double\";\n switch (node.operator) {\n case \"<\": return { type: \"bool\", value: a < b };\n case \"<=\": return { type: \"bool\", value: a <= b };\n case \">\": return { type: \"bool\", value: a > b };\n case \">=\": return { type: \"bool\", value: a >= b };\n case \"+\": return number(a + b, type);\n case \"-\": return number(a - b, type);\n case \"*\": return number(a * b, type);\n case \"/\": return number(a / b, type);\n case \"%\": if (type !== \"int\") fail(); return number(a % b, \"int\");\n default: return fail();\n }\n }\n function call(name: string, args: (Value | undefined)[]): Value | undefined {\n step();\n if (args.some(argument => !argument)) fail();\n if (name === \"millis\") { if (args.length !== 0) fail(); return number(timeMs, \"int\"); }\n if (name === \"numberSensor\" || name === \"boolSensor\" || name === \"textSensor\") {\n if (args.length !== 1 || args[0]!.type !== \"string\") fail();\n const value = sensors[args[0]!.value as string];\n const type = name === \"numberSensor\" ? \"number\" : name === \"boolSensor\" ? \"boolean\" : \"string\";\n if (typeof value !== type) fail();\n return { type: type === \"number\" ? \"double\" : type === \"boolean\" ? \"bool\" : \"string\", value: value! };\n }\n if (name === \"min\" || name === \"max\" || name === \"abs\") {\n if (args.length !== (name === \"abs\" ? 1 : 2)) fail();\n const values = args.map(numeric);\n return number(name === \"abs\" ? Math.abs(values[0]!) : name === \"min\" ? Math.min(...values) : Math.max(...values), args.every(arg => arg!.type === \"int\") ? \"int\" : \"double\");\n }\n const signature = outputs.get(name);\n if (signature) {\n if (signature.length !== args.length || signature.some((type, index) => typeof args[index]!.value !== type)) fail();\n if (commands.length >= 64) fail(\"BUDGET_EXCEEDED\");\n commands.push({ name, args: args.map(arg => arg!.value) });\n return undefined;\n }\n const fn = program.functions.get(name);\n if (!fn || fn.parameters.length !== args.length) fail();\n if (++depth > 16) fail(\"BUDGET_EXCEEDED\");\n try {\n const scope: Scope = { bindings: new Map(), parent: globals };\n fn.parameters.forEach((parameter, index) => declare(scope, parameter.name, parameter.type, false, args[index]));\n const flow = statement(fn.body, scope);\n if (flow && flow.kind !== \"return\") fail();\n return convert(fn.type, flow?.kind === \"return\" ? flow.value : undefined);\n } finally { depth--; }\n }\n function statement(node: CppStatement, scope: Scope): Flow {\n step();\n switch (node.kind) {\n case \"block\": {\n const child: Scope = { bindings: new Map(), parent: scope };\n for (const item of node.statements) { const flow = statement(item, child); if (flow) return flow; }\n return undefined;\n }\n case \"declare\": {\n const initial: Value = node.type === \"bool\" ? { type: \"bool\", value: false } : node.type === \"string\" ? { type: \"string\", value: \"\" } : number(0, node.type === \"int\" ? \"int\" : \"double\");\n declare(scope, node.name, node.type, node.constant, node.value ? expression(node.value, scope) : initial);\n return undefined;\n }\n case \"assign\": {\n const binding = lookup(scope, node.name); if (binding.constant) fail();\n binding.value = convert(binding.type, expression(node.value, scope))!; return undefined;\n }\n case \"expression\": expression(node.value, scope); return undefined;\n case \"if\": {\n const branch = boolean(expression(node.condition, scope)) ? node.then : node.otherwise;\n return branch ? statement(branch, { bindings: new Map(), parent: scope }) : undefined;\n }\n case \"for\":\n case \"while\": {\n const loopScope: Scope = { bindings: new Map(), parent: scope };\n if (node.kind === \"for\" && node.initial) statement(node.initial, loopScope);\n while (!node.condition || boolean(expression(node.condition, loopScope))) {\n step();\n const flow = statement(node.body, { bindings: new Map(), parent: loopScope });\n if (flow?.kind === \"return\") return flow;\n if (flow?.kind === \"break\") return undefined;\n if (node.kind === \"for\" && node.increment) statement(node.increment, loopScope);\n }\n return undefined;\n }\n case \"return\": return { kind: \"return\", value: node.value ? expression(node.value, scope) : undefined };\n case \"break\": case \"continue\": return { kind: node.kind };\n }\n }\n function dispose(): void {\n closed = true; commands = []; sensors = Object.create(null) as Record<string, CppValue>;\n globals.bindings.clear(); program.functions.clear(); program.globals.length = 0;\n signal?.removeEventListener(\"abort\", dispose);\n }\n signal?.addEventListener(\"abort\", dispose, { once: true });\n if (signal?.aborted) dispose();\n return {\n get closed() { return closed; }, dispose,\n run(rawInput) {\n try {\n remaining = 2000;\n step();\n const input = record(rawInput, 2);\n if (Object.keys(input).length !== 2 || !Object.hasOwn(input, \"timeMs\") || !Object.hasOwn(input, \"sensors\")\n || !Number.isSafeInteger(input.timeMs) || (input.timeMs as number) < lastTime || (input.timeMs as number) < 0 || (input.timeMs as number) > 1e9) fail(\"INVALID_INPUT\");\n const snapshot = record(input.sensors, 32);\n sensors = Object.fromEntries(Object.entries(snapshot).map(([name, value]) => [name, primitive(value)]));\n // Null prototype prevents inherited names from masquerading as sensor samples.\n Object.setPrototypeOf(sensors, null);\n timeMs = input.timeMs as number; lastTime = timeMs; remaining = 2000; commands = [];\n if (!initialized) {\n for (const global of program.globals) statement(global, globals);\n if (program.functions.has(\"setup\")) call(\"setup\", []);\n initialized = true;\n }\n call(\"loop\", []);\n return { commands: commands.map(command => ({ name: command.name, args: [...command.args] })),\n globals: Object.fromEntries([...globals.bindings].map(([name, binding]) => [name, binding.value.value])) };\n } catch (error) {\n dispose();\n if (error instanceof CppProjectError) throw error;\n throw new CppProjectError(\"EXECUTION_FAILED\");\n }\n },\n };\n}\n","export type CppType = \"int\" | \"double\" | \"bool\" | \"string\" | \"void\";\nexport type CppValue = number | boolean | string;\nexport type CppExpression =\n | { kind: \"literal\"; value: CppValue; numberType?: \"int\" | \"double\" }\n | { kind: \"variable\"; name: string }\n | { kind: \"call\"; name: string; args: CppExpression[] }\n | { kind: \"unary\"; operator: string; value: CppExpression }\n | { kind: \"binary\"; operator: string; left: CppExpression; right: CppExpression };\nexport type CppStatement =\n | { kind: \"block\"; statements: CppStatement[] }\n | { kind: \"declare\"; type: CppType; constant: boolean; name: string; value?: CppExpression }\n | { kind: \"assign\"; name: string; value: CppExpression }\n | { kind: \"expression\"; value: CppExpression }\n | { kind: \"if\"; condition: CppExpression; then: CppStatement; otherwise?: CppStatement }\n | { kind: \"while\"; condition: CppExpression; body: CppStatement }\n | { kind: \"for\"; initial?: CppStatement; condition?: CppExpression; increment?: CppStatement; body: CppStatement }\n | { kind: \"return\"; value?: CppExpression }\n | { kind: \"break\" | \"continue\" };\nexport interface CppFunction { name: string; type: CppType; parameters: { name: string; type: CppType }[]; body: CppStatement }\nexport interface CppProgram { globals: CppStatement[]; functions: Map<string, CppFunction> }\nexport class CppProjectError extends Error {\n constructor(readonly code: \"INVALID_SOURCE\" | \"INVALID_INPUT\" | \"BUDGET_EXCEEDED\" | \"EXECUTION_FAILED\" | \"CLOSED\") {\n super(`Robot program ${code.toLowerCase().replaceAll(\"_\", \" \")}.`); this.name = \"CppProjectError\";\n }\n}\ninterface Token { text: string; value?: CppValue; numberType?: \"int\" | \"double\"; kind: \"symbol\" | \"identifier\" | \"literal\" }\nconst TYPES = new Set([\"int\", \"double\", \"bool\", \"string\", \"void\"]);\nconst RESERVED = new Set([...TYPES, \"const\", \"if\", \"else\", \"while\", \"for\", \"return\", \"break\", \"continue\", \"true\", \"false\"]);\nconst PRECEDENCE: Record<string, number> = { \"||\": 1, \"&&\": 2, \"==\": 3, \"!=\": 3, \"<\": 4, \"<=\": 4, \">\": 4, \">=\": 4, \"+\": 5, \"-\": 5, \"*\": 6, \"/\": 6, \"%\": 6 };\nfunction invalid(): never { throw new CppProjectError(\"INVALID_SOURCE\"); }\n\nfunction tokenize(source: string): Token[] {\n if (typeof source !== \"string\" || source.length > 32768 || source.includes(\"\\0\")) invalid();\n const tokens: Token[] = [];\n let offset = 0;\n while (offset < source.length) {\n const rest = source.slice(offset);\n if (/^\\s/u.test(rest)) { offset++; continue; }\n if (rest.startsWith(\"//\")) { const end = source.indexOf(\"\\n\", offset); offset = end < 0 ? source.length : end + 1; continue; }\n if (rest.startsWith(\"/*\")) { const end = source.indexOf(\"*/\", offset + 2); if (end < 0) invalid(); offset = end + 2; continue; }\n const number = /^(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?/u.exec(rest);\n const identifier = /^[A-Za-z_][A-Za-z0-9_]*/u.exec(rest);\n if (number) { tokens.push({ text: number[0], kind: \"literal\", value: Number(number[0]), numberType: /[.eE]/u.test(number[0]) ? \"double\" : \"int\" }); offset += number[0].length; }\n else if (identifier) {\n if (identifier[0].length > 64) invalid();\n tokens.push({ text: identifier[0], kind: \"identifier\" }); offset += identifier[0].length;\n } else if (rest[0] === '\"') {\n const quoted = /^\"(?:[^\"\\\\\\r\\n]|\\\\.)*\"/u.exec(rest);\n if (!quoted) invalid();\n let value: unknown;\n try { value = JSON.parse(quoted[0]); } catch { invalid(); }\n if (typeof value !== \"string\" || value.length > 256 || value.includes(\"\\0\")) invalid();\n tokens.push({ text: quoted[0], kind: \"literal\", value }); offset += quoted[0].length;\n } else {\n const operator = /^(?:==|!=|<=|>=|&&|\\|\\||\\+\\+|--|\\+=|-=|\\*=|\\/=|%=|[{}();,=+*/%!<>-])/u.exec(rest);\n if (!operator) invalid();\n tokens.push({ text: operator[0], kind: \"symbol\" }); offset += operator[0].length;\n }\n if (tokens.length > 4096) invalid();\n }\n tokens.push({ text: \"<end>\", kind: \"symbol\" });\n return tokens;\n}\n\nclass Parser {\n #offset = 0;\n #depth = 0;\n constructor(private readonly tokens: Token[]) {}\n current(): Token { return this.tokens[this.#offset]!; }\n is(text: string): boolean { return this.current().text === text; }\n take(): Token { if (this.is(\"<end>\")) invalid(); return this.tokens[this.#offset++]!; }\n accept(text: string): boolean { if (!this.is(text)) return false; this.take(); return true; }\n expect(text: string): void { if (!this.accept(text)) invalid(); }\n name(): string { const token = this.take(); if (token.kind !== \"identifier\" || RESERVED.has(token.text)) invalid(); return token.text; }\n type(): CppType { const token = this.take(); if (!TYPES.has(token.text)) invalid(); return token.text as CppType; }\n nested<T>(operation: () => T): T {\n if (++this.#depth > 64) invalid();\n try { return operation(); } finally { this.#depth--; }\n }\n program(): CppProgram {\n const globals: CppStatement[] = [];\n const functions = new Map<string, CppFunction>();\n const names = new Set<string>();\n while (!this.is(\"<end>\")) {\n const constant = this.accept(\"const\");\n const type = this.type();\n const name = this.name();\n if (names.has(name) || names.size >= 64) invalid();\n names.add(name);\n if (this.accept(\"(\")) {\n if (constant || functions.size >= 32) invalid();\n const parameters: CppFunction[\"parameters\"] = [];\n if (!this.is(\")\")) {\n do {\n const parameterType = this.type(); const parameterName = this.name();\n if (parameterType === \"void\" || parameters.some(parameter => parameter.name === parameterName) || parameters.length >= 8) invalid();\n parameters.push({ type: parameterType, name: parameterName });\n } while (this.accept(\",\"));\n }\n this.expect(\")\");\n if (!this.is(\"{\")) invalid();\n functions.set(name, { name, type, parameters, body: this.statement() });\n } else {\n if (type === \"void\") invalid();\n const value = this.accept(\"=\") ? this.expression() : undefined;\n if (constant && !value) invalid();\n this.expect(\";\"); globals.push({ kind: \"declare\", type, constant, name, value });\n }\n }\n const loop = functions.get(\"loop\"); const setup = functions.get(\"setup\");\n if (!loop || loop.type !== \"void\" || loop.parameters.length !== 0\n || (setup && (setup.type !== \"void\" || setup.parameters.length !== 0))) invalid();\n return { globals, functions };\n }\n declaration(): CppStatement {\n const constant = this.accept(\"const\"); const type = this.type(); const name = this.name();\n if (type === \"void\") invalid();\n const value = this.accept(\"=\") ? this.expression() : undefined;\n if (constant && !value) invalid();\n return { kind: \"declare\", type, constant, name, value };\n }\n simple(): CppStatement {\n if (this.is(\"const\") || TYPES.has(this.current().text)) return this.declaration();\n const value = this.expression();\n const operator = this.current().text;\n if ([\"=\", \"+=\", \"-=\", \"*=\", \"/=\", \"%=\", \"++\", \"--\"].includes(operator)) {\n this.take(); if (value.kind !== \"variable\") invalid();\n const right: CppExpression = operator === \"++\" || operator === \"--\" ? { kind: \"literal\", value: 1 } : this.expression();\n return { kind: \"assign\", name: value.name, value: operator === \"=\" ? right : { kind: \"binary\", operator: operator[0]!, left: value, right } };\n }\n return { kind: \"expression\", value };\n }\n statement(): CppStatement {\n return this.nested(() => {\n if (this.accept(\"{\")) {\n const statements: CppStatement[] = [];\n while (!this.accept(\"}\")) statements.push(this.statement());\n return { kind: \"block\", statements };\n }\n if (this.accept(\"if\")) {\n this.expect(\"(\"); const condition = this.expression(); this.expect(\")\"); const then = this.statement();\n const otherwise = this.accept(\"else\") ? this.statement() : undefined;\n return { kind: \"if\", condition, then, otherwise };\n }\n if (this.accept(\"while\")) {\n this.expect(\"(\"); const condition = this.expression(); this.expect(\")\");\n return { kind: \"while\", condition, body: this.statement() };\n }\n if (this.accept(\"for\")) {\n this.expect(\"(\"); const initial = this.is(\";\") ? undefined : this.simple(); this.expect(\";\");\n const condition = this.is(\";\") ? undefined : this.expression(); this.expect(\";\");\n const increment = this.is(\")\") ? undefined : this.simple(); this.expect(\")\");\n return { kind: \"for\", initial, condition, increment, body: this.statement() };\n }\n if (this.accept(\"return\")) {\n const value = this.is(\";\") ? undefined : this.expression(); this.expect(\";\"); return { kind: \"return\", value };\n }\n if (this.is(\"break\") || this.is(\"continue\")) { const kind = this.take().text as \"break\" | \"continue\"; this.expect(\";\"); return { kind }; }\n if (this.accept(\";\")) return { kind: \"block\", statements: [] };\n const result = this.simple(); this.expect(\";\"); return result;\n });\n }\n expression(minimum = 0): CppExpression {\n return this.nested(() => {\n let left: CppExpression;\n const token = this.take();\n if ([\"!\", \"-\", \"+\"].includes(token.text)) left = { kind: \"unary\", operator: token.text, value: this.expression(7) };\n else if (token.text === \"(\") { left = this.expression(); this.expect(\")\"); }\n else if (token.kind === \"literal\") left = { kind: \"literal\", value: token.value!, numberType: token.numberType };\n else if (token.text === \"true\" || token.text === \"false\") left = { kind: \"literal\", value: token.text === \"true\" };\n else if (token.kind === \"identifier\" && !RESERVED.has(token.text)) {\n if (this.accept(\"(\")) {\n const args: CppExpression[] = [];\n if (!this.is(\")\")) do { if (args.length >= 8) invalid(); args.push(this.expression()); } while (this.accept(\",\"));\n this.expect(\")\"); left = { kind: \"call\", name: token.text, args };\n } else left = { kind: \"variable\", name: token.text };\n } else invalid();\n while ((PRECEDENCE[this.current().text] ?? -1) >= minimum) {\n const operator = this.take().text;\n left = { kind: \"binary\", operator, left, right: this.expression(PRECEDENCE[operator]! + 1) };\n }\n return left;\n });\n }\n}\n\n/** Parse only the documented simulator grammar, with no host evaluation. */\nexport function parseCppProject(source: string): CppProgram { return new Parser(tokenize(source)).program(); }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YAAqB,MAA8F;AACjH,UAAM,iBAAiB,KAAK,YAAY,EAAE,WAAW,KAAK,GAAG,CAAC,GAAG;AAD9C;AACiD,SAAK,OAAO;AAAA,EAClF;AAAA,EAFqB;AAGvB;AAEA,IAAM,QAAQ,oBAAI,IAAI,CAAC,OAAO,UAAU,QAAQ,UAAU,MAAM,CAAC;AACjE,IAAM,WAAW,oBAAI,IAAI,CAAC,GAAG,OAAO,SAAS,MAAM,QAAQ,SAAS,OAAO,UAAU,SAAS,YAAY,QAAQ,OAAO,CAAC;AAC1H,IAAM,aAAqC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE;AAC1J,SAAS,UAAiB;AAAE,QAAM,IAAI,gBAAgB,gBAAgB;AAAG;AAEzE,SAAS,SAAS,QAAyB;AACzC,MAAI,OAAO,WAAW,YAAY,OAAO,SAAS,SAAS,OAAO,SAAS,IAAI,EAAG,SAAQ;AAC1F,QAAM,SAAkB,CAAC;AACzB,MAAI,SAAS;AACb,SAAO,SAAS,OAAO,QAAQ;AAC7B,UAAM,OAAO,OAAO,MAAM,MAAM;AAChC,QAAI,OAAO,KAAK,IAAI,GAAG;AAAE;AAAU;AAAA,IAAU;AAC7C,QAAI,KAAK,WAAW,IAAI,GAAG;AAAE,YAAM,MAAM,OAAO,QAAQ,MAAM,MAAM;AAAG,eAAS,MAAM,IAAI,OAAO,SAAS,MAAM;AAAG;AAAA,IAAU;AAC7H,QAAI,KAAK,WAAW,IAAI,GAAG;AAAE,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