clarity-pattern-parser 10.1.7 → 10.1.9
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 +17 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +17 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/patterns/Reference.d.ts +1 -0
- package/package.json +1 -1
- package/src/patterns/Options.ts +6 -2
- package/src/patterns/Reference.ts +14 -2
package/dist/index.browser.js
CHANGED
|
@@ -848,16 +848,25 @@
|
|
|
848
848
|
continue;
|
|
849
849
|
}
|
|
850
850
|
const foundPattern = pattern.getPatternWithinContext(this.name);
|
|
851
|
-
if (foundPattern != null && foundPattern
|
|
851
|
+
if (foundPattern != null && this._isValidPattern(foundPattern)) {
|
|
852
852
|
return foundPattern;
|
|
853
853
|
}
|
|
854
854
|
pattern = pattern.parent;
|
|
855
855
|
}
|
|
856
856
|
const root = this._getRoot();
|
|
857
857
|
return findPattern(root, (pattern) => {
|
|
858
|
-
return pattern.name === this._name && pattern
|
|
858
|
+
return pattern.name === this._name && this._isValidPattern(pattern);
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
|
+
_isValidPattern(pattern) {
|
|
862
|
+
if (pattern.type === "reference") {
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
if (pattern.type === "context" && pattern.children[0].type === "reference") {
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
861
870
|
_getRoot() {
|
|
862
871
|
let node = this;
|
|
863
872
|
while (true) {
|
|
@@ -1018,12 +1027,16 @@
|
|
|
1018
1027
|
return null;
|
|
1019
1028
|
}
|
|
1020
1029
|
_tryToParse(cursor) {
|
|
1021
|
-
|
|
1030
|
+
let children = this._children;
|
|
1031
|
+
if (depthCache$1.getDepth(this._id, this._firstIndex) > 1) {
|
|
1032
|
+
children = this._children.reverse();
|
|
1033
|
+
}
|
|
1034
|
+
else if (depthCache$1.getDepth(this._id, this._firstIndex) > 2) {
|
|
1022
1035
|
cursor.recordErrorAt(this._firstIndex, this._firstIndex, this);
|
|
1023
1036
|
return null;
|
|
1024
1037
|
}
|
|
1025
1038
|
const results = [];
|
|
1026
|
-
for (const pattern of
|
|
1039
|
+
for (const pattern of children) {
|
|
1027
1040
|
cursor.moveTo(this._firstIndex);
|
|
1028
1041
|
let result = null;
|
|
1029
1042
|
result = pattern.parse(cursor);
|