fez-lisp 1.0.33 → 1.0.34

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.0.33",
5
+ "version": "1.0.34",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "prettier": {
20
20
  "semi": false,
21
- "singleQuote": true
21
+ "singleQuote": true,
22
+ "trailingComma": "none"
22
23
  },
23
24
  "scripts": {
24
25
  "build": "node ./lib/builder.js",
package/src/compiler.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  KEYWORDS,
6
6
  TYPE,
7
7
  VALUE,
8
- WORD,
8
+ WORD
9
9
  } from './enums.js'
10
10
  import { leaf, isLeaf } from './parser.js'
11
11
  import { deepRename, lispToJavaScriptVariableName } from './utils.js'
@@ -85,7 +85,7 @@ return result
85
85
  default:
86
86
  return 0
87
87
  }
88
- }`,
88
+ }`
89
89
  }
90
90
  const semiColumnEdgeCases = new Set([
91
91
  ';)',
@@ -105,7 +105,7 @@ const semiColumnEdgeCases = new Set([
105
105
  ';?',
106
106
  ',,',
107
107
  ';;',
108
- ';]',
108
+ ';]'
109
109
  ])
110
110
 
111
111
  const parse = (Arguments, Drill) => Arguments.map((x) => compile(x, Drill))
package/src/enums.js CHANGED
@@ -79,5 +79,5 @@ export const KEYWORDS = {
79
79
  CLEAR_CONSOLE: 'clear!',
80
80
  SET_ARRAY: 'array:set!',
81
81
 
82
- DOC: 'fez-manual',
82
+ DOC: 'fez-manual'
83
83
  }
@@ -114,7 +114,7 @@ const keywords = {
114
114
  for (let i = 0; i < props.length; ++i) {
115
115
  Object.defineProperty(localEnv, params[i][VALUE], {
116
116
  value: evaluate(props[i], scope),
117
- writable: true,
117
+ writable: true
118
118
  })
119
119
  }
120
120
  return evaluate(body, localEnv)
@@ -177,7 +177,7 @@ const keywords = {
177
177
  name = word[VALUE]
178
178
  Object.defineProperty(env, name, {
179
179
  value: evaluate(args[1], env),
180
- writable: false,
180
+ writable: false
181
181
  })
182
182
  return env[name]
183
183
  },
@@ -269,7 +269,7 @@ const keywords = {
269
269
  for (let i = 0; i < props.length; ++i) {
270
270
  Object.defineProperty(localEnv, params[i][VALUE], {
271
271
  value: evaluate(props[i], scope),
272
- writable: true,
272
+ writable: true
273
273
  })
274
274
  }
275
275
  return evaluate(body, localEnv)
@@ -295,7 +295,6 @@ const keywords = {
295
295
  ? console.log(
296
296
  '\x1b[31m',
297
297
  `${describe} Failed:\n`,
298
-
299
298
  `${rest[0]} => ${stringify(rest[1])} != ${stringify(rest[2])}`,
300
299
  '\n',
301
300
  '\x1b[0m'
@@ -341,7 +340,7 @@ const keywords = {
341
340
  [KEYWORDS.CLEAR_CONSOLE]: (args) => {
342
341
  console.clear()
343
342
  return 0
344
- },
343
+ }
345
344
  }
346
345
  keywords[KEYWORDS.NOT_COMPILED_BLOCK] = keywords[KEYWORDS.BLOCK]
347
346
  keywords[KEYWORDS.DOC] = (args, env) => {
package/src/tokeniser.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  isEqual,
7
7
  isEqualTypes,
8
8
  isForbiddenVariableName,
9
- stringifyArgs,
9
+ stringifyArgs
10
10
  } from './utils.js'
11
11
 
12
12
  const keywords = {
@@ -405,7 +405,7 @@ const keywords = {
405
405
  for (let i = 0; i < props.length; ++i) {
406
406
  Object.defineProperty(localEnv, params[i][VALUE], {
407
407
  value: evaluate(props[i], scope),
408
- writable: true,
408
+ writable: true
409
409
  })
410
410
  }
411
411
  return evaluate(body, localEnv)
@@ -631,7 +631,7 @@ const keywords = {
631
631
  name = word[VALUE]
632
632
  Object.defineProperty(env, name, {
633
633
  value: evaluate(args[1], env),
634
- writable: false,
634
+ writable: false
635
635
  })
636
636
  return env[name]
637
637
  },
@@ -931,7 +931,7 @@ const keywords = {
931
931
  for (let i = 0; i < props.length; ++i) {
932
932
  Object.defineProperty(localEnv, params[i][VALUE], {
933
933
  value: evaluate(props[i], scope),
934
- writable: true,
934
+ writable: true
935
935
  })
936
936
  }
937
937
  return evaluate(body, localEnv)
@@ -966,13 +966,22 @@ const keywords = {
966
966
  [KEYWORDS.TEST_BED]: (args, env) => {
967
967
  let tests = []
968
968
  try {
969
+ if (
970
+ args.some(
971
+ ([[type, car]]) => !(type === APPLY && car === KEYWORDS.TEST_CASE)
972
+ )
973
+ )
974
+ throw new TypeError(
975
+ `Arguments of (${KEYWORDS.TEST_BED}) must be (${
976
+ KEYWORDS.TEST_CASE
977
+ }) (${KEYWORDS.TEST_BED} ${stringifyArgs(args)})`
978
+ )
969
979
  tests = args.map((x) => evaluate(x, env))
970
980
  tests.forEach(([state, describe, ...rest]) =>
971
981
  !state
972
982
  ? console.log(
973
983
  '\x1b[31m',
974
984
  `${describe} Failed:\n`,
975
-
976
985
  `${rest[0]} => ${stringify(rest[1])} != ${stringify(rest[2])}`,
977
986
  '\n',
978
987
  '\x1b[0m'
@@ -1090,7 +1099,7 @@ const keywords = {
1090
1099
  )
1091
1100
  console.clear()
1092
1101
  return 0
1093
- },
1102
+ }
1094
1103
  }
1095
1104
  keywords[KEYWORDS.NOT_COMPILED_BLOCK] = keywords[KEYWORDS.BLOCK]
1096
1105
  keywords[KEYWORDS.DOC] = (args, env) => {
package/src/utils.js CHANGED
@@ -8,7 +8,8 @@ export const logError = (error) => console.log('\x1b[31m', error, '\x1b[0m')
8
8
  export const logSuccess = (output) => console.log(output, '\x1b[0m')
9
9
  export const removeNoCode = (source) =>
10
10
  source
11
- .replace(/;.+/g, '')
11
+ // .replace(/;.+/g, '')
12
+ .replace(/;(?=(?:(?:[^"]*"){2})*[^"]*$).+/g, '')
12
13
  .replace(/[\s\s]+(?=[^"]*(?:"[^"]*"[^"]*)*$)/g, ' ')
13
14
  .trim()
14
15
  export const isBalancedParenthesis = (sourceCode) => {