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.esm.js
CHANGED
|
@@ -855,18 +855,19 @@ class Reference {
|
|
|
855
855
|
}
|
|
856
856
|
parse(cursor) {
|
|
857
857
|
this._firstIndex = cursor.index;
|
|
858
|
-
this.
|
|
858
|
+
const pattern = this.getReferencePatternSafely();
|
|
859
|
+
this._cacheAncestors(pattern.id);
|
|
859
860
|
if (this._isBeyondRecursiveAllowance()) {
|
|
860
861
|
cursor.recordErrorAt(this._firstIndex, this._firstIndex, this);
|
|
861
862
|
return null;
|
|
862
863
|
}
|
|
863
|
-
return
|
|
864
|
+
return pattern.parse(cursor);
|
|
864
865
|
}
|
|
865
|
-
_cacheAncestors() {
|
|
866
|
+
_cacheAncestors(id) {
|
|
866
867
|
if (!this._cachedAncestors) {
|
|
867
868
|
let pattern = this.parent;
|
|
868
869
|
while (pattern != null) {
|
|
869
|
-
if (pattern.
|
|
870
|
+
if (pattern.id === id) {
|
|
870
871
|
this._recursiveAncestors.push(pattern);
|
|
871
872
|
}
|
|
872
873
|
pattern = pattern.parent;
|
|
@@ -3601,7 +3602,7 @@ class Grammar {
|
|
|
3601
3602
|
const isNot = n.find(n => n.name === "not") != null;
|
|
3602
3603
|
const isOptional = n.find(n => n.name === "is-optional");
|
|
3603
3604
|
const pattern = this._buildPattern(patternNode);
|
|
3604
|
-
const finalPattern = isOptional ? new Optional(pattern.name
|
|
3605
|
+
const finalPattern = isOptional ? new Optional(`optional-${pattern.name}`, pattern) : pattern;
|
|
3605
3606
|
if (isNot) {
|
|
3606
3607
|
return new Not(`not-${finalPattern.name}`, finalPattern);
|
|
3607
3608
|
}
|
|
@@ -3660,7 +3661,7 @@ class Grammar {
|
|
|
3660
3661
|
isOptional = true;
|
|
3661
3662
|
}
|
|
3662
3663
|
}
|
|
3663
|
-
return isOptional ? new Optional(name, new Repeat(name
|
|
3664
|
+
return isOptional ? new Optional(name, new Repeat(`inner-optional-${name}`, pattern, options)) : new Repeat(name, pattern, options);
|
|
3664
3665
|
}
|
|
3665
3666
|
_saveConfigurableAnonymous(node) {
|
|
3666
3667
|
const nameNode = node.find(n => n.name === "name");
|