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.js
CHANGED
|
@@ -2822,12 +2822,15 @@ class Expression {
|
|
|
2822
2822
|
}
|
|
2823
2823
|
return pattern.name === this.name;
|
|
2824
2824
|
}
|
|
2825
|
-
|
|
2826
|
-
this._firstIndex = cursor.index;
|
|
2825
|
+
build() {
|
|
2827
2826
|
if (!this._hasOrganized) {
|
|
2828
2827
|
this._hasOrganized = true;
|
|
2829
2828
|
this._organizePatterns(this._originalPatterns);
|
|
2830
2829
|
}
|
|
2830
|
+
}
|
|
2831
|
+
parse(cursor) {
|
|
2832
|
+
this._firstIndex = cursor.index;
|
|
2833
|
+
this.build();
|
|
2831
2834
|
// If there are not any atom nodes then nothing can be found.
|
|
2832
2835
|
if (this._atomPatterns.length < 1) {
|
|
2833
2836
|
cursor.moveTo(this._firstIndex);
|
|
@@ -3583,8 +3586,16 @@ class Grammar {
|
|
|
3583
3586
|
const aliasNode = statementNode.find(n => n.name === "alias-literal");
|
|
3584
3587
|
const aliasName = aliasNode.value;
|
|
3585
3588
|
const name = nameNode.value;
|
|
3586
|
-
const
|
|
3587
|
-
|
|
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
|
+
}
|
|
3588
3599
|
}
|
|
3589
3600
|
static parse(expression, options) {
|
|
3590
3601
|
const grammar = new Grammar(options);
|