clarity-pattern-parser 11.0.12 → 11.0.15
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 +7 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +7 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/grammar/Grammar.test.ts +3 -3
- package/src/grammar/Grammar.ts +2 -2
- package/src/patterns/Reference.ts +7 -6
- package/src/query/query.ts +48 -0
- package/src/query/selector_parser.ts +8 -0
package/dist/index.js
CHANGED
|
@@ -859,18 +859,19 @@ class Reference {
|
|
|
859
859
|
}
|
|
860
860
|
parse(cursor) {
|
|
861
861
|
this._firstIndex = cursor.index;
|
|
862
|
-
this.
|
|
862
|
+
const pattern = this.getReferencePatternSafely();
|
|
863
|
+
this._cacheAncestors(pattern.id);
|
|
863
864
|
if (this._isBeyondRecursiveAllowance()) {
|
|
864
865
|
cursor.recordErrorAt(this._firstIndex, this._firstIndex, this);
|
|
865
866
|
return null;
|
|
866
867
|
}
|
|
867
|
-
return
|
|
868
|
+
return pattern.parse(cursor);
|
|
868
869
|
}
|
|
869
|
-
_cacheAncestors() {
|
|
870
|
+
_cacheAncestors(id) {
|
|
870
871
|
if (!this._cachedAncestors) {
|
|
871
872
|
let pattern = this.parent;
|
|
872
873
|
while (pattern != null) {
|
|
873
|
-
if (pattern.
|
|
874
|
+
if (pattern.id === id) {
|
|
874
875
|
this._recursiveAncestors.push(pattern);
|
|
875
876
|
}
|
|
876
877
|
pattern = pattern.parent;
|
|
@@ -3605,7 +3606,7 @@ class Grammar {
|
|
|
3605
3606
|
const isNot = n.find(n => n.name === "not") != null;
|
|
3606
3607
|
const isOptional = n.find(n => n.name === "is-optional");
|
|
3607
3608
|
const pattern = this._buildPattern(patternNode);
|
|
3608
|
-
const finalPattern = isOptional ? new Optional(pattern.name
|
|
3609
|
+
const finalPattern = isOptional ? new Optional(`optional-${pattern.name}`, pattern) : pattern;
|
|
3609
3610
|
if (isNot) {
|
|
3610
3611
|
return new Not(`not-${finalPattern.name}`, finalPattern);
|
|
3611
3612
|
}
|
|
@@ -3664,7 +3665,7 @@ class Grammar {
|
|
|
3664
3665
|
isOptional = true;
|
|
3665
3666
|
}
|
|
3666
3667
|
}
|
|
3667
|
-
return isOptional ? new Optional(name, new Repeat(name
|
|
3668
|
+
return isOptional ? new Optional(name, new Repeat(`inner-optional-${name}`, pattern, options)) : new Repeat(name, pattern, options);
|
|
3668
3669
|
}
|
|
3669
3670
|
_saveConfigurableAnonymous(node) {
|
|
3670
3671
|
const nameNode = node.find(n => n.name === "name");
|