fez-lisp 1.6.58 → 1.6.59
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/package.json +1 -1
- package/src/types.js +9 -0
- package/src/utils.js +8 -5
package/package.json
CHANGED
package/src/types.js
CHANGED
@@ -1539,3 +1539,12 @@ export const filteredDefinedTypes = (program, lib, libT) => {
|
|
1539
1539
|
export const definedTypes = (T) => fromSourceToType(T)
|
1540
1540
|
export const withStdDefinedTypes = (ast) =>
|
1541
1541
|
withCtxTypes(definedTypes(filteredDefinedTypes(ast, std, stdT)))
|
1542
|
+
|
1543
|
+
export const extractTypes = (source) => {
|
1544
|
+
let types
|
1545
|
+
const src = source.replaceAll(/\(the.+\)/g, (match, token) => {
|
1546
|
+
types = match
|
1547
|
+
return ''
|
1548
|
+
})
|
1549
|
+
return [src, types]
|
1550
|
+
}
|
package/src/utils.js
CHANGED
@@ -21,6 +21,7 @@ import { type, typeCheck, withScope } from './check.js'
|
|
21
21
|
import stdT from '../lib/baked/std-T.js'
|
22
22
|
import {
|
23
23
|
definedTypes,
|
24
|
+
extractTypes,
|
24
25
|
filteredDefinedTypes,
|
25
26
|
formatAstTypes,
|
26
27
|
withCtxTypes
|
@@ -380,8 +381,8 @@ export const init = () => {
|
|
380
381
|
console.log('Added directory src in root')
|
381
382
|
writeFileSync('./src/main.lisp', '')
|
382
383
|
console.log('Added file main.lisp in src')
|
383
|
-
writeFileSync('./src/types.lisp', '')
|
384
|
-
console.log('Added file types.lisp in src')
|
384
|
+
// writeFileSync('./src/types.lisp', '')
|
385
|
+
// console.log('Added file types.lisp in src')
|
385
386
|
writeFileSync(
|
386
387
|
'index.js',
|
387
388
|
`import { compile, enhance, parse, LISP, UTILS } from "fez-lisp";
|
@@ -406,16 +407,17 @@ export const dev = (source, types) => {
|
|
406
407
|
};
|
407
408
|
export const comp = (source) => compile(enhance(parse(source)));
|
408
409
|
const file = readFileSync("./src/main.lisp", "utf-8");
|
410
|
+
const [src, typ] = UTILS.extractTypes(file);
|
409
411
|
switch (process.argv[2]) {
|
410
412
|
case "comp":
|
411
413
|
writeFileSync(
|
412
414
|
"./src/main.js",
|
413
|
-
"var _ = " + comp(
|
415
|
+
"var _ = " + comp(src) + "; console.log(_)"
|
414
416
|
);
|
415
417
|
break;
|
416
418
|
case "dev":
|
417
419
|
default:
|
418
|
-
dev(
|
420
|
+
dev(src, typ);
|
419
421
|
break;
|
420
422
|
}
|
421
423
|
`
|
@@ -424,7 +426,7 @@ switch (process.argv[2]) {
|
|
424
426
|
console.log(
|
425
427
|
`Done!
|
426
428
|
|
427
|
-
Write code in main.lisp
|
429
|
+
Write code in main.lisp
|
428
430
|
Run node index.js with the following flags:
|
429
431
|
- dev (static type check and run time validations)
|
430
432
|
- comp (compile Fez to JavaScript file main.js)
|
@@ -440,6 +442,7 @@ That's it! You are all set!
|
|
440
442
|
}
|
441
443
|
|
442
444
|
export const UTILS = {
|
445
|
+
extractTypes,
|
443
446
|
init,
|
444
447
|
debug,
|
445
448
|
startDebug,
|