fez-lisp 1.1.30 → 1.1.31

Sign up to get free protection for your applications and to get access to all the features.
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.1.30",
5
+ "version": "1.1.31",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/compiler.js CHANGED
@@ -11,7 +11,6 @@ import { leaf, isLeaf } from './parser.js'
11
11
  import { deepRename } from './utils.js'
12
12
  const earMuffsToLodashes = (name) => name.replace(new RegExp(/\*/g), '_')
13
13
  const dotNamesToEmpty = (name) => name.replace(new RegExp(/\./g), '')
14
- const commaToLodash = (name) => name.replace(new RegExp(/\,/g), '_')
15
14
  const arrowFromTo = (name) => name.replace(new RegExp(/->/g), '-to-')
16
15
  const moduleNameToLodashes = (name) => name.replace(new RegExp(/:/g), '_')
17
16
  const questionMarkToPredicate = (name) =>
@@ -57,9 +56,7 @@ const lispToJavaScriptVariableName = (name) =>
57
56
  dotNamesToEmpty(
58
57
  exclamationMarkMarkToEffect(
59
58
  questionMarkToPredicate(
60
- commaToLodash(
61
- moduleNameToLodashes(earMuffsToLodashes(keywordToHelper(name)))
62
- )
59
+ moduleNameToLodashes(earMuffsToLodashes(keywordToHelper(name)))
63
60
  )
64
61
  )
65
62
  )
@@ -182,7 +179,7 @@ const compile = (tree, Drill) => {
182
179
  } else {
183
180
  const name = lispToJavaScriptVariableName(n)
184
181
  Drill.Variables.add(name)
185
- return `(${name}=${compile(Arguments[1], Drill)});`
182
+ return `${name}=${compile(Arguments[1], Drill)};`
186
183
  }
187
184
  }
188
185
  case KEYWORDS.IS_ATOM:
package/src/keywords.js CHANGED
@@ -5,6 +5,7 @@ export const WORD = 1
5
5
  export const ATOM = 2
6
6
  export const PLACEHOLDER = '.'
7
7
  export const KEYWORDS = {
8
+ RECURSION: 'rec',
8
9
  NUMBER_TYPE: 'number',
9
10
  ARRAY_TYPE: 'array',
10
11
  IDENTITY: 'identity',
package/src/utils.js CHANGED
@@ -34,9 +34,11 @@ export const isBalancedParenthesis = (sourceCode) => {
34
34
  let count = 0
35
35
  const stack = []
36
36
  const str = sourceCode.match(/[/\(|\)]/g) ?? []
37
- for (let i = 0; i < str.length; ++i)
38
- if (str[i] === '(') stack.push(str[i])
39
- else if (str[i] === ')') if (stack.pop() !== '(') ++count
37
+ for (let i = 0; i < str.length; ++i) {
38
+ const current = str[i]
39
+ if (current === '(') stack.push(current)
40
+ else if (current === ')') if (stack.pop() !== '(') ++count
41
+ }
40
42
  return count - stack.length
41
43
  }
42
44
  export const escape = (Char) => {