fez-lisp 1.5.80 → 1.5.82

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.5.80",
5
+ "version": "1.5.82",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -83,9 +83,10 @@ const fillUknownArgs = (n) =>
83
83
  }))
84
84
  export const formatType = (name, env) => {
85
85
  const stats = env[name][STATS]
86
+ const isAnonymous = typeof name === 'number'
86
87
  return stats
87
88
  ? stats[TYPE_PROP][0] === APPLY
88
- ? `${typeof name !== 'number' ? `${name} ` : ''}(${
89
+ ? `${isAnonymous ? '' : `(let ${name} `}(lambda ${
89
90
  stats[ARG_COUNT] === VARIADIC
90
91
  ? '... ' + STATIC_TYPES.UNKNOWN
91
92
  : (stats[ARGUMENTS] ?? [])
@@ -94,12 +95,18 @@ export const formatType = (name, env) => {
94
95
  `${
95
96
  x[STATS][TYPE_PROP][0] === APPLY
96
97
  ? `${formatType(i, stats[ARGUMENTS])}`
97
- : `${x[STATS][TYPE_PROP].map(toTypeNames).join(' ')}`
98
+ : `${toTypeNames(
99
+ x[STATS][TYPE_PROP][1] ?? x[STATS][TYPE_PROP][0]
100
+ )}`
98
101
  }`
99
102
  )
100
103
  .join(' ')
101
- }) -> ${toTypeNames(stats[RETURNS][1] ?? stats[RETURNS][0])}`
102
- : `${name} ${stats[TYPE_PROP].map(toTypeNames).join(' ')}`.trim()
104
+ } (${KEYWORDS.BLOCK} ${toTypeNames(
105
+ stats[RETURNS][1] ?? stats[RETURNS][0]
106
+ )})${isAnonymous ? '' : ')'})`
107
+ : `(let ${name} ${toTypeNames(
108
+ stats[TYPE_PROP][1] ?? stats[TYPE_PROP][0]
109
+ )})`
103
110
  : name
104
111
  }
105
112
  const formatTypes = (env) => {
@@ -122,7 +129,7 @@ const getScopeNames = (scope) => {
122
129
  }
123
130
  const withScope = (name, scope) => {
124
131
  const chain = getScopeNames(scope)
125
- return `${chain.length === 1 ? '· ' : ''}${chain
132
+ return `${chain.length === 1 ? '; ' : ''}${chain
126
133
  .map((x) => (Number.isInteger(+x) ? '::' : x))
127
134
  .join(' ')} ${name}`
128
135
  }
@@ -221,6 +228,7 @@ export const typeCheck = (ast) => {
221
228
  getSuffix(re[1][VALUE]) === PREDICATE_SUFFIX
222
229
  ) {
223
230
  // ATOM ASSIGMENT PREDICATE ASSIGMENT
231
+ env[name][STATS][TYPE_PROP][1] = [PREDICATE]
224
232
  env[name][STATS][RETURNS] = [ATOM, PREDICATE]
225
233
  }
226
234
  } else if (
@@ -638,6 +646,17 @@ export const typeCheck = (ast) => {
638
646
  )
639
647
  if (isLeaf(returns)) {
640
648
  // TODO figure out what we do here
649
+ // this here is a variable WORD
650
+ // so return type of that function is that varible type
651
+ if (copy[returns[VALUE]])
652
+ ref[STATS][RETURNS] =
653
+ copy[returns[VALUE]][STATS][TYPE_PROP]
654
+ else
655
+ stack.push(() => {
656
+ if (copy[returns[VALUE]])
657
+ ref[STATS][RETURNS] =
658
+ copy[returns[VALUE]][STATS][TYPE_PROP]
659
+ })
641
660
  } else {
642
661
  const ret = returns[0]
643
662
  switch (ret[VALUE]) {
@@ -651,6 +670,7 @@ export const typeCheck = (ast) => {
651
670
  getSuffix(re[0][VALUE]) === PREDICATE_SUFFIX ||
652
671
  getSuffix(re[1][VALUE]) === PREDICATE_SUFFIX
653
672
  ) {
673
+ ref[STATS][TYPE_PROP][1] = PREDICATE
654
674
  ref[STATS][RETURNS][1] = PREDICATE
655
675
  }
656
676
  } else {
@@ -687,6 +707,7 @@ export const typeCheck = (ast) => {
687
707
  ref[STATS][RETURNS] =
688
708
  copy[ret[VALUE]][STATS][RETURNS]
689
709
  })
710
+
690
711
  break
691
712
  }
692
713
  }
package/src/types.js CHANGED
@@ -10,8 +10,8 @@ export const TYPE_PROP = 'type'
10
10
  export const SIGNATURE = 'name'
11
11
  export const ORDER = '__order__'
12
12
  export const VARIABLE_ORDER_INDEX = 'index'
13
- export const PREDICATE = 3
14
- export const COLLECTION = 4
13
+ export const PREDICATE = 4
14
+ export const COLLECTION = 3
15
15
  export const MAX_ARGUMENT_RETRY = 1
16
16
  export const MAX_RETRY_DEFINITION = 10
17
17
  export const toTypeNames = (type) => {
@@ -31,7 +31,7 @@ export const toTypeNames = (type) => {
31
31
  }
32
32
  }
33
33
  export const SPECIAL_FORM_TYPES = {
34
- [SCOPE_NAME]: '·',
34
+ [SCOPE_NAME]: ';',
35
35
  [ORDER]: 0,
36
36
  [toTypeNames(APPLY)]: {
37
37
  [STATS]: {