aontu 0.30.2 → 0.32.1

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.
Files changed (63) hide show
  1. package/dist/aontu.js +1 -0
  2. package/dist/aontu.js.map +1 -1
  3. package/dist/ctx.d.ts +3 -2
  4. package/dist/ctx.js +3 -2
  5. package/dist/ctx.js.map +1 -1
  6. package/dist/hints.js +7 -1
  7. package/dist/hints.js.map +1 -1
  8. package/dist/unify.js +14 -8
  9. package/dist/unify.js.map +1 -1
  10. package/dist/utility.js +17 -7
  11. package/dist/utility.js.map +1 -1
  12. package/dist/val/ConjunctVal.js +4 -4
  13. package/dist/val/ConjunctVal.js.map +1 -1
  14. package/dist/val/CopyFuncVal.d.ts +2 -1
  15. package/dist/val/CopyFuncVal.js +14 -6
  16. package/dist/val/CopyFuncVal.js.map +1 -1
  17. package/dist/val/FuncBaseVal.d.ts +2 -2
  18. package/dist/val/FuncBaseVal.js +22 -18
  19. package/dist/val/FuncBaseVal.js.map +1 -1
  20. package/dist/val/JunctionVal.js +2 -2
  21. package/dist/val/JunctionVal.js.map +1 -1
  22. package/dist/val/KeyFuncVal.d.ts +1 -0
  23. package/dist/val/KeyFuncVal.js +36 -6
  24. package/dist/val/KeyFuncVal.js.map +1 -1
  25. package/dist/val/ListVal.js +10 -1
  26. package/dist/val/ListVal.js.map +1 -1
  27. package/dist/val/MapVal.d.ts +1 -1
  28. package/dist/val/MapVal.js +42 -8
  29. package/dist/val/MapVal.js.map +1 -1
  30. package/dist/val/MoveFuncVal.d.ts +1 -0
  31. package/dist/val/MoveFuncVal.js +11 -8
  32. package/dist/val/MoveFuncVal.js.map +1 -1
  33. package/dist/val/PrefVal.js +19 -11
  34. package/dist/val/PrefVal.js.map +1 -1
  35. package/dist/val/RefVal.js +50 -16
  36. package/dist/val/RefVal.js.map +1 -1
  37. package/dist/val/ScalarVal.js +1 -0
  38. package/dist/val/ScalarVal.js.map +1 -1
  39. package/dist/val/TopVal.d.ts +1 -1
  40. package/dist/val/TopVal.js +2 -2
  41. package/dist/val/TopVal.js.map +1 -1
  42. package/dist/val/Val.d.ts +3 -2
  43. package/dist/val/Val.js +37 -18
  44. package/dist/val/Val.js.map +1 -1
  45. package/package.json +1 -2
  46. package/src/aontu.ts +1 -0
  47. package/src/ctx.ts +6 -4
  48. package/src/hints.ts +11 -1
  49. package/src/unify.ts +17 -9
  50. package/src/utility.ts +19 -9
  51. package/src/val/ConjunctVal.ts +5 -5
  52. package/src/val/CopyFuncVal.ts +20 -7
  53. package/src/val/FuncBaseVal.ts +30 -24
  54. package/src/val/JunctionVal.ts +2 -2
  55. package/src/val/KeyFuncVal.ts +42 -6
  56. package/src/val/ListVal.ts +14 -1
  57. package/src/val/MapVal.ts +63 -9
  58. package/src/val/MoveFuncVal.ts +12 -8
  59. package/src/val/PrefVal.ts +25 -14
  60. package/src/val/RefVal.ts +69 -17
  61. package/src/val/ScalarVal.ts +2 -0
  62. package/src/val/TopVal.ts +2 -2
  63. package/src/val/Val.ts +42 -18
package/src/val/TopVal.ts CHANGED
@@ -43,8 +43,8 @@ class TopVal extends Val {
43
43
  return peer.isTop
44
44
  }
45
45
 
46
- unify(peer: Val, _ctx?: AontuContext): Val {
47
- return peer
46
+ unify(peer: Val, ctx: AontuContext): Val {
47
+ return peer.unify(this, ctx)
48
48
  }
49
49
 
50
50
  get canon() { return 'top' }
package/src/val/Val.ts CHANGED
@@ -38,8 +38,6 @@ type ValSpec = {
38
38
  prefix?: boolean,
39
39
  }
40
40
 
41
- // import { AontuError, descErr, makeNilErr } from '../err'
42
- // import { AontuError } from '../err'
43
41
 
44
42
 
45
43
  const DONE = -1
@@ -155,11 +153,16 @@ abstract class Val {
155
153
  clone(ctx: AontuContext, spec?: ValSpec): Val {
156
154
  let cloneCtx
157
155
 
158
- let cut = this.path.indexOf('&')
159
- cut = -1 < cut ? cut + 1 : ctx.path.length
160
- cloneCtx = ctx.clone({
161
- path: ctx.path.concat(this.path.slice(cut))
162
- })
156
+ let path = spec?.path
157
+ if (null == path) {
158
+ let cut = this.path.indexOf('&')
159
+ cut = -1 < cut ? cut + 1 : ctx.path.length
160
+ path = ctx.path.concat(this.path.slice(cut))
161
+ }
162
+ // console.log('CLONE', path, this.canon)
163
+ // console.trace()
164
+
165
+ cloneCtx = ctx.clone({ path })
163
166
 
164
167
  let fullspec = {
165
168
  peg: this.peg,
@@ -170,11 +173,13 @@ abstract class Val {
170
173
  let out = new (this as any)
171
174
  .constructor(fullspec, cloneCtx)
172
175
 
176
+ out.dc = this.done ? DONE : out.dc
177
+
173
178
  out.site.row = spec?.row ?? this.site.row ?? -1
174
179
  out.site.col = spec?.col ?? this.site.col ?? -1
175
180
  out.site.url = spec?.url ?? this.site.url ?? ''
176
181
 
177
- // TODO: should not be needed - update all VAL ctors to handle spec.mark
182
+ out.mark = Object.assign({}, this.mark, fullspec.mark ?? {})
178
183
  out.mark.type = this.mark.type && (fullspec.mark?.type ?? true)
179
184
  out.mark.hide = this.mark.hide && (fullspec.mark?.hide ?? true)
180
185
 
@@ -215,7 +220,12 @@ abstract class Val {
215
220
  abstract superior(): Val
216
221
 
217
222
 
218
- [inspect.custom](_d: number, _o: any, _inspect: any): string {
223
+ [inspect.custom](d: number, _opts: any, _inspect: any) {
224
+ return this.inspect(d)
225
+ }
226
+
227
+ inspect(d?: number): string {
228
+ d = null == d ? -1 : d
219
229
  let s = ['<' + this.constructor.name.replace(/Val$/, '') + '/' + this.id]
220
230
 
221
231
  s.push('/' + this.path.join('.') + '/')
@@ -225,21 +235,26 @@ abstract class Val {
225
235
  ...Object.entries(this.mark).filter(n => n[1]).map(n => n[0]).sort()
226
236
  ].filter(n => null != n).join(','))
227
237
 
228
- let insp = this.inspection(inspect)
238
+ // let insp = this.inspection(inspect)
239
+ let insp = this.inspection(1 + d)
229
240
  if (null != insp && '' != insp) {
230
241
  s.push('/' + insp)
231
242
  }
232
243
 
233
244
  s.push('/')
234
245
 
235
- if ('object' === typeof this.peg) {
236
- s.push(inspectpeg(this.peg))
246
+ if (this.peg?.isVal) {
247
+ s.push(this.peg.inspect(1 + d))
248
+ }
249
+ else if (null != this.peg && 'object' === typeof this.peg &&
250
+ (Object.entries(this.peg)[0]?.[1] as any)?.isVal) {
251
+ s.push(inspectpeg(this.peg, 1 + d))
237
252
  }
238
253
  else if ('function' === typeof this.peg) {
239
254
  s.push(this.peg.name)
240
255
  }
241
256
  else {
242
- s.push(this.peg)
257
+ s.push(this.peg?.toString?.() ?? '')
243
258
  }
244
259
 
245
260
  s.push('>')
@@ -250,23 +265,32 @@ abstract class Val {
250
265
  }
251
266
 
252
267
 
253
- inspection(_inspect: Function) {
268
+ inspection(_d?: number) {
254
269
  return ''
255
270
  }
256
271
 
257
272
  }
258
273
 
259
274
 
260
- function inspectpeg(peg: any) {
261
- return pretty(!Array.isArray(peg) ? inspect(peg) :
262
- ('[' + peg.map(n => inspect(n)).join(',\n') + ']'))
275
+ function inspectpeg(peg: any, d: number) {
276
+ const indent = ' '.repeat(d)
277
+ return pretty(Array.isArray(peg) ?
278
+ ('[' + peg.map(n => '\n ' + indent + (n.inspect?.(d) ?? n)).join(',') +
279
+ '\n' + indent + ']') :
280
+ ('{' +
281
+ Object.entries(peg).map((n: any) =>
282
+ '\n ' + indent + n[0] + ': ' + // n[1].inspect(d)
283
+ (n[1].inspect(d) ?? '' + n[1])
284
+ ).join(',') +
285
+ '\n' + indent + '}')
286
+ )
263
287
  }
264
288
 
265
289
  function pretty(s: string) {
266
290
  return (
267
291
  (String(s))
268
292
  .replace(/\[Object: null prototype\]/g, '')
269
- .replace(/\s+/g, '')
293
+ // .replace(/([^\n]) +/g, '$1')
270
294
  )
271
295
  }
272
296