clarity-pattern-parser 11.0.12 → 11.0.14
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/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/grammar/Grammar.test.ts +3 -3
- package/src/grammar/Grammar.ts +2 -2
package/package.json
CHANGED
|
@@ -172,10 +172,10 @@ describe("Grammar", () => {
|
|
|
172
172
|
const patterns = Grammar.parseString(expression);
|
|
173
173
|
const pattern = patterns["digits"];
|
|
174
174
|
const digit = new Regex("digit", "\\d");
|
|
175
|
-
const digits = new Optional("digits", new Repeat("digits", digit, { min: 0 }));
|
|
176
|
-
|
|
177
|
-
const expected = new Context("digits", digits, [digit]);
|
|
175
|
+
const digits = new Optional("optional-digits", new Repeat("digits", digit, { min: 0 }));
|
|
178
176
|
|
|
177
|
+
const expected = new Context("optional-digits", digits, [digit]);
|
|
178
|
+
debugger;
|
|
179
179
|
expect(pattern.isEqual(expected)).toBeTruthy();
|
|
180
180
|
});
|
|
181
181
|
|
package/src/grammar/Grammar.ts
CHANGED
|
@@ -340,7 +340,7 @@ export class Grammar {
|
|
|
340
340
|
const isNot = n.find(n => n.name === "not") != null;
|
|
341
341
|
const isOptional = n.find(n => n.name === "is-optional");
|
|
342
342
|
const pattern = this._buildPattern(patternNode);
|
|
343
|
-
const finalPattern = isOptional ? new Optional(pattern.name
|
|
343
|
+
const finalPattern = isOptional ? new Optional(`optional-${pattern.name}`, pattern) : pattern;
|
|
344
344
|
|
|
345
345
|
if (isNot) {
|
|
346
346
|
return new Not(`not-${finalPattern.name}`, finalPattern);
|
|
@@ -410,7 +410,7 @@ export class Grammar {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
return isOptional ? new Optional(name, new Repeat(name
|
|
413
|
+
return isOptional ? new Optional(name, new Repeat(`inner-optional-${name}`, pattern, options)) : new Repeat(name, pattern, options);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
private _saveConfigurableAnonymous(node: Node) {
|