clarity-pattern-parser
Advanced tools
Comparing version 11.0.4 to 11.0.5
@@ -20,3 +20,3 @@ import { Node } from "../ast/Node"; | ||
private _binaryNames; | ||
private associationMap; | ||
private _associationMap; | ||
private _precedenceMap; | ||
@@ -59,6 +59,6 @@ private _shouldStopParsing; | ||
getTokens(): string[]; | ||
getTokensAfter(_childReference: Pattern): string[]; | ||
getTokensAfter(childReference: Pattern): string[]; | ||
getNextTokens(): string[]; | ||
getPatterns(): Pattern[]; | ||
getPatternsAfter(_childReference: Pattern): Pattern[]; | ||
getPatternsAfter(childReference: Pattern): Pattern[]; | ||
getNextPatterns(): Pattern[]; | ||
@@ -65,0 +65,0 @@ find(predicate: (p: Pattern) => boolean): Pattern | null; |
{ | ||
"name": "clarity-pattern-parser", | ||
"version": "11.0.4", | ||
"version": "11.0.5", | ||
"description": "Parsing Library for Typescript and Javascript.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -166,6 +166,5 @@ import { Options } from "./Options"; | ||
const autoComplete = new AutoComplete(expression); | ||
const suggestion = autoComplete.suggestFor("a"); | ||
const suggestion = autoComplete.suggestFor("a ? b "); | ||
expect(suggestion).toBe(suggestion); | ||
}); | ||
}); |
@@ -28,3 +28,3 @@ import { Node } from "../ast/Node"; | ||
private _binaryNames: string[]; | ||
private associationMap: Record<string, Association>; | ||
private _associationMap: Record<string, Association>; | ||
private _precedenceMap: Record<string, number>; | ||
@@ -95,3 +95,3 @@ private _shouldStopParsing: boolean; | ||
this._binaryNames = []; | ||
this.associationMap = {}; | ||
this._associationMap = {}; | ||
this._precedenceMap = {}; | ||
@@ -101,3 +101,3 @@ this._originalPatterns = patterns; | ||
this._shouldStopParsing = false; | ||
this._precedenceTree = new PrecedenceTree(this._precedenceMap, this.associationMap); | ||
this._precedenceTree = new PrecedenceTree(this._precedenceMap, this._associationMap); | ||
@@ -149,5 +149,5 @@ if (this._atomPatterns.length === 0) { | ||
if (pattern.type === "right-associated") { | ||
this.associationMap[name] = Association.right; | ||
this._associationMap[name] = Association.right; | ||
} else { | ||
this.associationMap[name] = Association.left; | ||
this._associationMap[name] = Association.left; | ||
} | ||
@@ -245,3 +245,3 @@ | ||
private _isRecursiveReference(pattern: Pattern) { | ||
if (pattern == null){ | ||
if (pattern == null) { | ||
return false; | ||
@@ -465,3 +465,27 @@ } | ||
getTokensAfter(_childReference: Pattern): string[] { | ||
getTokensAfter(childReference: Pattern): string[] { | ||
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) { | ||
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat(); | ||
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat(); | ||
return [...prefixTokens, ...atomTokens]; | ||
} | ||
if (this._atomPatterns.includes(childReference)) { | ||
const postfixTokens = this.prefixPatterns.map(p => p.getTokens()).flat(); | ||
if (postfixTokens.length === 0){ | ||
return this._binaryPatterns.map(p => p.getTokens()).flat(); | ||
} | ||
return postfixTokens; | ||
} | ||
if (this._postfixPatterns.includes(childReference)) { | ||
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat(); | ||
const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat(); | ||
return [...postfixTokens, ...binaryTokens]; | ||
} | ||
return []; | ||
@@ -482,3 +506,27 @@ } | ||
getPatternsAfter(_childReference: Pattern): Pattern[] { | ||
getPatternsAfter(childReference: Pattern): Pattern[] { | ||
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) { | ||
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat(); | ||
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat(); | ||
return [...prefixPatterns, ...atomPatterns]; | ||
} | ||
if (this._atomPatterns.includes(childReference)) { | ||
const postfixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat(); | ||
if (postfixPatterns.length === 0){ | ||
return this._binaryPatterns.map(p => p.getPatterns()).flat(); | ||
} | ||
return postfixPatterns; | ||
} | ||
if (this._postfixPatterns.includes(childReference)) { | ||
const postfixPaterns = this.postfixPatterns.map(p => p.getPatterns()).flat(); | ||
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat(); | ||
return [...postfixPaterns, ...binaryPatterns]; | ||
} | ||
return []; | ||
@@ -485,0 +533,0 @@ } |
@@ -251,3 +251,3 @@ import { Association, PrecedenceTree } from "./PrecedenceTree"; | ||
test("add Partial Binary With Greater Precedence", () => { | ||
test("mul Partial Binary With Greater Precedence", () => { | ||
const tree = new PrecedenceTree({ | ||
@@ -254,0 +254,0 @@ mul: 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
1306131
22493