@bablr/boot 0.10.0 → 0.11.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.
@@ -1,11 +1,10 @@
1
- import * as sym from '@bablr/agast-vm-helpers/symbols';
2
- import * as Spamex from './spamex.js';
3
- import * as CSTML from './cstml.js';
4
- import * as Regex from './regex.js';
5
- import * as BaseJSON from './json.js';
1
+ import Spamex from './spamex.js';
2
+ import CSTML from './cstml.js';
3
+ import Regex from './regex.js';
4
+ import BaseJSON from './json.js';
6
5
 
7
6
  const _ = /\s+/y;
8
- const PN = 'Punctuator';
7
+ const PN = null;
9
8
  const ID = 'Identifier';
10
9
  const KW = 'Keyword';
11
10
 
@@ -31,7 +30,7 @@ const JSON = {
31
30
  export const dependencies = { Spamex, CSTML, Regex, JSON };
32
31
 
33
32
  export const covers = new Map([
34
- [sym.node, new Set(['Call', 'Punctuator'])],
33
+ [Symbol.for('@bablr/node'), new Set(['Call'])],
35
34
  [
36
35
  'Expression',
37
36
  new Set([
@@ -42,7 +41,8 @@ export const covers = new Map([
42
41
  'CSTML:GapTag',
43
42
  'RegexString',
44
43
  'SpamexString',
45
- 'CSTMLString',
44
+ 'TagString',
45
+ 'NodeString',
46
46
  'Boolean',
47
47
  'Null',
48
48
  ]),
@@ -50,12 +50,11 @@ export const covers = new Map([
50
50
  ]);
51
51
 
52
52
  export const grammar = class InstructionMiniparserGrammar {
53
- // @Node
54
53
  Call(p) {
55
54
  p.eat(/[a-zA-Z]+/y, ID, { path: 'verb' });
56
55
  p.eatMatchTrivia(_);
57
56
 
58
- p.eat('(', PN, { path: 'openToken', balanced: ')' });
57
+ p.eat('(', PN, { path: 'openToken' });
59
58
 
60
59
  let sep = p.eatMatchTrivia(_);
61
60
 
@@ -66,40 +65,45 @@ export const grammar = class InstructionMiniparserGrammar {
66
65
  i++;
67
66
  }
68
67
 
69
- p.eat(')', PN, { path: 'closeToken', balancer: true });
68
+ p.eat(')', PN, { path: 'closeToken' });
70
69
  }
71
70
 
72
- // @Node
73
71
  SpamexString(p) {
74
72
  p.eat('m', KW, { path: 'sigilToken' });
75
73
  let quot = p.match(/['"`]/);
76
- p.eat(quot, PN, { path: 'openToken', balanced: quot });
74
+ p.eat(quot, PN, { path: 'openToken' });
77
75
  p.eatProduction('Spamex:Matcher', { path: 'content' });
78
76
 
79
- p.eat(quot, PN, { path: 'closeToken', balancer: true });
77
+ p.eat(quot, PN, { path: 'closeToken' });
80
78
  }
81
79
 
82
- // @Node
83
- CSTMLString(p) {
80
+ TagString(p) {
84
81
  p.eat('t', KW, { path: 'sigilToken' });
85
82
  let quot = p.match(/['"`]/);
86
- p.eat(quot, PN, { path: 'openToken', balanced: quot });
83
+ p.eat(quot, PN, { path: 'openToken' });
87
84
  p.eatProduction('CSTML:Tag', { path: 'content' });
88
85
 
89
- p.eat(quot, PN, { path: 'closeToken', balancer: true });
86
+ p.eat(quot, PN, { path: 'closeToken' });
87
+ }
88
+
89
+ NodeString(p) {
90
+ p.eat('n', KW, { path: 'sigilToken' });
91
+ let quot = p.match(/['"`]/);
92
+ p.eat(quot, PN, { path: 'openToken' });
93
+ p.eatProduction('CSTML:Node', { path: 'content' });
94
+
95
+ p.eat(quot, PN, { path: 'closeToken' });
90
96
  }
91
97
 
92
- // @Node
93
98
  RegexString(p) {
94
99
  p.eat('re', KW, { path: 'sigilToken' });
95
100
  let quot = p.match(/['"`]/);
96
- p.eat(quot, PN, { path: 'openToken', balanced: quot });
101
+ p.eat(quot, PN, { path: 'openToken' });
97
102
  p.eatProduction('Regex:Pattern', { path: 'content' });
98
103
 
99
- p.eat(quot, PN, { path: 'closeToken', balancer: true });
104
+ p.eat(quot, PN, { path: 'closeToken' });
100
105
  }
101
106
 
102
- // @Cover
103
107
  Expression(p) {
104
108
  if (p.match('[')) {
105
109
  p.eatProduction('JSON:Array');
@@ -111,6 +115,10 @@ export const grammar = class InstructionMiniparserGrammar {
111
115
  p.eatProduction('RegexString');
112
116
  } else if (p.match(/m['"`]/y)) {
113
117
  p.eatProduction('SpamexString');
118
+ } else if (p.match(/t['"`]/y)) {
119
+ p.eatProduction('TagString');
120
+ } else if (p.match(/n['"`]/y)) {
121
+ p.eatProduction('NodeString');
114
122
  } else if (p.match(/true|false/y)) {
115
123
  p.eatProduction('JSON:Boolean');
116
124
  } else if (p.match('null')) {
@@ -118,3 +126,5 @@ export const grammar = class InstructionMiniparserGrammar {
118
126
  }
119
127
  }
120
128
  };
129
+
130
+ export default { name, canonicalURL, dependencies, covers, grammar };
@@ -1,11 +1,7 @@
1
1
  import objectEntries from 'iter-tools-es/methods/object-entries';
2
- import * as sym from '@bablr/agast-vm-helpers/symbols';
3
- import * as Spamex from './spamex.js';
4
- import * as CSTML from './cstml.js';
5
- import * as Regex from './regex.js';
6
2
 
7
3
  const _ = /\s+/y;
8
- const PN = 'Punctuator';
4
+ const PN = null;
9
5
  const KW = 'Keyword';
10
6
  const LIT = 'Identifier';
11
7
 
@@ -13,13 +9,12 @@ export const name = 'JSON';
13
9
 
14
10
  export const canonicalURL = 'https://bablr.org/languages/core/en/cstml-json';
15
11
 
16
- export const dependencies = { Spamex, CSTML, Regex };
12
+ export const dependencies = {};
17
13
 
18
14
  export const covers = new Map([
19
15
  [
20
- sym.node,
16
+ Symbol.for('@bablr/node'),
21
17
  new Set([
22
- 'Punctuator',
23
18
  'Property',
24
19
  'Object',
25
20
  'Array',
@@ -84,7 +79,6 @@ export const cookEscape = (escape, span) => {
84
79
  };
85
80
 
86
81
  export const grammar = class JSONMiniparserGrammar {
87
- // @Cover
88
82
  Expression(p) {
89
83
  if (p.match('[')) {
90
84
  p.eatProduction('Array');
@@ -103,9 +97,8 @@ export const grammar = class JSONMiniparserGrammar {
103
97
  }
104
98
  }
105
99
 
106
- // @Node
107
100
  Object(p) {
108
- p.eat('{', PN, { path: 'openToken', balanced: '}' });
101
+ p.eat('{', PN, { path: 'openToken' });
109
102
 
110
103
  p.eatMatchTrivia(_);
111
104
 
@@ -121,10 +114,9 @@ export const grammar = class JSONMiniparserGrammar {
121
114
 
122
115
  p.eatMatchTrivia(_);
123
116
 
124
- p.eat('}', PN, { path: 'closeToken', balancer: true });
117
+ p.eat('}', PN, { path: 'closeToken' });
125
118
  }
126
119
 
127
- // @Node
128
120
  Property(p) {
129
121
  if (p.match(/['"]/y)) {
130
122
  p.eatProduction('String', { path: 'key' });
@@ -137,9 +129,8 @@ export const grammar = class JSONMiniparserGrammar {
137
129
  p.eatProduction('Expression', { path: 'value' });
138
130
  }
139
131
 
140
- // @Node
141
132
  Array(p) {
142
- p.eat('[', PN, { path: 'openToken', balanced: ']' });
133
+ p.eat('[', PN, { path: 'openToken' });
143
134
 
144
135
  p.eatMatchTrivia(_);
145
136
 
@@ -154,15 +145,13 @@ export const grammar = class JSONMiniparserGrammar {
154
145
  first = false;
155
146
  }
156
147
 
157
- p.eat(']', PN, { path: 'closeToken', balancer: true });
148
+ p.eat(']', PN, { path: 'closeToken' });
158
149
  }
159
150
 
160
- // @Node
161
151
  Boolean(p) {
162
152
  p.eat(/true|false/y, KW, { path: 'sigilToken' });
163
153
  }
164
154
 
165
- // @Node
166
155
  Null(p) {
167
156
  p.eat('null', KW, { path: 'sigilToken' });
168
157
  }
@@ -183,29 +172,24 @@ export const grammar = class JSONMiniparserGrammar {
183
172
  }
184
173
  }
185
174
 
186
- // @Node
187
175
  Integer(p) {
188
- p.eatMatch('-', 'Punctuator', { path: 'negative' });
176
+ p.eatMatch('-', PN, { path: 'negative' });
189
177
  p.eatProduction('Digits', { path: 'digits[]' });
190
178
  }
191
179
 
192
- // @Node
193
180
  UnsignedInteger(p) {
194
181
  p.eatProduction('Digits', { path: 'digits[]' });
195
182
  }
196
183
 
197
- // @Node
198
184
  Infinity(p) {
199
- p.eatMatch(/[+-]/, 'Punctuator', { path: 'sign' });
185
+ p.eatMatch(/[+-]/y, PN, { path: 'sign' });
200
186
  p.eat('Infinity', 'Keyword', { path: 'sigilToken' });
201
187
  }
202
188
 
203
- // @Node
204
189
  NotANumber(p) {
205
190
  p.eat('NaN', 'Keyword', { path: 'sigilToken' });
206
191
  }
207
192
 
208
- // @Node
209
193
  Undefined(p) {
210
194
  p.eat('undefined', 'Keyword', { path: 'sigilToken' });
211
195
  }
@@ -216,17 +200,14 @@ export const grammar = class JSONMiniparserGrammar {
216
200
  }
217
201
  }
218
202
 
219
- // @Node
220
203
  Digit(p) {
221
204
  p.eatLiteral(/\d/y);
222
205
  }
223
206
 
224
- // @Node
225
207
  Identifier(p) {
226
208
  p.eat(/[a-zA-Z]+/y, LIT, { path: 'content' });
227
209
  }
228
210
 
229
- // @Node
230
211
  String(p) {
231
212
  const q = p.match(/['"]/y) || '"';
232
213
 
@@ -239,7 +220,6 @@ export const grammar = class JSONMiniparserGrammar {
239
220
  p.eat(q, PN, { path: 'closeToken', endSpan: span, balancer: true });
240
221
  }
241
222
 
242
- // @Node
243
223
  StringContent(p) {
244
224
  let esc, lit;
245
225
  let i = 0;
@@ -259,3 +239,5 @@ export const grammar = class JSONMiniparserGrammar {
259
239
  }
260
240
  }
261
241
  };
242
+
243
+ export default { name, canonicalURL, dependencies, covers, grammar, cookEscape };
@@ -1,4 +1,3 @@
1
- import * as sym from '@bablr/agast-vm-helpers/symbols';
2
1
  import when from 'iter-tools-es/methods/when';
3
2
  import { escapables } from './json.js';
4
3
 
@@ -10,7 +9,7 @@ export const dependencies = {};
10
9
 
11
10
  export const covers = new Map([
12
11
  [
13
- sym.node,
12
+ Symbol.for('@bablr/node'),
14
13
  new Set([
15
14
  'RegExpLiteral',
16
15
  'Flags',
@@ -29,7 +28,6 @@ export const covers = new Map([
29
28
  'SpaceCharacterSet',
30
29
  'DigitCharacterSet',
31
30
  'Quantifier',
32
- 'Punctuator',
33
31
  'Keyword',
34
32
  'Escape',
35
33
  'Number',
@@ -82,7 +80,7 @@ const flags = {
82
80
  sticky: 'y',
83
81
  };
84
82
 
85
- const PN = 'Punctuator';
83
+ const PN = null;
86
84
  const KW = 'Keyword';
87
85
  const ESC = 'Escape';
88
86
 
@@ -138,7 +136,6 @@ export const cookEscape = (escape, span) => {
138
136
  };
139
137
 
140
138
  export const grammar = class RegexMiniparserGrammar {
141
- // @Node
142
139
  Pattern(p) {
143
140
  p.eat('/', PN, { path: 'openToken', balanced: '/' });
144
141
  p.eatProduction('Alternatives', { path: 'alternatives[]' });
@@ -149,7 +146,6 @@ export const grammar = class RegexMiniparserGrammar {
149
146
  }
150
147
  }
151
148
 
152
- // @Node
153
149
  Flags(p) {
154
150
  const flagsStr = p.match(/[gimsuy]+/y) || '';
155
151
 
@@ -171,10 +167,9 @@ export const grammar = class RegexMiniparserGrammar {
171
167
  Alternatives(p) {
172
168
  do {
173
169
  p.eatProduction('Alternative');
174
- } while (p.eatMatch('|', PN, { path: 'separatorTokens[]' }));
170
+ } while (p.eatMatch('|', PN, { path: '#separatorTokens' }));
175
171
  }
176
172
 
177
- // @Node
178
173
  Alternative(p) {
179
174
  p.eatProduction('Elements', { path: 'elements[]+' });
180
175
  }
@@ -185,7 +180,6 @@ export const grammar = class RegexMiniparserGrammar {
185
180
  }
186
181
  }
187
182
 
188
- // @Cover
189
183
  Element(p) {
190
184
  if (p.match('[')) {
191
185
  p.eatProduction('CharacterClass');
@@ -210,14 +204,12 @@ export const grammar = class RegexMiniparserGrammar {
210
204
  }
211
205
  }
212
206
 
213
- // @Node
214
207
  Group(p) {
215
208
  p.eat('(?:', PN, { path: 'openToken', balanced: ')' });
216
209
  p.eatProduction('Alternatives', { path: 'alternatives[]' });
217
210
  p.eat(')', PN, { path: 'closeToken', balancer: true });
218
211
  }
219
212
 
220
- // @Node
221
213
  CapturingGroup(p) {
222
214
  p.eat('(', PN, { path: 'openToken', balanced: ')' });
223
215
  p.eatProduction('Alternatives', { path: 'alternatives[]' });
@@ -234,20 +226,14 @@ export const grammar = class RegexMiniparserGrammar {
234
226
  }
235
227
  }
236
228
 
237
- // @CoveredBy('Assertion')
238
- // @Node
239
229
  StartOfInputAssertion(p) {
240
230
  p.eat('^', KW, { path: 'sigilToken' });
241
231
  }
242
232
 
243
- // @CoveredBy('Assertion')
244
- // @Node
245
233
  EndOfInputAssertion(p) {
246
234
  p.eat('$', KW, { path: 'sigilToken' });
247
235
  }
248
236
 
249
- // @CoveredBy('Assertion')
250
- // @Node
251
237
  WordBoundaryAssertion(p) {
252
238
  let attrs;
253
239
  if (p.eatMatch('\\', ESC, { path: 'escapeToken' })) {
@@ -259,7 +245,6 @@ export const grammar = class RegexMiniparserGrammar {
259
245
  return { attrs };
260
246
  }
261
247
 
262
- // @Node
263
248
  Character(p) {
264
249
  const specialPattern = getSpecialPattern(p.span);
265
250
 
@@ -287,14 +272,13 @@ export const grammar = class RegexMiniparserGrammar {
287
272
  }
288
273
  }
289
274
 
290
- // @Node
291
275
  CharacterClass(p) {
292
276
  p.eat('[', PN, { path: 'openToken', balanced: ']', startSpan: 'CharacterClass' });
293
277
 
294
278
  const negate = !!p.eatMatch('^', KW, { path: 'negateToken', boolean: true });
295
279
 
296
280
  let first = !negate;
297
- while (p.match(/./sy)) {
281
+ while (p.match(/./sy) || p.atExpression) {
298
282
  p.eatProduction('CharacterClassElement', { path: 'elements[]' }, { first });
299
283
  first = false;
300
284
  }
@@ -304,7 +288,6 @@ export const grammar = class RegexMiniparserGrammar {
304
288
  return { attrs: { negate } };
305
289
  }
306
290
 
307
- // @Cover
308
291
  CharacterClassElement(p, { first }) {
309
292
  if (p.match(/(.|\\(u(\{[0-9a-fA-F]{1,6}\}|[0-9a-fA-F]{4})|x[0-9a-fA-F]{2}|\w))-[^\]\n]/y)) {
310
293
  p.eatProduction('CharacterClassRange', undefined, { first });
@@ -317,13 +300,11 @@ export const grammar = class RegexMiniparserGrammar {
317
300
  }
318
301
  }
319
302
 
320
- // @Node
321
303
  Gap(p) {
322
304
  p.eat('\\', PN, { path: 'escapeToken' });
323
305
  p.eat('g', KW, { path: 'value' });
324
306
  }
325
307
 
326
- // @Node
327
308
  CharacterClassRange(p, { first }) {
328
309
  p.eatProduction('Character', {
329
310
  path: 'min',
@@ -353,14 +334,10 @@ export const grammar = class RegexMiniparserGrammar {
353
334
  return { attrs };
354
335
  }
355
336
 
356
- // @CoveredBy('CharacterSet')
357
- // @Node
358
337
  AnyCharacterSet(p) {
359
338
  p.eat('.', KW, { path: 'sigilToken' });
360
339
  }
361
340
 
362
- // @CoveredBy('CharacterSet')
363
- // @Node
364
341
  WordCharacterSet(p) {
365
342
  p.eat('\\', PN, { path: 'escapeToken' });
366
343
 
@@ -375,8 +352,6 @@ export const grammar = class RegexMiniparserGrammar {
375
352
  return { attrs };
376
353
  }
377
354
 
378
- // @CoveredBy('CharacterSet')
379
- // @Node
380
355
  SpaceCharacterSet(p) {
381
356
  p.eat('\\', PN, { path: 'escapeToken' });
382
357
 
@@ -391,8 +366,6 @@ export const grammar = class RegexMiniparserGrammar {
391
366
  return { attrs };
392
367
  }
393
368
 
394
- // @CoveredBy('CharacterSet')
395
- // @Node
396
369
  DigitCharacterSet(p) {
397
370
  p.eat('\\', PN, { path: 'escapeToken' });
398
371
 
@@ -407,7 +380,6 @@ export const grammar = class RegexMiniparserGrammar {
407
380
  return { attrs };
408
381
  }
409
382
 
410
- // @Node
411
383
  Quantifier(p) {
412
384
  p.eatHeldProduction('Element', { path: 'element+' });
413
385
 
@@ -441,3 +413,5 @@ export const grammar = class RegexMiniparserGrammar {
441
413
  return { attrs };
442
414
  }
443
415
  };
416
+
417
+ export default { name, canonicalURL, dependencies, covers, grammar, cookEscape };