feat: create trie programmatically in options

This commit is contained in:
Jason Etcovitch
2021-02-04 09:11:28 +08:00
committed by Jun Yang
parent 8734e2e6ce
commit befc33c4eb
28 changed files with 196 additions and 146 deletions
+3 -2
View File
@@ -13,6 +13,7 @@ import { range, toValue } from '../util/underscore'
import { Tokenizer } from '../parser/tokenizer'
import { Operators } from '../render/operator'
import { UndefinedVariableError, InternalUndefinedVariableError } from '../util/error'
import { Trie } from '../util/operator-trie'
export class Expression {
private operands: any[] = []
@@ -20,8 +21,8 @@ export class Expression {
private lenient: boolean
private operators: Operators
public constructor (str: string, operators: Operators, lenient = false) {
const tokenizer = new Tokenizer(str)
public constructor (str: string, operators: Operators, operatorsTrie: Trie, lenient = false) {
const tokenizer = new Tokenizer(str, operatorsTrie)
this.postfix = [...toPostfix(tokenizer.readExpression())]
this.lenient = lenient
this.operators = operators