@bablr/boot 0.1.6 → 0.1.8

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.
@@ -291,11 +291,13 @@ const grammar = class RegexMiniparserGrammar {
291
291
  let attrs;
292
292
 
293
293
  if (p.eatMatch('*', KW, { path: 'value' })) {
294
- attrs = { min: 0, max: Infinity };
294
+ const greedy = !p.eatMatch('?', KW, { path: 'greedyOperator' });
295
+ attrs = { min: 0, max: Infinity, greedy };
295
296
  } else if (p.eatMatch('+', KW, { path: 'value' })) {
296
- attrs = { min: 1, max: Infinity };
297
+ const greedy = !p.eatMatch('?', KW, { path: 'greedyOperator' });
298
+ attrs = { min: 1, max: Infinity, greedy };
297
299
  } else if (p.eatMatch('?', KW, { path: 'value' })) {
298
- attrs = { min: 0, max: 1 };
300
+ attrs = { min: 0, max: 1, greedy: true };
299
301
  } else if (p.match('{')) {
300
302
  p.eat('{', PN, { path: 'open', balanced: '}' });
301
303
 
@@ -306,9 +308,11 @@ const grammar = class RegexMiniparserGrammar {
306
308
  max = p.eatMatch(/\d+/y, 'Number', { path: 'max' });
307
309
  }
308
310
 
309
- attrs = { min: min && parseInt(min, 10), max: max && parseInt(max, 10) };
310
-
311
311
  p.eat('}', PN, { path: 'close', balancer: true });
312
+
313
+ const greedy = !p.eatMatch('?', KW, { path: 'greedyOperator' });
314
+
315
+ attrs = { min: min && parseInt(min, 10), max: max && parseInt(max, 10), greedy };
312
316
  }
313
317
 
314
318
  return { attrs };
@@ -71,12 +71,12 @@ const grammar = class SpamexMiniparserGrammar {
71
71
  p.eatProduction('TagType', { path: 'type' });
72
72
  let sp = p.eatMatchTrivia(_);
73
73
 
74
- if (sp && p.match(/['"/]/y)) {
74
+ if (sp && (p.match(/['"/]/y) || p.atExpression)) {
75
75
  p.eatProduction('StringMatcher', { path: 'value' });
76
76
  sp = p.eatMatchTrivia(_);
77
77
  }
78
78
 
79
- if (sp && p.match(/\w+/y)) {
79
+ if (sp && (p.match(/\w+/y) || p.atExpression)) {
80
80
  p.eatProduction('Attributes', { path: 'attributes[]' });
81
81
  sp = p.eatMatchTrivia(_);
82
82
  }
@@ -24,10 +24,6 @@ const escapables = new Map(
24
24
  const cookEscape = (escape, span) => {
25
25
  let hexMatch;
26
26
 
27
- if (!span.type.startsWith('String')) {
28
- throw new Error();
29
- }
30
-
31
27
  if (!escape.startsWith('\\')) {
32
28
  throw new Error('string escape must start with \\');
33
29
  }
@@ -44,11 +40,11 @@ const cookEscape = (escape, span) => {
44
40
  return String.fromCodePoint(parseInt(hexMatch[1], 16));
45
41
  }
46
42
 
47
- const litPattern = span === 'String:Single' ? /\\([\\nrt0'])/y : /\\([\\nrt0"])/y;
43
+ const litPattern = span === 'Single' ? /\\([\\nrt0'])/y : /\\([\\nrt0"])/y;
48
44
  const litMatch = litPattern.exec(escape);
49
45
 
50
46
  if (litMatch) {
51
- return escapables.get(litMatch[1]);
47
+ return escapables.get(litMatch[1]) || litMatch[1];
52
48
  }
53
49
 
54
50
  throw new Error('unable to cook string escape');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/boot",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Compile-time tools for bootstrapping BABLR VM",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"