clarity-pattern-parser 10.1.22 → 10.1.23
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 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +7 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/patterns/Context.ts +8 -1
- package/src/patterns/ExpressionPattern.ts +11 -3
package/package.json
CHANGED
package/src/patterns/Context.ts
CHANGED
|
@@ -84,6 +84,9 @@ export class Context implements Pattern {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
getTokensAfter(childReference: Pattern): string[] {
|
|
87
|
+
if (this.parent == null) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
87
90
|
return this._pattern.getTokensAfter(childReference);
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -96,7 +99,11 @@ export class Context implements Pattern {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
getPatternsAfter(childReference: Pattern): Pattern[] {
|
|
99
|
-
|
|
102
|
+
if (this.parent == null) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this.parent.getPatternsAfter(childReference);
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
getNextPatterns(): Pattern[] {
|
|
@@ -41,17 +41,23 @@ export class ExpressionPattern implements Pattern {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
get children(): Pattern[] {
|
|
44
|
-
return
|
|
44
|
+
return this._patterns;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
constructor(name: string, patterns: []) {
|
|
47
|
+
constructor(name: string, patterns: Pattern[]) {
|
|
48
48
|
this._id = `expression-${indexId++}`;
|
|
49
49
|
this._type = "expression";
|
|
50
|
+
this._name = name;
|
|
50
51
|
this._unaryPatterns = [];
|
|
51
52
|
this._binaryPatterns = [];
|
|
53
|
+
|
|
54
|
+
this._patterns.forEach(p => p.parent = this);
|
|
55
|
+
this._patterns = this._organizePatterns(patterns);
|
|
56
|
+
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
private _organizePatterns() {
|
|
59
|
+
private _organizePatterns(patterns: Pattern[]) {
|
|
60
|
+
const finalPatterns = [];
|
|
55
61
|
this._patterns.forEach((pattern) => {
|
|
56
62
|
if (this._isBinary(pattern)) {
|
|
57
63
|
this._binaryPatterns.push(pattern);
|
|
@@ -59,6 +65,8 @@ export class ExpressionPattern implements Pattern {
|
|
|
59
65
|
this._unaryPatterns.push();
|
|
60
66
|
}
|
|
61
67
|
});
|
|
68
|
+
|
|
69
|
+
return finalPatterns;
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
private _isBinary(pattern: Pattern) {
|