fez-lisp 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.6.5",
5
+ "version": "1.6.7",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/macros.js CHANGED
@@ -31,6 +31,12 @@ export const SUGGAR = {
31
31
  POWER: '**',
32
32
  INTEGER_DEVISION: '//',
33
33
  CONDITION: 'cond',
34
+ BIG_INT: '#i',
35
+ BIG_INT_ADDITION: '#+',
36
+ BIG_INT_SUBTRACTION: '#-',
37
+ BIG_INT_DIVISION: '#/',
38
+ BIG_INT_MULTIPLICATION: '#*',
39
+ NEW_BIG_INTEGER: 'new:big-integer',
34
40
  PROMISES: '*DATA*'
35
41
  }
36
42
  export const deSuggarAst = (ast, scope) => {
@@ -356,6 +362,24 @@ export const deSuggarAst = (ast, scope) => {
356
362
  deSuggarAst(exp, scope)
357
363
  }
358
364
  break
365
+ case SUGGAR.BIG_INT_ADDITION:
366
+ case SUGGAR.BIG_INT_MULTIPLICATION:
367
+ case SUGGAR.BIG_INT_SUBTRACTION:
368
+ case SUGGAR.BIG_INT_DIVISION:
369
+ if (rest.length > 2) {
370
+ exp.length = 0
371
+ rest.reverse()
372
+ let temp = exp
373
+ for (let i = 0; i < rest.length; i += 1) {
374
+ if (i < rest.length - 1) {
375
+ temp.push([APPLY, first[VALUE]], [], rest[i])
376
+ temp = temp.at(-2)
377
+ } else temp.push(...rest[i])
378
+ }
379
+ deSuggarAst(exp, scope)
380
+ }
381
+ break
382
+
359
383
  case KEYWORDS.AND:
360
384
  if (!rest.length) {
361
385
  exp[0][TYPE] = ATOM
@@ -731,9 +755,12 @@ export const replaceQuotes = (source) =>
731
755
  .replaceAll(/\]/g, ')')
732
756
  .replaceAll(/\{/g, `(${SUGGAR.CREATE_LIST} `)
733
757
  .replaceAll(/\}/g, ')')
734
-
758
+ export const replaceBigInteger = (source) =>
759
+ source.replaceAll(/\(#i\s+([0-9]+)\)/g, (_, num) => `(#int "${num}")`)
735
760
  export const deSuggarSource = (source) =>
736
- replaceQuotes(replaceStrings(replaceTemplateLiteralStrings(source)))
761
+ replaceQuotes(
762
+ replaceStrings(replaceTemplateLiteralStrings(replaceBigInteger(source)))
763
+ )
737
764
  export const handleUnbalancedQuotes = (source) => {
738
765
  const diff = (source.match(/\"/g) ?? []).length % 2
739
766
  if (diff !== 0) throw new SyntaxError(`Quotes are unbalanced "`)