@calcit/procs 0.4.33 → 0.4.37-a1
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/README.md +1 -1
- package/lib/calcit.procs.js +1 -1
- package/lib/js-cirru.js +9 -0
- package/package.json +4 -4
- package/ts-src/calcit.procs.ts +1 -1
- package/ts-src/js-cirru.ts +8 -0
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ cr -e="range 100" # eval from CLI
|
|
|
88
88
|
cr compact.cirru --emit-js # compile to js
|
|
89
89
|
cr compact.cirru --emit-js --emit-path=out/ # compile to js and save in `out/`
|
|
90
90
|
|
|
91
|
-
cr compact.cirru --emit-ir # compiles intermediate representation into program-ir.
|
|
91
|
+
cr compact.cirru --emit-ir # compiles intermediate representation into program-ir.cirru
|
|
92
92
|
|
|
93
93
|
cr compact.cirru --emit-js --mjs # TODO compile to mjs
|
|
94
94
|
```
|
package/lib/calcit.procs.js
CHANGED
package/lib/js-cirru.js
CHANGED
|
@@ -72,6 +72,9 @@ export let to_cirru_edn = (x) => {
|
|
|
72
72
|
// turn `x.snd` with CalcitList into raw Cirru nodes, which is in plain Array
|
|
73
73
|
return ["quote", toWriterNode(x.snd)];
|
|
74
74
|
}
|
|
75
|
+
else if (x.fst instanceof CalcitRecord) {
|
|
76
|
+
return ["::", "|" + x.fst.name, to_cirru_edn(x.snd)];
|
|
77
|
+
}
|
|
75
78
|
else {
|
|
76
79
|
throw new Error(`Unsupported tag for EDN: ${x.fst}`);
|
|
77
80
|
}
|
|
@@ -169,6 +172,12 @@ export let extract_cirru_edn = (x) => {
|
|
|
169
172
|
}
|
|
170
173
|
return new CalcitTuple(new CalcitSymbol("quote"), to_calcit_data(x[1], true));
|
|
171
174
|
}
|
|
175
|
+
if (x[0] === "::") {
|
|
176
|
+
if (x.length !== 3) {
|
|
177
|
+
throw new Error("tuple expects 2 values");
|
|
178
|
+
}
|
|
179
|
+
return new CalcitTuple(extract_cirru_edn(x[1]), extract_cirru_edn(x[2]));
|
|
180
|
+
}
|
|
172
181
|
}
|
|
173
182
|
console.error(x);
|
|
174
183
|
throw new Error("Unexpected data from cirru-edn");
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calcit/procs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37-a1",
|
|
4
4
|
"main": "./lib/calcit.procs.js",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@types/node": "^16.
|
|
7
|
-
"esbuild": "^0.
|
|
8
|
-
"typescript": "^4.4.
|
|
6
|
+
"@types/node": "^16.9.6",
|
|
7
|
+
"esbuild": "^0.13.2",
|
|
8
|
+
"typescript": "^4.4.3"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"compile": "rm -rfv lib/* && tsc",
|
package/ts-src/calcit.procs.ts
CHANGED
package/ts-src/js-cirru.ts
CHANGED
|
@@ -76,6 +76,8 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
76
76
|
if (x.fst instanceof CalcitSymbol && x.fst.value === "quote") {
|
|
77
77
|
// turn `x.snd` with CalcitList into raw Cirru nodes, which is in plain Array
|
|
78
78
|
return ["quote", toWriterNode(x.snd as any)] as CirruEdnFormat;
|
|
79
|
+
} else if (x.fst instanceof CalcitRecord) {
|
|
80
|
+
return ["::", "|" + x.fst.name, to_cirru_edn(x.snd)];
|
|
79
81
|
} else {
|
|
80
82
|
throw new Error(`Unsupported tag for EDN: ${x.fst}`);
|
|
81
83
|
}
|
|
@@ -172,6 +174,12 @@ export let extract_cirru_edn = (x: CirruEdnFormat): CalcitValue => {
|
|
|
172
174
|
}
|
|
173
175
|
return new CalcitTuple(new CalcitSymbol("quote"), to_calcit_data(x[1], true));
|
|
174
176
|
}
|
|
177
|
+
if (x[0] === "::") {
|
|
178
|
+
if (x.length !== 3) {
|
|
179
|
+
throw new Error("tuple expects 2 values");
|
|
180
|
+
}
|
|
181
|
+
return new CalcitTuple(extract_cirru_edn(x[1]), extract_cirru_edn(x[2]));
|
|
182
|
+
}
|
|
175
183
|
}
|
|
176
184
|
console.error(x);
|
|
177
185
|
throw new Error("Unexpected data from cirru-edn");
|