@bablr/language-en-regex-vm-pattern 0.12.0 → 0.12.2

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 (2) hide show
  1. package/lib/grammar.js +11 -7
  2. package/package.json +6 -7
package/lib/grammar.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { re, spam as m } from '@bablr/boot';
2
- import objectEntries from 'iter-tools-es/methods/object-entries';
3
2
  import {
4
3
  eat,
5
4
  eatMatch,
@@ -24,7 +23,7 @@ export const dependencies = {};
24
23
  export const defaultMatcher = m`<Pattern />`;
25
24
 
26
25
  const escapables = new Map(
27
- objectEntries({
26
+ Object.entries({
28
27
  n: '\n',
29
28
  r: '\r',
30
29
  t: '\t',
@@ -132,13 +131,17 @@ export const grammar = class RegexGrammar {
132
131
 
133
132
  *Group() {
134
133
  yield eat(m`openToken*: <* '(?:' />`);
134
+ yield startSpan('Pattern', ')');
135
135
  yield eat(m`<__Alternatives />`);
136
+ yield endSpan();
136
137
  yield eat(m`closeToken*: <* ')' />`);
137
138
  }
138
139
 
139
140
  *CapturingGroup() {
140
141
  yield eat(m`openToken*: <* '(' />`);
142
+ yield startSpan('Pattern', ')');
141
143
  yield eat(m`<__Alternatives />`);
144
+ yield endSpan();
142
145
  yield eat(m`closeToken*: <* ')' />`);
143
146
  }
144
147
 
@@ -298,8 +301,9 @@ export const grammar = class RegexGrammar {
298
301
  yield eat(re`/[\da-fA-F]+/`);
299
302
  }
300
303
 
301
- *EscapeSequence({ s }) {
302
- const parentSpan = s().span;
304
+ *EscapeSequence({ ctx, s }) {
305
+ let { getGapNode } = ctx;
306
+ let parentSpan = s().span;
303
307
 
304
308
  yield startSpan('Escape');
305
309
 
@@ -309,7 +313,7 @@ export const grammar = class RegexGrammar {
309
313
  let cooked;
310
314
 
311
315
  if ((m_ = yield match(re`/[\\/nrt0]/`))) {
312
- const match_ = printSource(m_);
316
+ let match_ = printSource(m_);
313
317
  yield eat(m`code*: <*Keyword ${buildString(match_)} />`);
314
318
 
315
319
  cooked = escapables.get(match_) || match_;
@@ -319,9 +323,9 @@ export const grammar = class RegexGrammar {
319
323
  } else if (yield match(re`/[ux]/`)) {
320
324
  let code = yield eat(m`code*: <EscapeCode />`);
321
325
 
322
- let value = get('value', code.node);
326
+ let value = getGapNode(get('value', code.node));
323
327
 
324
- cooked = String.fromCodePoint(parseInt(printSource(value), 16));
328
+ cooked = String.fromCodePoint(parseInt(printSource(value, { getGapNode }), 16));
325
329
  } else {
326
330
  yield fail();
327
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-regex-vm-pattern",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "A BABLR language for nonbacktracking JS-style regexes",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -18,16 +18,15 @@
18
18
  "test": "mocha"
19
19
  },
20
20
  "dependencies": {
21
- "@bablr/boot": "0.11.0",
22
- "@bablr/helpers": "0.25.0",
23
- "@bablr/agast-helpers": "0.10.0",
24
- "@bablr/agast-vm-helpers": "0.10.0",
25
- "iter-tools-es": "7.5.3"
21
+ "@bablr/boot": "0.11.1",
22
+ "@bablr/helpers": "0.25.1",
23
+ "@bablr/agast-helpers": "0.10.2",
24
+ "@bablr/agast-vm-helpers": "0.10.2"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
29
28
  "@qnighy/dedent": "0.1.1",
30
- "bablr": "^0.11.0",
29
+ "bablr": "^0.11.2",
31
30
  "enhanced-resolve": "^5.12.0",
32
31
  "eslint": "^8.47.0",
33
32
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",