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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.6.58",
5
+ "version": "1.6.59",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
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(file) + "; console.log(_)"
415
+ "var _ = " + comp(src) + "; console.log(_)"
414
416
  );
415
417
  break;
416
418
  case "dev":
417
419
  default:
418
- dev(file, readFileSync("./src/types.lisp", "utf-8"));
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 and types (if any) in types.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,