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/src/parser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { APPLY, ATOM, TYPE, WORD, VALUE } from './enums.js'
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 './enums.js'
4
- import { run } from './interpreter.js'
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] in pairs) if (stack.pop() !== pairs[str[i]]) ++count
20
+ else if (str[i] === ')') if (stack.pop() !== '(') ++count
22
21
  return count - stack.length
23
22
  }
24
23
  export const escape = (Char) => {