11--[[
2- _ _ ____ __ __
2+ _ _ ____ __ __
33 | | _ _ / \ / ___|| \/ |
44 | | | | | | / _ \ \___ \| |\/| |
55 | |__| |_| |/ ___ \ ___) | | | |
66 |_____\__,_/_/ \_\____/|_| |_|
7-
7+
88
99A library to parse and execute custom ASM.
1010--]]
@@ -135,7 +135,7 @@ function LuASM.string_tokenizer(input)
135135 return nil
136136 end
137137
138- local startIndex , endIndex = string.find (tokenizer .input , " [^\r\n ]+" , tokenizer .cursor )
138+ local _ , endIndex = string.find (tokenizer .input , " [^\r\n ]+" , tokenizer .cursor )
139139
140140 local line = trim (string.sub (tokenizer .input , tokenizer .cursor , endIndex ))
141141
151151--[[
152152 Parses the instruction and returns an object with the structure:
153153 { op = opcode, args = args, line = current line }
154-
154+
155155 If the parsing has errored out, it returns a string with the error message.
156156--]]
157157function instruction :parse (elements , luasm )
@@ -215,7 +215,7 @@ function LuASM:parse(tokenizer)
215215 if (label ~= nil ) then
216216 -- Find label
217217 if parse_data .labels [label ] ~= nil then
218- return parse_data , {
218+ return parse_data , {
219219 errors = { " The label '" .. label " ' was found twice." },
220220 line = parse_data .parsed_lines
221221 }
@@ -237,12 +237,12 @@ function LuASM:parse(tokenizer)
237237 end
238238
239239 local errors = {}
240- for _ , instruction in ipairs (self .instructions ) do
241- if instruction .name ~= elements [1 ] then -- Not a valid instruction
240+ for _ , instr in ipairs (self .instructions ) do
241+ if instr .name ~= elements [1 ] then -- Not a valid instruction
242242 goto inline_continue
243243 end
244244
245- local result = instruction :parse (elements , self )
245+ local result = instr :parse (elements , self )
246246 if type (result ) == " table" then
247247 parse_data .instructions [# parse_data .instructions + 1 ] = result
248248
@@ -257,9 +257,9 @@ function LuASM:parse(tokenizer)
257257 -- When the program gets here no instruction had the ability to parse this
258258 if # errors == 0 then
259259 -- There exists no instruction with that name,
260- return parse_data , {
261- errors = { " There is no instruction with the name '" .. elements [1 ] .. " '" },
262- line = parse_data .parsed_lines
260+ return parse_data , {
261+ errors = { " There is no instruction with the name '" .. elements [1 ] .. " '" },
262+ line = parse_data .parsed_lines
263263 }
264264 else -- The else only exists to please the linter
265265 return parse_data , {
0 commit comments