clarity-pattern-parser 10.1.2 → 10.1.3
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 +10 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +10 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/patterns/Context.d.ts +5 -0
- package/package.json +1 -1
- package/src/patterns/Context.ts +13 -4
- package/src/patterns/Reference.ts +2 -3
package/dist/index.browser.js
CHANGED
|
@@ -847,9 +847,7 @@
|
|
|
847
847
|
pattern = pattern.parent;
|
|
848
848
|
continue;
|
|
849
849
|
}
|
|
850
|
-
const foundPattern =
|
|
851
|
-
return pattern.name === this._name && pattern.type !== "reference" && pattern.type !== "context";
|
|
852
|
-
});
|
|
850
|
+
const foundPattern = pattern.getPatternWithinContext(this.name);
|
|
853
851
|
if (foundPattern != null) {
|
|
854
852
|
return foundPattern;
|
|
855
853
|
}
|
|
@@ -2542,17 +2540,23 @@
|
|
|
2542
2540
|
get children() {
|
|
2543
2541
|
return this._children;
|
|
2544
2542
|
}
|
|
2543
|
+
getPatternWithinContext(name) {
|
|
2544
|
+
return this._patterns[name] || null;
|
|
2545
|
+
}
|
|
2546
|
+
getPatternsWithinContext() {
|
|
2547
|
+
return Object.assign({}, this._patterns);
|
|
2548
|
+
}
|
|
2545
2549
|
constructor(name, pattern, context = []) {
|
|
2546
2550
|
this._id = `context-${contextId++}`;
|
|
2547
2551
|
this._type = "context";
|
|
2548
2552
|
this._name = name;
|
|
2549
2553
|
this._parent = null;
|
|
2550
|
-
|
|
2554
|
+
this._patterns = {};
|
|
2551
2555
|
const clonedPattern = pattern.clone();
|
|
2552
|
-
|
|
2556
|
+
context.forEach(p => this._patterns[p.name] = p);
|
|
2553
2557
|
clonedPattern.parent = this;
|
|
2554
2558
|
this._pattern = clonedPattern;
|
|
2555
|
-
this._children = [
|
|
2559
|
+
this._children = [clonedPattern];
|
|
2556
2560
|
}
|
|
2557
2561
|
parse(cursor) {
|
|
2558
2562
|
return this._pattern.parse(cursor);
|