Skip to content

Commit 3fd5008

Browse files
committed
Remove inconsistencies
1. End a multiline comment with --]] 2. Add whitespace between some tokens to space things out 3. Add second string concatenation in the label error
1 parent 2e1be63 commit 3fd5008

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/luasm.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ LuASM.version = "0.0.1"
2121

2222
--[[
2323
Creates a new LuASM runner with the specific instructions and settings
24-
]]
24+
--]]
2525
function LuASM:new(instructions, settings)
2626
-- Default settings
27-
setmetatable(settings,{__index={
27+
setmetatable(settings, { __index = {
2828
separator = "[^,%s]+",
2929
label = "^([%a]+):%s*(.*)",
3030
syntax = {
@@ -58,16 +58,16 @@ local instruction = {}
5858
@param name The name of the instruction
5959
@param structure A list of datatypes on how the instruction should be parsed
6060
@param Different settings for the instruction
61-
]]
61+
--]]
6262
function LuASM.instruction(name, structure, settings)
6363
local obj = {}
6464

6565
obj.name = name
6666
obj.structure = structure
6767

6868
-- Default settings
69-
setmetatable(settings, {__index={
7069
-- Currently no settings
70+
setmetatable(settings, { __index = {
7171
}})
7272
obj.settings = settings
7373

@@ -90,7 +90,7 @@ end
9090

9191
--[[
9292
Creates a new tokenizer without a specific implementation.
93-
]]
93+
--]]
9494
function Tokenizer:new()
9595
local obj = {}
9696

@@ -169,15 +169,15 @@ function instruction:parse(elements, luasm)
169169
local args = {}
170170
for i = 2, #elements do
171171
-- TODO: If structure element does not exist in settings
172-
local arg = elements[i]:match(luasm.settings.syntax[expected[i-1]])
172+
local arg = elements[i]:match(luasm.settings.syntax[expected[i - 1]])
173173
if arg == nil then
174174
local error = string.format(
175175
"Could not match argument '%s' (expected %s)",
176-
elements[i], expected[i-1])
176+
elements[i], expected[i - 1])
177177
return error
178178
end
179179

180-
args[i-1] = arg
180+
args[i - 1] = arg
181181
end
182182

183183
return { op = opcode, args = args, line = luasm.current_line }
@@ -187,7 +187,7 @@ end
187187
Parses the inputted source and returns a list of instructions.
188188
189189
@param tokenizer The tokenizer
190-
]]
190+
--]]
191191
function LuASM:parse(tokenizer)
192192
local parse_data = {
193193
instructions = {},
@@ -216,7 +216,7 @@ function LuASM:parse(tokenizer)
216216
-- Find label
217217
if parse_data.labels[label] ~= nil then
218218
return parse_data, {
219-
errors = { "The label '" .. label "' was found twice." },
219+
errors = { "The label '" .. label .. "' was found twice." },
220220
line = parse_data.parsed_lines
221221
}
222222
end

0 commit comments

Comments
 (0)