commit 6dbfc4900579c7acfac8f957193b6d4280c71ce1
parent f61b116fe8b1578f560805deac2c83cf863d3ee1
Author: citbl <citbl@citbl.org>
Date: Sun, 24 May 2026 12:26:04 +1000
fix
Diffstat:
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/mtcl/lexer.lua b/mtcl/lexer.lua
@@ -122,18 +122,18 @@ function lexer:lex(file, src)
local c = src:sub(i, i)
if is_space(c) then
- -- skip...
if c == "\n" then
self.col = 1
self.line = self.line + 1
else
self.col = self.col + 1
end
+ i = i + 1
elseif is_alpha(c:byte()) then
- print("adding " .. " at col " .. i .. " self col: " .. self.col)
word, i = read_ident(i, src)
self:add(TK.IDENT, word)
- self.col = i
+ self.col = self.col + #word
+ i = i + 1
elseif is_digit(c:byte()) then
number, i, is_float = read_number(i, src)
if is_float then
@@ -141,46 +141,49 @@ function lexer:lex(file, src)
else
self:add(TK.LIT_INT, number)
end
- self.col = i
+ self.col = self.col + #number
+ i = i + 1
elseif c == ":" then
if next() == ":" then
self:add(TK.COLONCOLON, "::")
- i = i + 1
- self.col = self.col + 1
+ self.col = self.col + 2
+ i = i + 2
else
self:add(TK.COLON, ":")
+ self.col = self.col + 1
+ i = i + 1
end
elseif c == "=" then
if next() == "=" then
self:add(TK.EQEQ, "==")
- i = i + 1
- self.col = self.col + 1
+ self.col = self.col + 2
+ i = i + 2
else
self:add(TK.EQ, "=")
+ self.col = self.col + 1
+ i = i + 1
end
elseif c == "(" then
self:add(TK.L_PAREN, "(")
- i = i + 1
self.col = self.col + 1
+ i = i + 1
elseif c == ")" then
self:add(TK.R_PAREN, ")")
- i = i + 1
self.col = self.col + 1
+ i = i + 1
elseif c == "'" then
self:add(TK.SGL_QUOTE, "'")
- i = i + 1
self.col = self.col + 1
+ i = i + 1
elseif c == '"' then
self:add(TK.DBL_QUOTE, '"')
- i = i + 1
self.col = self.col + 1
+ i = i + 1
else
self:add(TK.IDK, "")
- i = i + 1
self.col = self.col + 1
+ i = i + 1
end
- i = i + 1
- self.col = self.col + 1
end
for i = 1, #self.tokens do