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