fix: operator boundary not correctly recognized, fixes #342

This commit is contained in:
Jun Yang
2021-05-04 18:13:02 +08:00
parent 69f1a394b1
commit 3e3d84a5ed
3 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { IDENTIFIER } from '../util/character'
import { IDENTIFIER, TYPES } from '../util/character'
import { Trie } from '../util/operator-trie'
export function matchOperator (str: string, begin: number, trie: Trie, end = str.length) {
@@ -10,6 +10,6 @@ export function matchOperator (str: string, begin: number, trie: Trie, end = str
if (node['end']) info = node
}
if (!info) return -1
if (info['needBoundary'] && str.charCodeAt(i) & IDENTIFIER) return -1
if (info['needBoundary'] && (TYPES[str.charCodeAt(i)] & IDENTIFIER)) return -1
return i
}
+2 -1
View File
@@ -1,4 +1,5 @@
import { Operators } from '../render/operator'
import { IDENTIFIER, TYPES } from '../util/character'
export interface Trie {
[key: string]: any;
@@ -13,7 +14,7 @@ export function createTrie (operators: Operators): Trie {
const c = name[i]
node[c] = node[c] || {}
if (i === name.length - 1 && c !== '=') {
if (i === name.length - 1 && (TYPES[name.charCodeAt(i)] & IDENTIFIER)) {
node[c].needBoundary = true
}