lemmascript 0.0.1 → 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.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Typed IR — Raw IR annotated with resolved types and classifications.
3
+ *
4
+ * Produced by the resolve pass. Consumed by the transform.
5
+ * Still TS-shaped (not Lean-shaped).
6
+ */
7
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Type mapping — TS types → Lean types.
3
+ *
4
+ * Single source of truth for type-related decisions.
5
+ * The transform phase imports this.
6
+ */
7
+ export function tyToLean(ty) {
8
+ switch (ty.kind) {
9
+ case "nat": return "Nat";
10
+ case "int": return "Int";
11
+ case "bool": return "Bool";
12
+ case "string": return "String";
13
+ case "void": return "Unit";
14
+ case "array": {
15
+ const elem = tyToLean(ty.elem);
16
+ return elem.includes(" ") ? `Array (${elem})` : `Array ${elem}`;
17
+ }
18
+ case "user": return ty.name;
19
+ case "unknown": return "_";
20
+ }
21
+ }
22
+ export function parseTsType(tsType) {
23
+ const t = tsType.trim();
24
+ if (t === "number")
25
+ return { kind: "int" };
26
+ if (t === "nat")
27
+ return { kind: "nat" };
28
+ if (t === "boolean")
29
+ return { kind: "bool" };
30
+ if (t === "string")
31
+ return { kind: "string" };
32
+ if (t === "void" || t === "undefined")
33
+ return { kind: "void" };
34
+ const m = t.match(/^(?:Array<(.+)>|(.+)\[\])$/);
35
+ if (m)
36
+ return { kind: "array", elem: parseTsType(m[1] || m[2]) };
37
+ return { kind: "user", name: t };
38
+ }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const VERSION = "0.0.1";
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERSION = void 0;
4
- exports.VERSION = "0.0.1";
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export const VERSION = "0.0.1";
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "Node16",
5
- "moduleResolution": "Node16",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "declaration": true,
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true
12
- },
13
- "include": ["src"]
14
- }