clarity-pattern-parser 11.0.4 → 11.0.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 +41 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +41 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +41 -7
- package/dist/index.js.map +1 -1
- package/dist/patterns/ExpressionPattern.d.ts +3 -3
- package/package.json +1 -1
- package/src/intellisense/AutoComplete.test.ts +1 -1
- package/src/patterns/ExpressionPattern.test.ts +1 -2
- package/src/patterns/ExpressionPattern.ts +57 -9
- package/src/patterns/PrecedenceTree.test.ts +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -2930,12 +2930,12 @@
|
|
|
2930
2930
|
this._postfixNames = [];
|
|
2931
2931
|
this._binaryPatterns = [];
|
|
2932
2932
|
this._binaryNames = [];
|
|
2933
|
-
this.
|
|
2933
|
+
this._associationMap = {};
|
|
2934
2934
|
this._precedenceMap = {};
|
|
2935
2935
|
this._originalPatterns = patterns;
|
|
2936
2936
|
this._patterns = this._organizePatterns(patterns);
|
|
2937
2937
|
this._shouldStopParsing = false;
|
|
2938
|
-
this._precedenceTree = new PrecedenceTree(this._precedenceMap, this.
|
|
2938
|
+
this._precedenceTree = new PrecedenceTree(this._precedenceMap, this._associationMap);
|
|
2939
2939
|
if (this._atomPatterns.length === 0) {
|
|
2940
2940
|
throw new Error("Need at least one terminating pattern with an 'expression' pattern.");
|
|
2941
2941
|
}
|
|
@@ -2973,10 +2973,10 @@
|
|
|
2973
2973
|
this._binaryPatterns.push(clone);
|
|
2974
2974
|
this._binaryNames.push(name);
|
|
2975
2975
|
if (pattern.type === "right-associated") {
|
|
2976
|
-
this.
|
|
2976
|
+
this._associationMap[name] = Association.right;
|
|
2977
2977
|
}
|
|
2978
2978
|
else {
|
|
2979
|
-
this.
|
|
2979
|
+
this._associationMap[name] = Association.left;
|
|
2980
2980
|
}
|
|
2981
2981
|
finalPatterns.push(clone);
|
|
2982
2982
|
}
|
|
@@ -3004,7 +3004,7 @@
|
|
|
3004
3004
|
_isAtom(pattern) {
|
|
3005
3005
|
pattern = this._unwrapAssociationIfNecessary(pattern);
|
|
3006
3006
|
const firstChild = pattern.children[0];
|
|
3007
|
-
const lastChild = pattern.children[1];
|
|
3007
|
+
const lastChild = pattern.children[pattern.children.length - 1];
|
|
3008
3008
|
const firstChildIsReference = this._isRecursiveReference(firstChild);
|
|
3009
3009
|
const lastChildIsReference = this._isRecursiveReference(lastChild);
|
|
3010
3010
|
return !firstChildIsReference && !lastChildIsReference;
|
|
@@ -3221,7 +3221,24 @@
|
|
|
3221
3221
|
getTokens() {
|
|
3222
3222
|
return this.atomPatterns.map(p => p.getTokens()).flat();
|
|
3223
3223
|
}
|
|
3224
|
-
getTokensAfter(
|
|
3224
|
+
getTokensAfter(childReference) {
|
|
3225
|
+
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3226
|
+
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3227
|
+
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3228
|
+
return [...prefixTokens, ...atomTokens];
|
|
3229
|
+
}
|
|
3230
|
+
if (this._atomPatterns.includes(childReference)) {
|
|
3231
|
+
const postfixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3232
|
+
if (postfixTokens.length === 0) {
|
|
3233
|
+
return this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3234
|
+
}
|
|
3235
|
+
return postfixTokens;
|
|
3236
|
+
}
|
|
3237
|
+
if (this._postfixPatterns.includes(childReference)) {
|
|
3238
|
+
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3239
|
+
const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3240
|
+
return [...postfixTokens, ...binaryTokens];
|
|
3241
|
+
}
|
|
3225
3242
|
return [];
|
|
3226
3243
|
}
|
|
3227
3244
|
getNextTokens() {
|
|
@@ -3233,7 +3250,24 @@
|
|
|
3233
3250
|
getPatterns() {
|
|
3234
3251
|
return this.atomPatterns.map(p => p.getPatterns()).flat();
|
|
3235
3252
|
}
|
|
3236
|
-
getPatternsAfter(
|
|
3253
|
+
getPatternsAfter(childReference) {
|
|
3254
|
+
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3255
|
+
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3256
|
+
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3257
|
+
return [...prefixPatterns, ...atomPatterns];
|
|
3258
|
+
}
|
|
3259
|
+
if (this._atomPatterns.includes(childReference)) {
|
|
3260
|
+
const postfixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3261
|
+
if (postfixPatterns.length === 0) {
|
|
3262
|
+
return this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3263
|
+
}
|
|
3264
|
+
return postfixPatterns;
|
|
3265
|
+
}
|
|
3266
|
+
if (this._postfixPatterns.includes(childReference)) {
|
|
3267
|
+
const postfixPaterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3268
|
+
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3269
|
+
return [...postfixPaterns, ...binaryPatterns];
|
|
3270
|
+
}
|
|
3237
3271
|
return [];
|
|
3238
3272
|
}
|
|
3239
3273
|
getNextPatterns() {
|