aontu 0.28.0 → 0.30.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 (89) hide show
  1. package/dist/aontu.d.ts +17 -10
  2. package/dist/aontu.js +149 -57
  3. package/dist/aontu.js.map +1 -1
  4. package/package.json +18 -34
  5. package/aontu.ts +0 -81
  6. package/dist/lib/err.d.ts +0 -3
  7. package/dist/lib/err.js +0 -91
  8. package/dist/lib/err.js.map +0 -1
  9. package/dist/lib/lang.d.ts +0 -15
  10. package/dist/lib/lang.js +0 -409
  11. package/dist/lib/lang.js.map +0 -1
  12. package/dist/lib/op/disjunct.d.ts +0 -3
  13. package/dist/lib/op/disjunct.js +0 -28
  14. package/dist/lib/op/disjunct.js.map +0 -1
  15. package/dist/lib/op/op.d.ts +0 -6
  16. package/dist/lib/op/op.js +0 -9
  17. package/dist/lib/op/op.js.map +0 -1
  18. package/dist/lib/op/unite.d.ts +0 -3
  19. package/dist/lib/op/unite.js +0 -100
  20. package/dist/lib/op/unite.js.map +0 -1
  21. package/dist/lib/type.d.ts +0 -40
  22. package/dist/lib/type.js +0 -7
  23. package/dist/lib/type.js.map +0 -1
  24. package/dist/lib/unify.d.ts +0 -35
  25. package/dist/lib/unify.js +0 -72
  26. package/dist/lib/unify.js.map +0 -1
  27. package/dist/lib/utility.d.ts +0 -3
  28. package/dist/lib/utility.js +0 -16
  29. package/dist/lib/utility.js.map +0 -1
  30. package/dist/lib/val/ConjunctVal.d.ts +0 -17
  31. package/dist/lib/val/ConjunctVal.js +0 -196
  32. package/dist/lib/val/ConjunctVal.js.map +0 -1
  33. package/dist/lib/val/DisjunctVal.d.ts +0 -17
  34. package/dist/lib/val/DisjunctVal.js +0 -100
  35. package/dist/lib/val/DisjunctVal.js.map +0 -1
  36. package/dist/lib/val/ListVal.d.ts +0 -18
  37. package/dist/lib/val/ListVal.js +0 -120
  38. package/dist/lib/val/ListVal.js.map +0 -1
  39. package/dist/lib/val/MapVal.d.ts +0 -18
  40. package/dist/lib/val/MapVal.js +0 -144
  41. package/dist/lib/val/MapVal.js.map +0 -1
  42. package/dist/lib/val/Nil.d.ts +0 -22
  43. package/dist/lib/val/Nil.js +0 -84
  44. package/dist/lib/val/Nil.js.map +0 -1
  45. package/dist/lib/val/NullVal.d.ts +0 -15
  46. package/dist/lib/val/NullVal.js +0 -39
  47. package/dist/lib/val/NullVal.js.map +0 -1
  48. package/dist/lib/val/OpVal.d.ts +0 -17
  49. package/dist/lib/val/OpVal.js +0 -89
  50. package/dist/lib/val/OpVal.js.map +0 -1
  51. package/dist/lib/val/PlusVal.d.ts +0 -12
  52. package/dist/lib/val/PlusVal.js +0 -32
  53. package/dist/lib/val/PlusVal.js.map +0 -1
  54. package/dist/lib/val/PrefVal.d.ts +0 -17
  55. package/dist/lib/val/PrefVal.js +0 -87
  56. package/dist/lib/val/PrefVal.js.map +0 -1
  57. package/dist/lib/val/RefVal.d.ts +0 -22
  58. package/dist/lib/val/RefVal.js +0 -256
  59. package/dist/lib/val/RefVal.js.map +0 -1
  60. package/dist/lib/val/ValBase.d.ts +0 -26
  61. package/dist/lib/val/ValBase.js +0 -77
  62. package/dist/lib/val/ValBase.js.map +0 -1
  63. package/dist/lib/val/VarVal.d.ts +0 -15
  64. package/dist/lib/val/VarVal.js +0 -84
  65. package/dist/lib/val/VarVal.js.map +0 -1
  66. package/dist/lib/val.d.ts +0 -81
  67. package/dist/lib/val.js +0 -191
  68. package/dist/lib/val.js.map +0 -1
  69. package/lib/err.ts +0 -111
  70. package/lib/lang.ts +0 -586
  71. package/lib/op/disjunct.ts +0 -52
  72. package/lib/op/op.ts +0 -19
  73. package/lib/op/unite.ts +0 -143
  74. package/lib/type.ts +0 -83
  75. package/lib/unify.ts +0 -144
  76. package/lib/utility.ts +0 -23
  77. package/lib/val/ConjunctVal.ts +0 -300
  78. package/lib/val/DisjunctVal.ts +0 -170
  79. package/lib/val/ListVal.ts +0 -196
  80. package/lib/val/MapVal.ts +0 -217
  81. package/lib/val/Nil.ts +0 -144
  82. package/lib/val/NullVal.ts +0 -74
  83. package/lib/val/OpVal.ts +0 -159
  84. package/lib/val/PlusVal.ts +0 -76
  85. package/lib/val/PrefVal.ts +0 -154
  86. package/lib/val/RefVal.ts +0 -380
  87. package/lib/val/ValBase.ts +0 -109
  88. package/lib/val/VarVal.ts +0 -156
  89. package/lib/val.ts +0 -326
package/lib/op/unite.ts DELETED
@@ -1,143 +0,0 @@
1
- /* Copyright (c) 2021-2023 Richard Rodger, MIT License */
2
-
3
-
4
-
5
- import type { Val } from '../type'
6
-
7
- import { DONE } from '../type'
8
- import { Context } from '../unify'
9
-
10
-
11
- import { ConjunctVal } from '../val/ConjunctVal'
12
- import { DisjunctVal } from '../val/DisjunctVal'
13
- import { ListVal } from '../val/ListVal'
14
- import { MapVal } from '../val/MapVal'
15
- import { Nil } from '../val/Nil'
16
- import { PrefVal } from '../val/PrefVal'
17
- import { RefVal } from '../val/RefVal'
18
- import { ValBase } from '../val/ValBase'
19
-
20
-
21
- import {
22
- TOP,
23
- } from '../val'
24
-
25
-
26
- import { Operation } from './op'
27
-
28
-
29
- let uc = 0
30
-
31
-
32
- // Vals should only have to unify downwards (in .unify) over Vals they understand.
33
- // and for complex Vals, TOP, which means self unify if not yet done
34
- const unite: Operation = (ctx: Context, a?: any, b?: any, whence?: string) => {
35
- let out = a
36
- let why = 'u'
37
- // console.log('AA OP unite IN', a?.canon, b?.canon,
38
- // 'W', whence,
39
- // 'E', 0 < ctx?.err?.length ? ctx.err.map((e: Val) => e.canon) : '')
40
-
41
- let unified = false
42
-
43
- if (b && (TOP === a || !a)) {
44
- //console.log('Utb', b.canon)
45
- out = b
46
- why = 'b'
47
- }
48
-
49
- else if (a && (TOP === b || !b)) {
50
- //console.log('Uta', a.canon)
51
- out = a
52
- why = 'a'
53
- }
54
-
55
- else if (a && b && TOP !== b) {
56
- if (a.isNil) {
57
- out = update(a, b)
58
- why = 'an'
59
- }
60
- else if (b.isNil) {
61
- out = update(b, a)
62
- why = 'bn'
63
- }
64
- else if (a.isConjunctVal) {
65
- // console.log('Q', a.canon, b.canon)
66
- out = a.unify(b, ctx)
67
- unified = true
68
- why = 'acj'
69
- }
70
- else if (
71
- b.isConjunctVal ||
72
- b.isDisjunctVal ||
73
- b.isRefVal ||
74
- b.isPrefVal
75
- ) {
76
-
77
- // console.log('U', a.canon, b.canon)
78
- // return b.unify(a, ctx)
79
- out = b.unify(a, ctx)
80
- unified = true
81
- // console.log('UO', out.canon)
82
- why = 'bv'
83
- }
84
-
85
- // Exactly equal scalars.
86
- else if (a.constructor === b.constructor && a.peg === b.peg) {
87
- out = update(a, b)
88
- why = 'up'
89
- }
90
-
91
- else {
92
- // console.log('QQQ')
93
- out = a.unify(b, ctx)
94
- unified = true
95
- why = 'ab'
96
- }
97
- }
98
-
99
- if (!out || !out.unify) {
100
- out = Nil.make(ctx, 'unite', a, b)
101
- why += 'N'
102
- }
103
-
104
- if (DONE !== out.done && !unified) {
105
- out = out.unify(TOP, ctx)
106
- why += 'T'
107
- }
108
-
109
- // console.log('AA OP unite OUT', a?.canon, b?.canon, '->', out && out.canon,
110
- // 0 < ctx?.err?.length ? ctx.err.map((e: Val) => e.canon) : '')
111
-
112
- uc++
113
-
114
- // TODO: KEEP THIS! print in debug mode! push to ctx.log?
115
- /*
116
- console.log(
117
- 'U',
118
- ('' + ctx.cc).padStart(2),
119
- ('' + uc).padStart(4),
120
- (whence || '').substring(0, 16).padEnd(16),
121
- why.padEnd(6),
122
- ctx.path.join('.').padEnd(16),
123
- (a || '').constructor.name.substring(0, 3),
124
- '&',
125
- (b || '').constructor.name.substring(0, 3),
126
- '|',
127
- ' '.repeat(ctx.path.length),
128
- a?.canon, '&', b?.canon, '->', out.canon)
129
- */
130
-
131
- return out
132
- }
133
-
134
-
135
- function update(x: Val, _y: Val) {
136
- // TODO: update x with y.site
137
- return x
138
- }
139
-
140
-
141
- export {
142
- unite
143
- }
package/lib/type.ts DELETED
@@ -1,83 +0,0 @@
1
- /* Copyright (c) 2022-2023 Richard Rodger, MIT License */
2
-
3
-
4
- // TODO: refactor these out
5
-
6
- import { Resolver } from '@jsonic/multisource'
7
-
8
- import { Context } from './unify'
9
-
10
- import {
11
- Site
12
- } from './lang'
13
-
14
-
15
-
16
- type Options = {
17
- src: string // Source text.
18
- print: number // Print debug verbosity
19
- resolver?: Resolver // Source resolver
20
- base?: string // Base path for resolver
21
- path?: string // Path of entry file
22
- debug?: boolean
23
- trace?: boolean
24
- }
25
-
26
-
27
-
28
-
29
- interface Val {
30
- isVal: boolean
31
-
32
- id: number
33
- done: number
34
- path: string[]
35
- row: number
36
- col: number
37
- url: string
38
-
39
- top: boolean
40
-
41
- // Actual native value.
42
- peg: any
43
-
44
- // TODO: used for top level result - not great
45
- err: any[]
46
- deps?: any
47
-
48
- same(peer: Val): boolean
49
-
50
- // TODO: reverse args, as spec is mostly only used internally?
51
- clone(spec?: ValSpec, ctx?: Context): Val
52
-
53
- // get site(): Site
54
- unify(peer: Val, ctx?: Context): Val
55
- get canon(): string
56
- gen(ctx?: Context): any
57
- }
58
-
59
- type ValSpec = {
60
- peg?: any,
61
- [name: string]: any,
62
- } | null
63
- type ValMap = { [key: string]: Val }
64
- type ValList = Val[]
65
-
66
-
67
-
68
- const DONE = -1
69
-
70
-
71
- export type {
72
- Val,
73
- ValSpec,
74
- ValMap,
75
- ValList,
76
- Options,
77
- }
78
-
79
- export {
80
- DONE,
81
- Resolver,
82
- }
83
-
package/lib/unify.ts DELETED
@@ -1,144 +0,0 @@
1
- /* Copyright (c) 2021-2023 Richard Rodger, MIT License */
2
-
3
-
4
- import type { Val } from './type'
5
-
6
- import { DONE, } from './type'
7
-
8
-
9
- import {
10
- TOP
11
- } from './val'
12
-
13
- import {
14
- Lang
15
- } from './lang'
16
-
17
- import {
18
- unite
19
- } from './op/op'
20
-
21
-
22
-
23
-
24
-
25
- // import { MapVal } from '../lib/val/MapVal'
26
- // import { RefVal } from '../lib/val/RefVal'
27
- import { Nil } from '../lib/val/Nil'
28
-
29
-
30
- type Path = string[]
31
-
32
-
33
-
34
- class Context {
35
- root: Val // Starting Val, root of paths.
36
- path: Path // Path to current Val.
37
- err: Nil[] // Nil error log of current unify.
38
- vc: number // Val counter to create unique val ids.
39
- cc: number = -1
40
- var: Record<string, Val> = {}
41
-
42
- constructor(cfg: {
43
- root: Val,
44
- path?: Path,
45
- err?: Nil[],
46
- vc?: number,
47
- cc?: number,
48
- var?: Record<string, Val>
49
- }) {
50
- this.root = cfg.root
51
- this.path = cfg.path || []
52
- this.err = cfg.err || []
53
-
54
- // Multiple unify passes will keep incrementing Val counter.
55
- this.vc = null == cfg.vc ? 1_000_000_000 : cfg.vc
56
-
57
- this.cc = null == cfg.cc ? this.cc : cfg.cc
58
-
59
- this.var = cfg.var || this.var
60
- }
61
-
62
-
63
- clone(cfg: {
64
- root?: Val,
65
- path?: Path,
66
- err?: Nil[],
67
- }): Context {
68
- return new Context({
69
- root: cfg.root || this.root,
70
- path: cfg.path,
71
- err: cfg.err || this.err,
72
- vc: this.vc,
73
- cc: this.cc,
74
- var: { ...this.var },
75
- })
76
- }
77
-
78
-
79
- descend(key: string): Context {
80
- return this.clone({
81
- root: this.root,
82
- path: this.path.concat(key),
83
- })
84
- }
85
- }
86
-
87
-
88
- class Unify {
89
- root: Val
90
- res: Val
91
- err: Nil[]
92
- cc: number
93
- lang: Lang
94
-
95
- constructor(root: Val | string, lang?: Lang, ctx?: Context) {
96
- // console.log('ROOT-A', root)
97
-
98
- this.lang = lang || new Lang()
99
- if ('string' === typeof root) {
100
- root = this.lang.parse(root)
101
- }
102
-
103
- // console.log('ROOT-B', root)
104
-
105
- this.cc = 0
106
- this.root = root
107
- this.res = root
108
- this.err = root.err || []
109
-
110
- let res = root
111
-
112
- // Only unify if no syntax errors
113
- if (!(root as Nil).nil) {
114
- ctx = ctx || new Context({
115
- root: res,
116
- err: this.err,
117
- })
118
-
119
-
120
- // TODO: derive maxdc from res deterministically
121
- // perhaps parse should count intial vals, paths, etc?
122
-
123
-
124
- let maxdc = 9 // 99
125
- for (; this.cc < maxdc && DONE !== res.done; this.cc++) {
126
- ctx.cc = this.cc
127
- res = unite(ctx, res, TOP)
128
- ctx = ctx.clone({ root: res })
129
-
130
- // console.log('==============', this.cc)
131
- }
132
- }
133
-
134
-
135
- this.res = res
136
- }
137
- }
138
-
139
-
140
- export {
141
- Context,
142
- Path,
143
- Unify,
144
- }
package/lib/utility.ts DELETED
@@ -1,23 +0,0 @@
1
- /* Copyright (c) 2023 Richard Rodger, MIT License */
2
-
3
-
4
- import type { Val } from './type'
5
-
6
- function formatPath(path: Val | string[], absolute?: boolean) {
7
- let parts: string[]
8
- if (Array.isArray(path)) {
9
- parts = path
10
- }
11
- else {
12
- parts = path.path
13
- }
14
-
15
- let pathstr = (0 < parts.length && false !== absolute ? '$.' : '') + parts.join('.')
16
-
17
- return pathstr
18
- }
19
-
20
- export {
21
- formatPath
22
- }
23
-
@@ -1,300 +0,0 @@
1
- /* Copyright (c) 2021-2023 Richard Rodger, MIT License */
2
-
3
-
4
- import type {
5
- Val,
6
- ValSpec,
7
- } from '../type'
8
-
9
- import {
10
- DONE,
11
- } from '../type'
12
-
13
- import {
14
- descErr
15
- } from '../err'
16
-
17
- import {
18
- Context,
19
- } from '../unify'
20
-
21
-
22
-
23
- import {
24
- unite
25
- } from '../op/op'
26
-
27
-
28
- import { TOP } from '../val'
29
- // import { DisjunctVal } from '../val/DisjunctVal'
30
- import { ListVal } from '../val/ListVal'
31
- import { MapVal } from '../val/MapVal'
32
- import { Nil } from '../val/Nil'
33
- // import { PrefVal } from '../val/PrefVal'
34
- import { RefVal } from '../val/RefVal'
35
- import { ValBase } from '../val/ValBase'
36
-
37
-
38
- // TODO: move main logic to op/conjunct
39
- class ConjunctVal extends ValBase {
40
- isBinaryOp = true
41
- isConjunctVal = true
42
-
43
- constructor(
44
- spec: {
45
- peg: Val[]
46
- },
47
- ctx?: Context
48
- ) {
49
- super(spec, ctx)
50
- // console.log('NEWCJ')
51
- // console.trace()
52
- }
53
-
54
- // NOTE: mutation!
55
- append(peer: Val): ConjunctVal {
56
- this.peg.push(peer)
57
- return this
58
- }
59
-
60
- unify(peer: Val, ctx: Context): Val {
61
- // console.log('CONJUNCT UNIFY', this.done, this.path.join('.'), this.canon,
62
- // 'P', peer.top || peer.constructor.name,
63
- // peer.done, peer.path.join('.'), peer.canon)
64
-
65
-
66
- const mark = (Math.random() * 1e7) % 1e6 | 0
67
- // console.log('CONJUNCT unify', mark, this.done, this.canon, 'peer=', peer.canon)
68
-
69
- let done = true
70
-
71
- // Unify each term of conjunct against peer
72
- let upeer: Val[] = []
73
-
74
-
75
- // console.log('CJa' + mark, this.peg.map((p: Val) => p.canon), 'p=', peer.canon)
76
- for (let vI = 0; vI < this.peg.length; vI++) {
77
- upeer[vI] = unite(ctx, this.peg[vI], peer, 'cj-own' + mark)
78
-
79
- // let prevdone = done
80
- done = done && (DONE === upeer[vI].done)
81
-
82
- // console.log('CONJUNCT pud', mark, vI, done, prevdone, '|', upeer[vI].done, upeer[vI].canon)
83
-
84
- if (upeer[vI] instanceof Nil) {
85
- return Nil.make(
86
- ctx,
87
- '&peer[' + upeer[vI].canon + ',' + peer.canon + ']',
88
- this.peg[vI],
89
- peer
90
- )
91
- }
92
- }
93
-
94
- upeer = norm(upeer)
95
-
96
- // console.log('CONJUNCT upeer', this.id, mark, this.done, done, upeer.map(p => p.canon))
97
-
98
- upeer.sort((a: Val, b: Val) => {
99
- return (a.constructor.name === b.constructor.name) ? 0 :
100
- (a.constructor.name < b.constructor.name ? -1 : 1)
101
- })
102
-
103
- // console.log('CONJUNCT upeer sort', this.id, mark, this.done, done, upeer.map(p => p.canon))
104
-
105
- // Unify terms against each other
106
-
107
- let outvals: Val[] = []
108
- let val: Val
109
-
110
-
111
- // for (let pI = 0; pI < upeer.length; pI++) {
112
- // let pt = upeer[pI]
113
- // for (let qI = pI; qI < upeer.length; qI++) {
114
- // let qt = upeer[pI]
115
-
116
- // let pq = unite(ctx, pt, qt, 'cj-pq')
117
-
118
- // }
119
- // }
120
-
121
-
122
- // console.log('CJ upeer', mark, upeer.map(v => v.canon))
123
-
124
- let t0 = upeer[0]
125
-
126
- next_term:
127
- for (let pI = 0; pI < upeer.length; pI++) {
128
- // console.log('CJ TERM t0', pI, t0.done, t0.canon)
129
-
130
- if (DONE !== t0.done) {
131
- let u0 = unite(ctx, t0, TOP, 'cj-peer-t0')
132
-
133
- if (
134
- DONE !== u0.done
135
-
136
- // Maps and Lists are still unified so that path refs will work
137
- // TODO: || ListVal - test!
138
- && !(
139
- u0 instanceof MapVal
140
- || u0 instanceof ListVal
141
- || u0 instanceof RefVal
142
- )
143
- ) {
144
-
145
- // console.log('CONJUNCT PUSH A', u0.id, u0.canon)
146
- outvals.push(u0)
147
- // console.log('CJ outvals A', outvals.map(v => v.canon))
148
- continue next_term
149
- }
150
- else {
151
- t0 = u0
152
- }
153
- }
154
-
155
- let t1 = upeer[pI + 1]
156
- // console.log('CJ TERM t1', pI + 1, t1?.done, t1?.canon)
157
-
158
- if (null == t1) {
159
- // console.log('CONJUNCT PUSH B', t0.canon)
160
- outvals.push(t0)
161
- // console.log('CJ outvals B', outvals.map(v => v.canon))
162
- }
163
-
164
- // Can't unite with a RefVal, unless also a RefVal with same path.
165
- else if (t0 instanceof RefVal && !(t1 instanceof RefVal)) {
166
- // console.log('CONJUNCT PUSH D', t0.canon)
167
- outvals.push(t0)
168
- t0 = t1
169
- // console.log('CJ outvals C', outvals.map(v => v.canon))
170
- }
171
-
172
- else if (t1 instanceof RefVal && !(t0 instanceof RefVal)) {
173
- // console.log('CONJUNCT PUSH D', t0.canon)
174
- outvals.push(t0)
175
- t0 = t1
176
- // console.log('CJ outvals C', outvals.map(v => v.canon))
177
- }
178
-
179
-
180
- else {
181
- val = unite(ctx, t0, t1, 'cj-peer-t0t1')
182
- done = done && DONE === val.done
183
-
184
- // Unite was just a conjunt anyway, so discard.
185
- if (val instanceof ConjunctVal) {
186
- // if (t0.id === val.peg[0].id) {
187
- // val = t0
188
- outvals.push(t0)
189
- t0 = t1
190
- // console.log('CJ outvals D', outvals.map(v => v.canon))
191
- //}
192
- }
193
- else if (val instanceof Nil) {
194
- return val
195
- }
196
- else {
197
- t0 = val
198
- }
199
- // TODO: t0 should become this to avoid unnecessary repasses
200
- // console.log('CONJUNCT PUSH C', val.canon)
201
- // outvals.push(val)
202
-
203
- // pI++
204
- }
205
- }
206
-
207
- // console.log('CJ outvals', mark, outvals.map(v => v.canon))
208
-
209
- let out: Val
210
-
211
- if (0 === outvals.length) {
212
-
213
- // Empty conjuncts evaporate.
214
- out = TOP
215
- }
216
-
217
- // TODO: corrects CV[CV[1&/x]] issue above, but swaps term order!
218
- else if (1 === outvals.length) {
219
- out = outvals[0]
220
- }
221
- else {
222
- out = new ConjunctVal({ peg: outvals }, ctx)
223
- }
224
-
225
- out.done = done ? DONE : this.done + 1
226
-
227
- // console.log('CJ out', out.done, out.canon)
228
-
229
- return out
230
- }
231
-
232
-
233
- clone(spec?: ValSpec, ctx?: Context): Val {
234
- let out = (super.clone(spec, ctx) as ConjunctVal)
235
- out.peg = this.peg.map((entry: Val) => entry.clone(null, ctx))
236
- return out
237
- }
238
-
239
-
240
- // TODO: need a well-defined val order so conjunt canon is always the same
241
- get canon() {
242
- return this.peg.map((v: Val) => {
243
- return (v as any).isBinaryOp && Array.isArray(v.peg) && 1 < v.peg.length ?
244
- '(' + v.canon + ')' : v.canon
245
- }).join('&')
246
- }
247
-
248
-
249
- gen(ctx?: Context) {
250
- // Unresolved conjunct cannot be generated, so always an error.
251
- let nil = Nil.make(
252
- ctx,
253
- 'conjunct',
254
- this, // (formatPath(this.peg, this.absolute) as any),
255
- undefined
256
- )
257
-
258
- // TODO: refactor to use Site
259
- nil.path = this.path
260
- nil.url = this.url
261
- nil.row = this.row
262
- nil.col = this.col
263
-
264
- descErr(nil, ctx)
265
-
266
- if (ctx) {
267
- ctx.err.push(nil)
268
- }
269
- else {
270
- throw new Error(nil.msg)
271
- }
272
-
273
- return undefined
274
- }
275
- }
276
-
277
-
278
- // Normalize Conjuct:
279
- // - flatten child conjuncts
280
- function norm(terms: Val[]): Val[] {
281
-
282
- let expand: Val[] = []
283
- for (let tI = 0, pI = 0; tI < terms.length; tI++, pI++) {
284
- if (terms[tI] instanceof ConjunctVal) {
285
- expand.push(...terms[tI].peg)
286
- pI += terms[tI].peg.length - 1
287
- }
288
- else {
289
- expand[pI] = terms[tI]
290
- }
291
- }
292
-
293
- return expand
294
- }
295
-
296
-
297
- export {
298
- norm,
299
- ConjunctVal,
300
- }