@bablr/language-en-regex-vm-pattern 0.10.0 → 0.11.0

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.
package/lib/grammar.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* @macrome
2
2
  * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#44cd5c6d803ea69c494531d65db6b33a5faa09cb
3
+ * @generatedfrom ./grammar.macro.js#c3c390f3e54607dfde1d07c0e099e54294ab7f32
4
4
  * This file is autogenerated. Please do not edit it directly.
5
5
  * When editing run `npx macrome watch` then change the file this is generated from.
6
6
  */
@@ -11,9 +11,10 @@ import { Node, CoveredBy, InjectFrom, UndefinedAttributes, AllowEmpty, Literal }
11
11
  import objectEntries from 'iter-tools-es/methods/object-entries';
12
12
  import * as Shared from '@bablr/helpers/productions';
13
13
  import { eat, eatMatch, match, shiftMatch, guard, defineAttribute, fail, o } from '@bablr/helpers/grammar';
14
- import { buildString, buildBoolean } from '@bablr/helpers/builders';
14
+ import { buildString } from '@bablr/helpers/builders';
15
15
  export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-regex-pattern';
16
16
  export const dependencies = {};
17
+ export const defaultMatcher = m`<Pattern />`;
17
18
  const escapables = new Map(objectEntries({
18
19
  n: '\n',
19
20
  r: '\r',
@@ -47,7 +48,7 @@ export const grammar = class RegexGrammar {
47
48
  }
48
49
  *[(_FlagsDecs = [UndefinedAttributes(Object.keys(flagCharacters)), AllowEmpty, Node], _GroupDecs = [CoveredBy('Element'), Node], _AssertionDecs = CoveredBy('Element'), _StartOfInputAssertionDecs = [CoveredBy('Assertion'), Node], _EndOfInputAssertionDecs = [CoveredBy('Assertion'), Node], _WordBoundaryAssertionDecs = [UndefinedAttributes(['negate']), CoveredBy('Assertion'), Node], _GapDecs = [CoveredBy('Assertion'), Node], _CharacterDecs = [CoveredBy('Element'), CoveredBy('CharacterClassElement'), Node], _CharacterClassDecs = [UndefinedAttributes(['negate']), CoveredBy('Element'), Node], _CharacterClassRangeDecs = [CoveredBy('CharacterClassElement'), Node], _CharacterSetDecs = CoveredBy('Element'), _AnyCharacterSetDecs = [CoveredBy('Element'), CoveredBy('CharacterSet'), Node], _DigitCharacterSetDecs = [UndefinedAttributes(['negate']), CoveredBy('Element'), CoveredBy('CharacterSet'), Node], _SpaceCharacterSetDecs = [UndefinedAttributes(['negate']), CoveredBy('Element'), CoveredBy('CharacterSet'), Node], _WordCharacterSetDecs = [UndefinedAttributes(['negate']), CoveredBy('Element'), CoveredBy('CharacterSet'), Node], _QuantifierDecs = [UndefinedAttributes(['min', 'max']), Node], _AnyDecs = InjectFrom(Shared), _KeywordDecs = [Literal, Node, InjectFrom(Shared)], _PunctuatorDecs = [Literal, Node, InjectFrom(Shared)], "Pattern")]() {
49
50
  yield eat(m`openToken: <*Punctuator '/' { balanced: '/', balancedSpan: 'Pattern' } />`);
50
- yield eat(m`<_Alternatives />`);
51
+ yield eat(m`<__Alternatives />`);
51
52
  yield eat(m`closeToken: <*Punctuator '/' { balancer: true } />`);
52
53
  yield eat(m`flags$: <Flags />`);
53
54
  }
@@ -74,36 +75,36 @@ export const grammar = class RegexGrammar {
74
75
  *Alternatives() {
75
76
  do {
76
77
  yield eat(m`alternatives[]$: <Alternative />`);
77
- } while (yield eatMatch(m`separatorTokens[]: <*Punctuator '|' />`));
78
+ } while (yield eatMatch(m`#separatorTokens[]: <*Punctuator '|' />`));
78
79
  }
79
80
  *Alternative() {
80
- yield eat(m`elements[]+$: <_Elements />`);
81
+ yield eat(m`elements[]+$: <__Elements />`);
81
82
  }
82
83
  *Elements() {
83
84
  yield eat(m`.[]: []`);
84
85
  while (yield match(re`/[^|]/`)) {
85
- yield eat(m`.[]+: <__Element />`);
86
+ yield eat(m`.[]+: <_Element />`);
86
87
  }
87
88
  }
88
89
  *Element() {
89
90
  yield guard(m`<*Keyword /[*+?]/ />`);
90
- yield eat(m`<_Any />`, [m`<CharacterClass '[' />`, m`<Group '(?:' />`, m`<_Assertion /[$^]|\\b/i />`, m`<Gap '\\g' />`, m`<_CharacterSet /\.|\\[dswp]/i />`, m`<*Character />`]);
91
+ yield eat(m`<__Any />`, [m`<CharacterClass '[' />`, m`<Group '(?:' />`, m`<__Assertion /[$^]|\\b/i />`, m`<Gap '\\g' />`, m`<__CharacterSet /\.|\\[dswp]/i />`, m`<*Character />`]);
91
92
  if (yield match(re`/[*+?{]/`)) {
92
93
  return shiftMatch(m`<Quantifier />`);
93
94
  }
94
95
  }
95
96
  *Group() {
96
97
  yield eat(m`openToken: <*Punctuator '(?:' { balanced: ')' } />`);
97
- yield eat(m`<_Alternatives />`);
98
+ yield eat(m`<__Alternatives />`);
98
99
  yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
99
100
  }
100
101
  *CapturingGroup() {
101
102
  yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
102
- yield eat(m`<_Alternatives />`);
103
+ yield eat(m`<__Alternatives />`);
103
104
  yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
104
105
  }
105
106
  *Assertion() {
106
- yield eat(m`<_Any />`, [m`<*StartOfInputAssertion '^' />`, m`<*EndOfInputAssertion '$' />`, m`<*WordBoundaryAssertion /\\b/i />`]);
107
+ yield eat(m`<__Any />`, [m`<StartOfInputAssertion '^' />`, m`<EndOfInputAssertion '$' />`, m`<WordBoundaryAssertion /\\b/i />`]);
107
108
  }
108
109
  *StartOfInputAssertion() {
109
110
  yield eat(m`sigilToken: <*Keyword '^' />`);
@@ -116,7 +117,7 @@ export const grammar = class RegexGrammar {
116
117
  }) {
117
118
  yield eatMatch(m`escapeToken: <*Punctuator '\\' />`);
118
119
  const m_ = yield eat(m`value: <*Keyword /b/i />`);
119
- yield defineAttribute('negate', buildBoolean(ctx.sourceTextFor(m_) === 'B'));
120
+ yield defineAttribute('negate', ctx.sourceTextFor(m_) === 'B');
120
121
  }
121
122
  *Gap() {
122
123
  yield eatMatch(m`escapeToken: <*Punctuator '\\' />`);
@@ -136,12 +137,12 @@ export const grammar = class RegexGrammar {
136
137
  }));
137
138
  yield defineAttribute('negate', !!negate);
138
139
  while (yield match(re`/./s`)) {
139
- yield eat(m`elements[]+$: <__CharacterClassElement />`);
140
+ yield eat(m`elements[]+$: <_CharacterClassElement />`);
140
141
  }
141
142
  yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
142
143
  }
143
144
  *CharacterClassElement() {
144
- yield eat(m`<_Any />`, [m`<_CharacterSet /\\[dswp]/i />`, m`<Gap '\\g' />`, m`<*Character />`]);
145
+ yield eat(m`<__Any />`, [m`<__CharacterSet /\\[dswp]/i />`, m`<Gap '\\g' />`, m`<*Character />`]);
145
146
  if (yield match('-')) {
146
147
  return shiftMatch(m`<CharacterClassRange />`);
147
148
  }
@@ -152,7 +153,7 @@ export const grammar = class RegexGrammar {
152
153
  yield eat(m`max+$: <*Character />`);
153
154
  }
154
155
  *CharacterSet() {
155
- yield eat(m`<_Any />`, [m`<AnyCharacterSet '.' />`, m`<DigitCharacterSet /\\[dD]/ />`, m`<SpaceCharacterSet /\\[sS]/ />`, m`<WordCharacterSet /\\[wW]/ />`]);
156
+ yield eat(m`<__Any />`, [m`<AnyCharacterSet '.' />`, m`<DigitCharacterSet /\\[dD]/ />`, m`<SpaceCharacterSet /\\[sS]/ />`, m`<WordCharacterSet /\\[wW]/ />`]);
156
157
  }
157
158
  *AnyCharacterSet() {
158
159
  yield eat(m`sigilToken: <*Keyword '.' />`);
@@ -181,7 +182,7 @@ export const grammar = class RegexGrammar {
181
182
  *Quantifier({
182
183
  ctx
183
184
  }) {
184
- yield eat(m`element+$: <__Element />`);
185
+ yield eat(m`element+$: <_Element />`);
185
186
  let attrs, sigil;
186
187
  if (sigil = yield eatMatch(m`sigilToken: <*Keyword /[*+?]/ />`)) {
187
188
  switch (ctx.sourceTextFor(sigil)) {
@@ -19,12 +19,14 @@ import {
19
19
  fail,
20
20
  o,
21
21
  } from '@bablr/helpers/grammar';
22
- import { buildString, buildBoolean } from '@bablr/helpers/builders';
22
+ import { buildString } from '@bablr/helpers/builders';
23
23
 
24
24
  export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-regex-pattern';
25
25
 
26
26
  export const dependencies = {};
27
27
 
28
+ export const defaultMatcher = m`<Pattern />`;
29
+
28
30
  const escapables = new Map(
29
31
  objectEntries({
30
32
  n: '\n',
@@ -59,7 +61,7 @@ export const grammar = class RegexGrammar {
59
61
  @Node
60
62
  *Pattern() {
61
63
  yield eat(m`openToken: <*Punctuator '/' { balanced: '/', balancedSpan: 'Pattern' } />`);
62
- yield eat(m`<_Alternatives />`);
64
+ yield eat(m`<__Alternatives />`);
63
65
  yield eat(m`closeToken: <*Punctuator '/' { balancer: true } />`);
64
66
  yield eat(m`flags$: <Flags />`);
65
67
  }
@@ -91,32 +93,32 @@ export const grammar = class RegexGrammar {
91
93
  *Alternatives() {
92
94
  do {
93
95
  yield eat(m`alternatives[]$: <Alternative />`);
94
- } while (yield eatMatch(m`separatorTokens[]: <*Punctuator '|' />`));
96
+ } while (yield eatMatch(m`#separatorTokens[]: <*Punctuator '|' />`));
95
97
  }
96
98
 
97
99
  @AllowEmpty
98
100
  @Node
99
101
  *Alternative() {
100
- yield eat(m`elements[]+$: <_Elements />`);
102
+ yield eat(m`elements[]+$: <__Elements />`);
101
103
  }
102
104
 
103
105
  @AllowEmpty
104
106
  *Elements() {
105
107
  yield eat(m`.[]: []`);
106
108
  while (yield match(re`/[^|]/`)) {
107
- yield eat(m`.[]+: <__Element />`);
109
+ yield eat(m`.[]+: <_Element />`);
108
110
  }
109
111
  }
110
112
 
111
113
  *Element() {
112
114
  yield guard(m`<*Keyword /[*+?]/ />`);
113
115
 
114
- yield eat(m`<_Any />`, [
116
+ yield eat(m`<__Any />`, [
115
117
  m`<CharacterClass '[' />`,
116
118
  m`<Group '(?:' />`,
117
- m`<_Assertion /[$^]|\\b/i />`,
119
+ m`<__Assertion /[$^]|\\b/i />`,
118
120
  m`<Gap '\\g' />`,
119
- m`<_CharacterSet /\.|\\[dswp]/i />`,
121
+ m`<__CharacterSet /\.|\\[dswp]/i />`,
120
122
  m`<*Character />`,
121
123
  ]);
122
124
 
@@ -129,23 +131,23 @@ export const grammar = class RegexGrammar {
129
131
  @Node
130
132
  *Group() {
131
133
  yield eat(m`openToken: <*Punctuator '(?:' { balanced: ')' } />`);
132
- yield eat(m`<_Alternatives />`);
134
+ yield eat(m`<__Alternatives />`);
133
135
  yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
134
136
  }
135
137
 
136
138
  @Node
137
139
  *CapturingGroup() {
138
140
  yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
139
- yield eat(m`<_Alternatives />`);
141
+ yield eat(m`<__Alternatives />`);
140
142
  yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
141
143
  }
142
144
 
143
145
  @CoveredBy('Element')
144
146
  *Assertion() {
145
- yield eat(m`<_Any />`, [
146
- m`<*StartOfInputAssertion '^' />`,
147
- m`<*EndOfInputAssertion '$' />`,
148
- m`<*WordBoundaryAssertion /\\b/i />`,
147
+ yield eat(m`<__Any />`, [
148
+ m`<StartOfInputAssertion '^' />`,
149
+ m`<EndOfInputAssertion '$' />`,
150
+ m`<WordBoundaryAssertion /\\b/i />`,
149
151
  ]);
150
152
  }
151
153
 
@@ -167,7 +169,7 @@ export const grammar = class RegexGrammar {
167
169
  *WordBoundaryAssertion({ ctx }) {
168
170
  yield eatMatch(m`escapeToken: <*Punctuator '\\' />`);
169
171
  const m_ = yield eat(m`value: <*Keyword /b/i />`);
170
- yield defineAttribute('negate', buildBoolean(ctx.sourceTextFor(m_) === 'B'));
172
+ yield defineAttribute('negate', ctx.sourceTextFor(m_) === 'B');
171
173
  }
172
174
 
173
175
  @CoveredBy('Assertion')
@@ -199,14 +201,18 @@ export const grammar = class RegexGrammar {
199
201
  yield defineAttribute('negate', !!negate);
200
202
 
201
203
  while (yield match(re`/./s`)) {
202
- yield eat(m`elements[]+$: <__CharacterClassElement />`);
204
+ yield eat(m`elements[]+$: <_CharacterClassElement />`);
203
205
  }
204
206
 
205
207
  yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
206
208
  }
207
209
 
208
210
  *CharacterClassElement() {
209
- yield eat(m`<_Any />`, [m`<_CharacterSet /\\[dswp]/i />`, m`<Gap '\\g' />`, m`<*Character />`]);
211
+ yield eat(m`<__Any />`, [
212
+ m`<__CharacterSet /\\[dswp]/i />`,
213
+ m`<Gap '\\g' />`,
214
+ m`<*Character />`,
215
+ ]);
210
216
 
211
217
  if (yield match('-')) {
212
218
  return shiftMatch(m`<CharacterClassRange />`);
@@ -223,7 +229,7 @@ export const grammar = class RegexGrammar {
223
229
 
224
230
  @CoveredBy('Element')
225
231
  *CharacterSet() {
226
- yield eat(m`<_Any />`, [
232
+ yield eat(m`<__Any />`, [
227
233
  m`<AnyCharacterSet '.' />`,
228
234
  m`<DigitCharacterSet /\\[dD]/ />`,
229
235
  m`<SpaceCharacterSet /\\[sS]/ />`,
@@ -277,7 +283,7 @@ export const grammar = class RegexGrammar {
277
283
  @UndefinedAttributes(['min', 'max'])
278
284
  @Node
279
285
  *Quantifier({ ctx }) {
280
- yield eat(m`element+$: <__Element />`);
286
+ yield eat(m`element+$: <_Element />`);
281
287
 
282
288
  let attrs, sigil;
283
289
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-regex-vm-pattern",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "A BABLR language for nonbacktracking JS-style regexes",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -21,11 +21,11 @@
21
21
  "test": "mocha"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/runtime": "^7.23.2",
25
- "@bablr/boot": "0.9.0",
26
- "@bablr/helpers": "0.23.0",
27
- "@bablr/agast-helpers": "0.8.0",
28
- "@bablr/agast-vm-helpers": "0.8.0",
24
+ "@babel/runtime": "7.28.2",
25
+ "@bablr/boot": "0.10.0",
26
+ "@bablr/helpers": "0.24.0",
27
+ "@bablr/agast-helpers": "0.9.0",
28
+ "@bablr/agast-vm-helpers": "0.9.0",
29
29
  "iter-tools-es": "7.5.3"
30
30
  },
31
31
  "devDependencies": {
@@ -33,7 +33,7 @@
33
33
  "@bablr/macrome": "^0.1.3",
34
34
  "@bablr/macrome-generator-bablr": "^0.3.2",
35
35
  "@qnighy/dedent": "0.1.1",
36
- "bablr": "^0.7.0",
36
+ "bablr": "^0.10.0",
37
37
  "enhanced-resolve": "^5.12.0",
38
38
  "eslint": "^8.47.0",
39
39
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",