Self explanatory, attempt to index nil with 'pos'
local self = setmetatable({
text = text:split(""),
pos = 0,
char = text[pos] or nil
}, lexer)
Self explanatory, attempt to index nil with 'pos'
local self = setmetatable({
text = text:split(""),
pos = 0,
char = text[pos] or nil
}, lexer)
In Lua, Lua doesn’t start their indexing position with 0, this means you’re trying to index the 0 position of the table which will error.
Right, I forgot about that, but I’m still getting the error. I assume its something to do with scopes.
Never mind, I found the error.
You cannot reference a key for another key’s value in a table. You are doing this:
local t = {
"Hey" = "Oh",
"Bruh!" = "Hey" -- imagine you are referring the key value of "Hey"
}
You could either just set text[pos]
to text[1]
or something.