fez-lisp 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -113,7 +113,7 @@ npm i fez-lisp
113
113
 
114
114
  ```js
115
115
  import { fez } from 'fez-lisp'
116
- fez(`(log! "Hello World!")`, { strings: true }) // Hello World!
116
+ fez(`(log! "Hello World!")`) // Hello World!
117
117
  ```
118
118
 
119
119
  ```js
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.6",
5
+ "version": "1.1.7",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/evaluator.js CHANGED
@@ -13,7 +13,7 @@ export const evaluate = (exp, env) => {
13
13
  throw new ReferenceError(`Undefined variable ${first[VALUE]}`)
14
14
  return word
15
15
  }
16
- case APPLY:
16
+ case APPLY: {
17
17
  const apply = env[first[VALUE]]
18
18
  if (apply == undefined)
19
19
  throw new ReferenceError(
@@ -24,6 +24,7 @@ export const evaluate = (exp, env) => {
24
24
  `${first[VALUE]} is not a (${KEYWORDS.ANONYMOUS_FUNCTION})`
25
25
  )
26
26
  return apply(rest, env)
27
+ }
27
28
  case ATOM:
28
29
  return first[VALUE]
29
30
  default:
@@ -1,6 +1,6 @@
1
1
  import std from '../lib/baked/std.js'
2
2
  import { TYPE, VALUE, WORD, KEYWORDS, APPLY } from './keywords.js'
3
- import { evaluate, isAtom } from './evaluator.js'
3
+ import { evaluate } from './evaluator.js'
4
4
  import { LISP } from './parser.js'
5
5
  import {
6
6
  isEqual,
package/src/keywords.js CHANGED
@@ -1,13 +1,9 @@
1
- // AST enums
2
1
  export const TYPE = 0
3
2
  export const VALUE = 1
4
-
5
3
  export const APPLY = 0
6
4
  export const WORD = 1
7
5
  export const ATOM = 2
8
- // tokeniser enums
9
6
  export const PLACEHOLDER = '.'
10
- // keywords aliases
11
7
  export const KEYWORDS = {
12
8
  NUMBER_TYPE: 'number',
13
9
  STRING_TYPE: 'string',
package/src/utils.js CHANGED
@@ -18,6 +18,7 @@ export const replaceStrings = (source) => {
18
18
  )
19
19
  return source
20
20
  }
21
+ export const replaceQuotes = (source) => source.replaceAll(/\'\(/g, '(array ')
21
22
  export const removeNoCode = (source) =>
22
23
  source
23
24
  .replace(/;.+/g, '')
@@ -72,9 +73,7 @@ export const stringifyArgs = (args) =>
72
73
  export const isForbiddenVariableName = (name) => {
73
74
  switch (name) {
74
75
  case '_':
75
- case KEYWORDS.CAST_TYPE:
76
76
  case KEYWORDS.DEFINE_VARIABLE:
77
- // case KEYWORDS.DESTRUCTURING_ASSIGMENT:
78
77
  return true
79
78
  default:
80
79
  return false
@@ -163,7 +162,7 @@ export const fez = (source, options = {}) => {
163
162
  const env = Object.create(null)
164
163
  try {
165
164
  if (typeof source === 'string') {
166
- if (options.strings) source = replaceStrings(source)
165
+ source = replaceQuotes(replaceStrings(source))
167
166
  let code
168
167
  if (!options.compile)
169
168
  code = handleUnbalancedQuotes(
@@ -249,5 +248,8 @@ export const decompress = (raw) => {
249
248
  export const shake = (parsed, std) => [...treeShake(parsed, std), ...parsed]
250
249
  export const tree = (source, std) =>
251
250
  std
252
- ? shake(LISP.parse(removeNoCode(source)), std)
253
- : LISP.parse(removeNoCode(source))
251
+ ? shake(
252
+ LISP.parse(replaceQuotes(replaceStrings(removeNoCode(source)))),
253
+ std
254
+ )
255
+ : LISP.parse(replaceQuotes(replaceStrings(removeNoCode(source))))