clarity-pattern-parser 11.0.25 → 11.0.26

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.js CHANGED
@@ -3586,8 +3586,16 @@ class Grammar {
3586
3586
  const aliasNode = statementNode.find(n => n.name === "alias-literal");
3587
3587
  const aliasName = aliasNode.value;
3588
3588
  const name = nameNode.value;
3589
- const alias = this._getPattern(aliasName).clone(name);
3590
- this._parseContext.patternsByName.set(name, alias);
3589
+ const aliasPattern = this._getPattern(aliasName);
3590
+ // This solves the problem for an alias pointing to a reference.
3591
+ if (aliasPattern.type === "reference") {
3592
+ const sequence = new Sequence(name, [aliasPattern]);
3593
+ this._parseContext.patternsByName.set(name, sequence);
3594
+ }
3595
+ else {
3596
+ const alias = aliasPattern.clone(name);
3597
+ this._parseContext.patternsByName.set(name, alias);
3598
+ }
3591
3599
  }
3592
3600
  static parse(expression, options) {
3593
3601
  const grammar = new Grammar(options);