clarity-pattern-parser 10.3.4 → 10.3.6
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 +12 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +12 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/patterns/ExpressionPattern.d.ts +2 -1
- package/package.json +1 -1
- package/src/patterns/ExpressionPattern.ts +14 -6
|
@@ -28,7 +28,8 @@ export declare class ExpressionPattern implements Pattern {
|
|
|
28
28
|
get parent(): Pattern | null;
|
|
29
29
|
set parent(pattern: Pattern | null);
|
|
30
30
|
get children(): Pattern[];
|
|
31
|
-
get
|
|
31
|
+
get unaryPrefixPatterns(): readonly Pattern[];
|
|
32
|
+
get atomPatterns(): readonly Pattern[];
|
|
32
33
|
get binaryPatterns(): readonly Pattern[];
|
|
33
34
|
get recursivePatterns(): readonly Pattern[];
|
|
34
35
|
get startedOnIndex(): number;
|
package/package.json
CHANGED
|
@@ -62,7 +62,11 @@ export class ExpressionPattern implements Pattern {
|
|
|
62
62
|
return this._patterns;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
get
|
|
65
|
+
get unaryPrefixPatterns(): readonly Pattern[] {
|
|
66
|
+
return this._unaryPrefixPatterns;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get atomPatterns(): readonly Pattern[] {
|
|
66
70
|
return this._atomPatterns;
|
|
67
71
|
}
|
|
68
72
|
|
|
@@ -114,7 +118,7 @@ export class ExpressionPattern implements Pattern {
|
|
|
114
118
|
|
|
115
119
|
if (this._isUnary(pattern)) {
|
|
116
120
|
const unaryPrefix = this._extractUnaryPrefixPattern(pattern).clone();
|
|
117
|
-
this._unaryPrefixPatterns.push(
|
|
121
|
+
this._unaryPrefixPatterns.push(unaryPrefix);
|
|
118
122
|
this._unaryPrefixNames.push(pattern.name);
|
|
119
123
|
unaryPrefix.parent = this;
|
|
120
124
|
|
|
@@ -356,6 +360,10 @@ export class ExpressionPattern implements Pattern {
|
|
|
356
360
|
|
|
357
361
|
onIndex = cursor.index;
|
|
358
362
|
|
|
363
|
+
if (prefix != null && this._recursivePatterns.length === 0) {
|
|
364
|
+
lastAtomNode = createNode(prefixName, [prefix, lastAtomNode]);
|
|
365
|
+
}
|
|
366
|
+
|
|
359
367
|
for (let i = 0; i < this._recursivePatterns.length; i++) {
|
|
360
368
|
const pattern = this._recursivePatterns[i];
|
|
361
369
|
const node = pattern.parse(cursor);
|
|
@@ -550,11 +558,11 @@ export class ExpressionPattern implements Pattern {
|
|
|
550
558
|
}
|
|
551
559
|
|
|
552
560
|
getTokens(): string[] {
|
|
553
|
-
return this.
|
|
561
|
+
return this.atomPatterns.map(p => p.getTokens()).flat();
|
|
554
562
|
}
|
|
555
563
|
|
|
556
564
|
getTokensAfter(childReference: Pattern): string[] {
|
|
557
|
-
if (this.
|
|
565
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
558
566
|
const recursiveTokens = this._recursivePatterns.map(p => p.getTokens()).flat();
|
|
559
567
|
const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
560
568
|
|
|
@@ -588,11 +596,11 @@ export class ExpressionPattern implements Pattern {
|
|
|
588
596
|
}
|
|
589
597
|
|
|
590
598
|
getPatterns(): Pattern[] {
|
|
591
|
-
return this.
|
|
599
|
+
return this.atomPatterns.map(p => p.getPatterns()).flat();
|
|
592
600
|
}
|
|
593
601
|
|
|
594
602
|
getPatternsAfter(childReference: Pattern): Pattern[] {
|
|
595
|
-
if (this.
|
|
603
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
596
604
|
const recursivePatterns = this._recursivePatterns.map(p => p.getPatterns()).flat();
|
|
597
605
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
598
606
|
|