clarity-pattern-parser 10.1.20 → 10.1.22
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 +39 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +39 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -12
- package/dist/index.js.map +1 -1
- package/dist/patterns/Reference.d.ts +1 -1
- package/dist/patterns/isRecursivePattern.d.ts +2 -0
- package/package.json +1 -1
- package/src/intellisense/AutoComplete.test.ts +85 -0
- package/src/patterns/ExpressionPattern.ts +36 -1
- package/src/patterns/Options.ts +9 -2
- package/src/patterns/Reference.ts +4 -4
- package/src/patterns/RightAssociatedPattern.ts +71 -0
- package/src/patterns/Sequence.ts +14 -6
- package/src/patterns/isRecursivePattern.ts +21 -0
package/dist/index.browser.js
CHANGED
|
@@ -819,9 +819,9 @@
|
|
|
819
819
|
};
|
|
820
820
|
}
|
|
821
821
|
parse(cursor) {
|
|
822
|
-
return this.
|
|
822
|
+
return this.getReferencePatternSafely().parse(cursor);
|
|
823
823
|
}
|
|
824
|
-
|
|
824
|
+
getReferencePatternSafely() {
|
|
825
825
|
if (this._pattern === null) {
|
|
826
826
|
let pattern = null;
|
|
827
827
|
if (this._cachedPattern == null) {
|
|
@@ -881,7 +881,7 @@
|
|
|
881
881
|
return node;
|
|
882
882
|
}
|
|
883
883
|
getTokens() {
|
|
884
|
-
return this.
|
|
884
|
+
return this.getReferencePatternSafely().getTokens();
|
|
885
885
|
}
|
|
886
886
|
getTokensAfter(_lastMatched) {
|
|
887
887
|
if (this._parent == null) {
|
|
@@ -896,7 +896,7 @@
|
|
|
896
896
|
return this.parent.getTokensAfter(this);
|
|
897
897
|
}
|
|
898
898
|
getPatterns() {
|
|
899
|
-
return this.
|
|
899
|
+
return this.getReferencePatternSafely().getPatterns();
|
|
900
900
|
}
|
|
901
901
|
getPatternsAfter(_childReference) {
|
|
902
902
|
if (this._parent == null) {
|
|
@@ -954,6 +954,21 @@
|
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
|
|
957
|
+
function isRecursivePattern(pattern) {
|
|
958
|
+
let onPattern = pattern.parent;
|
|
959
|
+
let depth = 0;
|
|
960
|
+
while (onPattern != null) {
|
|
961
|
+
if (onPattern.id === pattern.id) {
|
|
962
|
+
depth++;
|
|
963
|
+
}
|
|
964
|
+
onPattern = onPattern.parent;
|
|
965
|
+
if (depth > 1) {
|
|
966
|
+
return true;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
|
|
957
972
|
/*
|
|
958
973
|
The following is created to reduce the overhead of recursion check.
|
|
959
974
|
*/
|
|
@@ -1050,8 +1065,11 @@
|
|
|
1050
1065
|
}
|
|
1051
1066
|
getTokens() {
|
|
1052
1067
|
const tokens = [];
|
|
1053
|
-
for (const
|
|
1054
|
-
|
|
1068
|
+
for (const pattern of this._children) {
|
|
1069
|
+
if (isRecursivePattern(pattern)) {
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
tokens.push(...pattern.getTokens());
|
|
1055
1073
|
}
|
|
1056
1074
|
return tokens;
|
|
1057
1075
|
}
|
|
@@ -1070,6 +1088,9 @@
|
|
|
1070
1088
|
getPatterns() {
|
|
1071
1089
|
const patterns = [];
|
|
1072
1090
|
for (const pattern of this._children) {
|
|
1091
|
+
if (isRecursivePattern(pattern)) {
|
|
1092
|
+
continue;
|
|
1093
|
+
}
|
|
1073
1094
|
patterns.push(...pattern.getPatterns());
|
|
1074
1095
|
}
|
|
1075
1096
|
return patterns;
|
|
@@ -1797,9 +1818,12 @@
|
|
|
1797
1818
|
}
|
|
1798
1819
|
getTokens() {
|
|
1799
1820
|
const tokens = [];
|
|
1800
|
-
for (const
|
|
1801
|
-
|
|
1802
|
-
|
|
1821
|
+
for (const pattern of this._children) {
|
|
1822
|
+
if (isRecursivePattern(pattern) && pattern === this._children[0]) {
|
|
1823
|
+
return tokens;
|
|
1824
|
+
}
|
|
1825
|
+
tokens.push(...pattern.getTokens());
|
|
1826
|
+
if (pattern.type !== "optional" && pattern.type !== "not") {
|
|
1803
1827
|
break;
|
|
1804
1828
|
}
|
|
1805
1829
|
}
|
|
@@ -1819,9 +1843,12 @@
|
|
|
1819
1843
|
}
|
|
1820
1844
|
getPatterns() {
|
|
1821
1845
|
const patterns = [];
|
|
1822
|
-
for (const
|
|
1823
|
-
|
|
1824
|
-
|
|
1846
|
+
for (const pattern of this._children) {
|
|
1847
|
+
if (isRecursivePattern(pattern) && pattern === this._children[0]) {
|
|
1848
|
+
return patterns;
|
|
1849
|
+
}
|
|
1850
|
+
patterns.push(...pattern.getPatterns());
|
|
1851
|
+
if (pattern.type !== "optional" && pattern.type !== "not") {
|
|
1825
1852
|
break;
|
|
1826
1853
|
}
|
|
1827
1854
|
}
|