fez-lisp 1.5.169 → 1.5.171
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 +8 -1
- package/index.js +2 -2
- package/lib/baked/std-T.js +1 -1
- package/package.json +1 -1
- package/src/utils.js +14 -1
- package/logo.svg +0 -16
package/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Fez Programming Language
|
2
2
|
|
3
3
|
<p align="center">
|
4
|
-
<img width="128" src="./
|
4
|
+
<img width="128" src="./favicon.svg"/>
|
5
5
|
</p>
|
6
6
|
|
7
7
|
```lisp
|
@@ -37,3 +37,10 @@ import { parse, compile } from 'fez-lisp'
|
|
37
37
|
console.log(compile(parse('(+ 1 2)')))
|
38
38
|
// '(()=>{;return(()=>{return (1+2);})()})()'
|
39
39
|
```
|
40
|
+
|
41
|
+
```js
|
42
|
+
import { parse, fez } from 'fez-lisp'
|
43
|
+
const parsed = parse(`(|> [ 1 2 3 4 ] (math:map math:square) (math:summation))`)
|
44
|
+
const [result, error] = fez(parsed, false)
|
45
|
+
error == null ? console.log(result) : console.log('\x1b[31m', error, '\x1b[0m')
|
46
|
+
```
|
package/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { evaluate } from './src/evaluator.js'
|
2
2
|
import { compile } from './src/compiler.js'
|
3
|
-
import { parse, UTILS } from './src/utils.js'
|
3
|
+
import { parse, fez, UTILS } from './src/utils.js'
|
4
4
|
import { LISP, AST } from './src/parser.js'
|
5
5
|
import { type } from './src/check.js'
|
6
6
|
import { enhance } from './src/enhance.js'
|
7
|
-
export { parse, evaluate, compile, type, enhance, LISP, AST, UTILS }
|
7
|
+
export { parse, evaluate, compile, type, enhance, fez, LISP, AST, UTILS }
|
package/lib/baked/std-T.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default [[[0,"let"],[1,"math:map"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:select"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:exclude"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:fold"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:enumerated-fold"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:maximum-index"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:minimum-index"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-def"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-get"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-set!"],[[0,"lambda"],[1,"Numbers"],[1,"Number"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-del!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-set-and-get!"],[[0,"lambda"],[1,"Numbers"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-increment!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-decrement!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-increment-and-get!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-decrement-and-get!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:max-sub-array-sum"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"var:def"],[[0,"lambda"],[1,"Any"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:get"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"var:set!"],[[0,"lambda"],[1,"Unknowns"],[1,"Any"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:del!"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:set-and-get!"],[[0,"lambda"],[1,"Unknowns"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:first"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:second"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:third"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:last"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:transform"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Unknowns"],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]],[1,"Unknowns"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"array:reduce"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"array:enumerated-reduce"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"bools:fold"],[[0,"lambda"],[1,"Booleans"],[[0,"lambda"],[1,"Boolean"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]]],[[0,"let"],[1,"array:unique"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]]]
|
1
|
+
export default [[[0,"let"],[1,"math:map"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:select"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:exclude"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:fold"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:enumerated-fold"],[[0,"lambda"],[1,"Numbers"],[[0,"lambda"],[1,"Number"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:maximum-index"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:minimum-index"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-def"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-get"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-set!"],[[0,"lambda"],[1,"Numbers"],[1,"Number"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-del!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-set-and-get!"],[[0,"lambda"],[1,"Numbers"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-increment!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-decrement!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]],[[0,"let"],[1,"math:var-increment-and-get!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:var-decrement-and-get!"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:max-sub-array-sum"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:median"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"math:mean"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"var:def"],[[0,"lambda"],[1,"Any"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:get"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"var:set!"],[[0,"lambda"],[1,"Unknowns"],[1,"Any"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:del!"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"var:set-and-get!"],[[0,"lambda"],[1,"Unknowns"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:first"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:second"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:third"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:last"],[[0,"lambda"],[1,"Unknowns"],[[0,"do"],[1,"Any"]]]],[[0,"let"],[1,"array:transform"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Unknowns"],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]],[1,"Unknowns"],[[0,"do"],[1,"Unknowns"]]]],[[0,"let"],[1,"array:reduce"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"array:enumerated-reduce"],[[0,"lambda"],[1,"Unknowns"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"let"],[1,"bools:fold"],[[0,"lambda"],[1,"Booleans"],[[0,"lambda"],[1,"Boolean"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]]],[[0,"let"],[1,"array:unique"],[[0,"lambda"],[1,"Numbers"],[[0,"do"],[1,"Numbers"]]]]]
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
@@ -15,7 +15,11 @@ import {
|
|
15
15
|
deSuggarSource,
|
16
16
|
handleUnbalancedQuotes
|
17
17
|
} from './macros.js'
|
18
|
-
import { OPTIMIZATIONS } from './enhance.js'
|
18
|
+
import { enhance, OPTIMIZATIONS } from './enhance.js'
|
19
|
+
import { type } from './check.js'
|
20
|
+
import stdT from '../lib/baked/std-T.js'
|
21
|
+
import { definedTypes, withCtxTypes } from './types.js'
|
22
|
+
import { compile } from './compiler.js'
|
19
23
|
export const logError = (error) =>
|
20
24
|
console.log('\x1b[31m', `\n${error}\n`, '\x1b[0m')
|
21
25
|
export const logSuccess = (output) => console.log('\x1b[32m', output, '\x1b[0m')
|
@@ -498,3 +502,12 @@ export class Brr {
|
|
498
502
|
for (let i = 0, len = this.length; i < len; ++i) yield this.get(i)
|
499
503
|
}
|
500
504
|
}
|
505
|
+
export const fez = (ast, c = false) => {
|
506
|
+
try {
|
507
|
+
if (!c) type(ast, withCtxTypes(definedTypes(stdT)))
|
508
|
+
const opt = enhance(ast)
|
509
|
+
return [c ? compile(ast) : evaluate(opt), null]
|
510
|
+
} catch (err) {
|
511
|
+
return [null, err]
|
512
|
+
}
|
513
|
+
}
|
package/logo.svg
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
<svg width="60" height="88" viewBox="0 0 60 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
-
<path d="M56 58.4998C61.166 60.9107 63.7232 82.5984 43 86.4999C31.755 88.617 1.50018 90.3154 1.5 69C1.49978 42.7121 27.65 50.8529 43 58.4998C52 61 50.834 56.089 56 58.4998Z" fill="#F9B949"/>
|
3
|
-
<circle cx="25.5" cy="35.5" r="25.5" fill="#F9B949"/>
|
4
|
-
<circle cx="36.5" cy="31.5" r="2.5" fill="#1F1B1B"/>
|
5
|
-
<circle cx="9.5" cy="21.5" r="2.5" fill="#1F1B1B"/>
|
6
|
-
<circle cx="10" cy="21" r="1" fill="#EBEBEB"/>
|
7
|
-
<circle cx="10" cy="21" r="1" fill="#EBEBEB"/>
|
8
|
-
<circle cx="10" cy="21" r="1" fill="#EBEBEB"/>
|
9
|
-
<circle cx="37" cy="31" r="1" fill="#EBEBEB"/>
|
10
|
-
<circle cx="37" cy="31" r="1" fill="#EBEBEB"/>
|
11
|
-
<circle cx="37" cy="31" r="1" fill="#EBEBEB"/>
|
12
|
-
<path d="M49.8808 7.37404C50.5137 5.27388 40.491 0.514532 39.3766 1.22816C38.2623 1.9418 33.2308 11.7323 33.2308 11.7323L43.7349 17.8782C43.7349 17.8782 49.2479 9.47421 49.8808 7.37404Z" fill="#B44637"/>
|
13
|
-
<path d="M49.8808 7.37404C50.5137 5.27388 40.491 0.514532 39.3766 1.22816C38.2623 1.9418 33.2308 11.7323 33.2308 11.7323L43.7349 17.8782C43.7349 17.8782 49.2479 9.47421 49.8808 7.37404Z" fill="#B44637"/>
|
14
|
-
<path d="M51 15C46 13.5 54.6472 7.06417 48.8171 5" stroke="#F9B949" stroke-width="2" stroke-linecap="round"/>
|
15
|
-
<path d="M19.5 27.1883C16.1667 26.3396 12 28.635 12 28.635C12 28.635 12.4167 30.7565 17.4167 32.7045C22.4167 34.6525 27 35 27 35C27 35 22.8333 28.037 19.5 27.1883Z" fill="#B44637"/>
|
16
|
-
</svg>
|