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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-pattern-parser",
3
- "version": "11.0.12",
3
+ "version": "11.0.14",
4
4
  "description": "Parsing Library for Typescript and Javascript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -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
 
@@ -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, pattern) : pattern;
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, pattern, options)) : new Repeat(name, pattern, options);
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) {