clarity-pattern-parser
Advanced tools
Comparing version
@@ -26,2 +26,3 @@ import { Node } from "../ast/Node"; | ||
private _hasOrganized; | ||
private _atomsIdToAncestorsMap; | ||
get id(): string; | ||
@@ -41,2 +42,3 @@ get type(): string; | ||
private _organizePatterns; | ||
private _cacheAncestors; | ||
private _extractName; | ||
@@ -58,2 +60,3 @@ private _isPrefix; | ||
private _tryToMatchAtom; | ||
private _isBeyondRecursiveAllowance; | ||
private _tryToMatchPostfix; | ||
@@ -60,0 +63,0 @@ private _tryToMatchBinary; |
{ | ||
"name": "clarity-pattern-parser", | ||
"version": "11.3.3", | ||
"version": "11.3.4", | ||
"description": "Parsing Library for Typescript and Javascript.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -35,2 +35,3 @@ import { Node } from "../ast/Node"; | ||
private _hasOrganized: boolean; | ||
private _atomsIdToAncestorsMap: Record<string, Pattern[]> | ||
@@ -110,2 +111,3 @@ get id(): string { | ||
this._precedenceTree = new PrecedenceTree({}, {}); | ||
this._atomsIdToAncestorsMap = {}; | ||
} | ||
@@ -168,2 +170,17 @@ | ||
private _cacheAncestors() { | ||
for (let atom of this._atomPatterns) { | ||
const id = atom.id; | ||
const ancestors: Pattern[] = this._atomsIdToAncestorsMap[id] = []; | ||
let pattern: Pattern | null = this.parent; | ||
while (pattern != null) { | ||
if (pattern.id === id) { | ||
ancestors.push(pattern); | ||
} | ||
pattern = pattern.parent; | ||
} | ||
} | ||
} | ||
private _extractName(pattern: Pattern) { | ||
@@ -268,2 +285,3 @@ if (pattern.type === "right-associated") { | ||
this._organizePatterns(this._originalPatterns); | ||
this._cacheAncestors(); | ||
} | ||
@@ -374,2 +392,7 @@ } | ||
const pattern = this._atomPatterns[i]; | ||
if (this._isBeyondRecursiveAllowance(pattern, onIndex)) { | ||
continue; | ||
} | ||
const node = pattern.parse(cursor); | ||
@@ -394,2 +417,7 @@ | ||
private _isBeyondRecursiveAllowance(atom: Pattern, onIndex: number) { | ||
const ancestors = this._atomsIdToAncestorsMap[atom.id]; | ||
return ancestors.some(a => a.startedOnIndex === onIndex); | ||
} | ||
private _tryToMatchPostfix(cursor: Cursor) { | ||
@@ -396,0 +424,0 @@ let onIndex = cursor.index; |
@@ -111,3 +111,3 @@ import { Node } from "../ast/Node"; | ||
if (depth > 0) { | ||
if (depth > 1) { | ||
return true; | ||
@@ -114,0 +114,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1556488
0.38%26978
0.34%