@bablr/language-en-regex-vm-pattern 0.12.1 → 0.12.3

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 +9 -9
  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',
@@ -44,9 +43,9 @@ const flagCharacters = {
44
43
  const unique = (flags) => flags.length === new Set(flags).size;
45
44
 
46
45
  const getSpecialPattern = (span) => {
47
- if (span === 'Pattern') {
46
+ if (span.name === 'Pattern') {
48
47
  return re`/[*+?{}[\]().^$|\n\\<>]/`;
49
- } else if (span === 'CharacterClass') {
48
+ } else if (span.name === 'CharacterClass') {
50
49
  return re`/[\]\\]/`;
51
50
  } else {
52
51
  throw new Error('unknown span type for special pattern');
@@ -302,8 +301,9 @@ export const grammar = class RegexGrammar {
302
301
  yield eat(re`/[\da-fA-F]+/`);
303
302
  }
304
303
 
305
- *EscapeSequence({ s }) {
306
- const parentSpan = s().span;
304
+ *EscapeSequence({ ctx, s }) {
305
+ let { getGapNode } = ctx;
306
+ let parentSpan = s().span;
307
307
 
308
308
  yield startSpan('Escape');
309
309
 
@@ -313,7 +313,7 @@ export const grammar = class RegexGrammar {
313
313
  let cooked;
314
314
 
315
315
  if ((m_ = yield match(re`/[\\/nrt0]/`))) {
316
- const match_ = printSource(m_);
316
+ let match_ = printSource(m_);
317
317
  yield eat(m`code*: <*Keyword ${buildString(match_)} />`);
318
318
 
319
319
  cooked = escapables.get(match_) || match_;
@@ -323,9 +323,9 @@ export const grammar = class RegexGrammar {
323
323
  } else if (yield match(re`/[ux]/`)) {
324
324
  let code = yield eat(m`code*: <EscapeCode />`);
325
325
 
326
- let value = get('value', code.node);
326
+ let value = getGapNode(get('value', code.node));
327
327
 
328
- cooked = String.fromCodePoint(parseInt(printSource(value), 16));
328
+ cooked = String.fromCodePoint(parseInt(printSource(value, { getGapNode }), 16));
329
329
  } else {
330
330
  yield fail();
331
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-regex-vm-pattern",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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.3",
22
+ "@bablr/helpers": "0.25.2",
23
+ "@bablr/agast-helpers": "0.10.4",
24
+ "@bablr/agast-vm-helpers": "0.10.4"
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.3",
31
30
  "enhanced-resolve": "^5.12.0",
32
31
  "eslint": "^8.47.0",
33
32
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",