fez-lisp 1.0.51 → 1.0.53
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +3 -3
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/compiler.js +1 -1
- package/src/evaluator.js +43 -0
- package/src/interpreter.js +1129 -34
- package/src/parser.js +1 -1
- package/src/utils.js +3 -4
- package/src/tokeniser.js +0 -1145
- /package/src/{enums.js → keywords.js} +0 -0
package/src/parser.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { APPLY, ATOM, TYPE, WORD, VALUE } from './
|
1
|
+
import { APPLY, ATOM, TYPE, WORD, VALUE } from './keywords.js'
|
2
2
|
import { escape, preserveEscape } from './utils.js'
|
3
3
|
export const leaf = (type, value) => [type, value]
|
4
4
|
export const isLeaf = ([car]) => car === APPLY || car === ATOM || car === WORD
|
package/src/utils.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import std from '../lib/baked/std.js'
|
2
2
|
import { comp } from './compiler.js'
|
3
|
-
import { APPLY, KEYWORDS, TYPE, VALUE, WORD } from './
|
4
|
-
import { run } from './
|
3
|
+
import { APPLY, KEYWORDS, TYPE, VALUE, WORD } from './keywords.js'
|
4
|
+
import { run } from './evaluator.js'
|
5
5
|
import { AST, isLeaf, LISP } from './parser.js'
|
6
6
|
export const logError = (error) => console.log('\x1b[31m', error, '\x1b[0m')
|
7
7
|
export const logSuccess = (output) => console.log(output, '\x1b[0m')
|
@@ -15,10 +15,9 @@ export const isBalancedParenthesis = (sourceCode) => {
|
|
15
15
|
let count = 0
|
16
16
|
const stack = []
|
17
17
|
const str = sourceCode.match(/[/\(|\)](?=[^"]*(?:"[^"]*"[^"]*)*$)/g) ?? []
|
18
|
-
const pairs = { ')': '(' }
|
19
18
|
for (let i = 0; i < str.length; ++i)
|
20
19
|
if (str[i] === '(') stack.push(str[i])
|
21
|
-
else if (str[i]
|
20
|
+
else if (str[i] === ')') if (stack.pop() !== '(') ++count
|
22
21
|
return count - stack.length
|
23
22
|
}
|
24
23
|
export const escape = (Char) => {
|