fez-lisp 1.6.46 → 1.6.47
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/utils.js +41 -36
package/package.json
CHANGED
package/src/utils.js
CHANGED
@@ -374,48 +374,53 @@ export const isInputVariable = (x) =>
|
|
374
374
|
x[1][VALUE] === 'INPUT'
|
375
375
|
|
376
376
|
export const init = () => {
|
377
|
-
import('fs').then(({ writeFileSync }) => {
|
377
|
+
import('fs').then(({ writeFileSync, mkdirSync }) => {
|
378
378
|
console.log('\x1b[32m')
|
379
|
-
|
380
|
-
console.log('Added
|
381
|
-
writeFileSync('
|
382
|
-
console.log('Added
|
379
|
+
mkdirSync('src')
|
380
|
+
console.log('Added directory src in root')
|
381
|
+
writeFileSync('./src/main.lisp', '')
|
382
|
+
console.log('Added file main.lisp in src')
|
383
|
+
writeFileSync('./src/types.lisp', '')
|
384
|
+
console.log('Added file types.lisp in src')
|
383
385
|
writeFileSync(
|
384
386
|
'index.js',
|
385
|
-
`import { compile, enhance, parse, LISP, UTILS } from
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
}
|
399
|
-
UTILS.logResult(LISP.serialise(evaluated))
|
400
|
-
} else UTILS.logError(error.message)
|
401
|
-
} catch (error) {
|
402
|
-
UTILS.logError(error.message)
|
403
|
-
}
|
404
|
-
}
|
405
|
-
export const comp = (source) => compile(enhance(parse(source)))
|
406
|
-
const file = readFileSync('./main.lisp', 'utf-8')
|
407
|
-
switch (process.argv[2]) {
|
408
|
-
case 'comp':
|
409
|
-
writeFileSync('./main.js', 'var _ = ' + comp(file) + '; console.log(_)')
|
410
|
-
break
|
411
|
-
case 'dev':
|
412
|
-
default:
|
413
|
-
dev(file, readFileSync('./types.lisp', 'utf-8'))
|
414
|
-
break
|
387
|
+
`import { compile, enhance, parse, LISP, UTILS } from "fez-lisp";
|
388
|
+
import { readFileSync, writeFileSync } from "fs";
|
389
|
+
export const dev = (source, types) => {
|
390
|
+
try {
|
391
|
+
const parsed = parse(source);
|
392
|
+
const { evaluated, type, error } = UTILS.debug(
|
393
|
+
parsed,
|
394
|
+
true,
|
395
|
+
types ? types : undefined
|
396
|
+
);
|
397
|
+
if (error == null) {
|
398
|
+
if (type) {
|
399
|
+
UTILS.logType(type);
|
415
400
|
}
|
401
|
+
UTILS.logResult(LISP.serialise(evaluated));
|
402
|
+
} else UTILS.logError(error.message);
|
403
|
+
} catch (error) {
|
404
|
+
UTILS.logError(error.message);
|
405
|
+
}
|
406
|
+
};
|
407
|
+
export const comp = (source) => compile(enhance(parse(source)));
|
408
|
+
const file = readFileSync("./src/main.lisp", "utf-8");
|
409
|
+
switch (process.argv[2]) {
|
410
|
+
case "comp":
|
411
|
+
writeFileSync(
|
412
|
+
"./src/main.js",
|
413
|
+
"var _ = " + comp(file) + "; console.log(_)"
|
414
|
+
);
|
415
|
+
break;
|
416
|
+
case "dev":
|
417
|
+
default:
|
418
|
+
dev(file, readFileSync("./src/types.lisp", "utf-8"));
|
419
|
+
break;
|
420
|
+
}
|
416
421
|
`
|
417
422
|
)
|
418
|
-
console.log('Added index.js')
|
423
|
+
console.log('Added file index.js in root')
|
419
424
|
console.log(
|
420
425
|
`Done!
|
421
426
|
|