@@ -219,20 +219,21 @@ end
219
219
-- @return <Table> operatorToken The next operator token.
220
220
function LexerMethods :consumeOperator ()
221
221
local node = self .operatorsTrie
222
- local longestOperator = self .longestOperator
223
222
local charStream = self .charStream
224
223
local curCharPos = self .curCharPos
225
224
local operator
226
225
227
226
-- Trie walker
228
- for index = 0 , longestOperator - 1 do
227
+ local index = 0
228
+ while true do
229
229
-- Use raw charStream instead of methods for optimization
230
230
local character = charStream [curCharPos + index ]
231
231
node = node [character ] -- Advance to the deeper node
232
232
if not node then break end
233
233
if node .value then
234
234
operator = node .value
235
235
end
236
+ index = index + 1
236
237
end
237
238
if operator then
238
239
self :consume (# operator - 1 )
@@ -299,7 +300,7 @@ function LexerMethods:resetToInitialState(charStream, operators)
299
300
self .curCharPos = 1
300
301
301
302
self .operators = operators or DEFAULT_OPERATORS
302
- self .operatorsTrie , self . longestOperator = makeTrie (self .operators )
303
+ self .operatorsTrie = makeTrie (self .operators )
303
304
end
304
305
305
306
--- Runs the lexer.
@@ -331,11 +332,10 @@ function Lexer:new(expression, operators, charPos)
331
332
end
332
333
if operators then
333
334
LexerInstance .operators = operators
334
- LexerInstance .operatorsTrie , LexerInstance . longestOperator = makeTrie (operators )
335
+ LexerInstance .operatorsTrie = makeTrie (operators )
335
336
else
336
337
LexerInstance .operators = DEFAULT_OPERATORS
337
338
LexerInstance .operatorsTrie = DEFAULT_OPERATORS_TRIE
338
- LexerInstance .longestOperator = DEFAULT_LONGEST_OPERATOR
339
339
end
340
340
341
341
local function inheritModule (moduleName , moduleTable )
0 commit comments