clarity-pattern-parser 10.1.11 → 10.1.13
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 +14 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +14 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns/Options.d.ts +1 -0
- package/package.json +1 -1
- package/src/patterns/Options.ts +19 -2
|
@@ -22,6 +22,7 @@ export declare class Options implements Pattern {
|
|
|
22
22
|
exec(text: string, record?: boolean): ParseResult;
|
|
23
23
|
parse(cursor: Cursor): Node | null;
|
|
24
24
|
private _tryToParse;
|
|
25
|
+
private _shouldReverseOrder;
|
|
25
26
|
getTokens(): string[];
|
|
26
27
|
getTokensAfter(_childReference: Pattern): string[];
|
|
27
28
|
getNextTokens(): string[];
|
package/package.json
CHANGED
package/src/patterns/Options.ts
CHANGED
|
@@ -111,11 +111,14 @@ export class Options implements Pattern {
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
private _tryToParse(cursor: Cursor): Node | null {
|
|
114
|
+
const shouldReverseOrder = this._shouldReverseOrder();
|
|
114
115
|
let children = this._children;
|
|
115
116
|
|
|
116
|
-
if (
|
|
117
|
+
if (shouldReverseOrder) {
|
|
117
118
|
children = this._children.slice().reverse();
|
|
118
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (depthCache.getDepth(this._id, this._firstIndex) > 2) {
|
|
119
122
|
cursor.recordErrorAt(this._firstIndex, this._firstIndex, this);
|
|
120
123
|
return null;
|
|
121
124
|
}
|
|
@@ -145,6 +148,20 @@ export class Options implements Pattern {
|
|
|
145
148
|
return nonNullResults[0] || null;
|
|
146
149
|
}
|
|
147
150
|
|
|
151
|
+
private _shouldReverseOrder() {
|
|
152
|
+
let count = 0;
|
|
153
|
+
let pattern = this._parent;
|
|
154
|
+
|
|
155
|
+
while (pattern != null) {
|
|
156
|
+
if (pattern.id === this.id) {
|
|
157
|
+
count++;
|
|
158
|
+
}
|
|
159
|
+
pattern = pattern.parent;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return count % 2 === 1;
|
|
163
|
+
}
|
|
164
|
+
|
|
148
165
|
getTokens(): string[] {
|
|
149
166
|
const tokens: string[] = [];
|
|
150
167
|
|