@@ -55,7 +55,7 @@ local function Lexer(expression, operators, charPos)
55
55
local errors = {}
56
56
local charStream , curChar , curCharPos
57
57
if expression then
58
- expression = expression .. " \0 "
58
+ expression = expression
59
59
charStream = stringToTable (expression )
60
60
curChar = charStream [charPos or 1 ]
61
61
curCharPos = charPos or 1
@@ -70,15 +70,15 @@ local function Lexer(expression, operators, charPos)
70
70
--- Gets the next character from the character stream.
71
71
-- @return <String> char The next character.
72
72
local function peek ()
73
- return charStream [curCharPos + 1 ]
73
+ return charStream [curCharPos + 1 ] or " \0 "
74
74
end
75
75
76
76
--- Consumes the next character from the character stream.
77
77
-- @param <Number?> n=1 The amount of characters to go ahead.
78
78
-- @return <String> char The next character.
79
79
local function consume (n )
80
80
local newCurCharPos = curCharPos + (n or 1 )
81
- local newCurChar = charStream [newCurCharPos ]
81
+ local newCurChar = charStream [newCurCharPos ] or " \0 "
82
82
curCharPos = newCurCharPos
83
83
curChar = newCurChar
84
84
return newCurChar
@@ -309,7 +309,7 @@ local function Lexer(expression, operators, charPos)
309
309
local function resetToInitialState (expression , givenOperators )
310
310
-- If charStream is a string convert it to a table of characters
311
311
if expression then
312
- expression = expression .. " \0 "
312
+ expression = expression
313
313
charStream = stringToTableCache [expression ] or stringToTable (expression )
314
314
curChar = charStream [1 ]
315
315
curCharPos = 1
0 commit comments