clarity-pattern-parser 11.0.24 → 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.browser.js +15 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +15 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/patterns/Expression.d.ts +1 -0
- package/package.json +1 -1
- package/src/grammar/Grammar.ts +10 -2
- package/src/patterns/Expression.ts +7 -3
package/dist/index.browser.js
CHANGED
|
@@ -2824,12 +2824,15 @@
|
|
|
2824
2824
|
}
|
|
2825
2825
|
return pattern.name === this.name;
|
|
2826
2826
|
}
|
|
2827
|
-
|
|
2828
|
-
this._firstIndex = cursor.index;
|
|
2827
|
+
build() {
|
|
2829
2828
|
if (!this._hasOrganized) {
|
|
2830
2829
|
this._hasOrganized = true;
|
|
2831
2830
|
this._organizePatterns(this._originalPatterns);
|
|
2832
2831
|
}
|
|
2832
|
+
}
|
|
2833
|
+
parse(cursor) {
|
|
2834
|
+
this._firstIndex = cursor.index;
|
|
2835
|
+
this.build();
|
|
2833
2836
|
// If there are not any atom nodes then nothing can be found.
|
|
2834
2837
|
if (this._atomPatterns.length < 1) {
|
|
2835
2838
|
cursor.moveTo(this._firstIndex);
|
|
@@ -3585,8 +3588,16 @@
|
|
|
3585
3588
|
const aliasNode = statementNode.find(n => n.name === "alias-literal");
|
|
3586
3589
|
const aliasName = aliasNode.value;
|
|
3587
3590
|
const name = nameNode.value;
|
|
3588
|
-
const
|
|
3589
|
-
|
|
3591
|
+
const aliasPattern = this._getPattern(aliasName);
|
|
3592
|
+
// This solves the problem for an alias pointing to a reference.
|
|
3593
|
+
if (aliasPattern.type === "reference") {
|
|
3594
|
+
const sequence = new Sequence(name, [aliasPattern]);
|
|
3595
|
+
this._parseContext.patternsByName.set(name, sequence);
|
|
3596
|
+
}
|
|
3597
|
+
else {
|
|
3598
|
+
const alias = aliasPattern.clone(name);
|
|
3599
|
+
this._parseContext.patternsByName.set(name, alias);
|
|
3600
|
+
}
|
|
3590
3601
|
}
|
|
3591
3602
|
static parse(expression, options) {
|
|
3592
3603
|
const grammar = new Grammar(options);
|