Skip to content

Commit 3be262d

Browse files
committed
Add documentation
1 parent f9f5477 commit 3be262d

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/luasm.lua

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,29 @@ end
105105
local Tokenizer = {}
106106

107107
--- Abstract method that must be overridden by a concrete tokenizer.
108-
--- @return string|nil
108+
--- @return string|nil The next line
109109
function Tokenizer.get_next_line()
110110
error("This function has to be implemented!")
111111
return nil
112112
end
113113

114+
--- Checks if the parser is at the end of the line
115+
--- @return boolean If it is at the end of the line
114116
function Tokenizer:eol()
115117
return self.line:len() == 0
116118
end
117119

118-
--- @return boolean
120+
--- Gets the next line and checks if it exist.
121+
--- This method moves the tokenizer to the next line.
122+
--- @return boolean If the next line exists
119123
function Tokenizer:has_line()
120124
self.line = self:get_next_line()
121125

122126
return self.line ~= nil
123127
end
124128

125-
--- @return string|nil
129+
--- Returns the label that is in this line
130+
--- @return string|nil The label
126131
function Tokenizer:get_label()
127132
if self.luasm.settings.label == nil then
128133
return nil
@@ -138,7 +143,8 @@ function Tokenizer:get_label()
138143
return label
139144
end
140145

141-
--- @return boolean
146+
--- Returns the mnemonic of the line
147+
--- @return string|nil The mnemonic that is being parsed
142148
function Tokenizer:get_mnemonic()
143149
local mnemonic, rest = self.line:match(self.luasm.settings.mnemonic)
144150

@@ -152,6 +158,9 @@ end
152158

153159
local ArgumentTokenizer = {}
154160

161+
--- Returns the next argument based on the argument type
162+
--- @param argument_type string The argument type that should be parsed
163+
--- @return string|nil The parsed result
155164
function ArgumentTokenizer:get_next(argument_type)
156165
local argument_regex = self.luasm.settings.syntax[argument_type]
157166

@@ -164,6 +173,8 @@ function ArgumentTokenizer:get_next(argument_type)
164173
return matched
165174
end
166175

176+
--- Skips the separator part of the line
177+
--- @return boolean If a separator existed
167178
function ArgumentTokenizer:skip_separator()
168179
local matched = self.line:match(self.luasm.settings.separator, self.position)
169180

@@ -176,17 +187,20 @@ function ArgumentTokenizer:skip_separator()
176187
return true
177188
end
178189

190+
--- Resets the argument tokenizer
179191
function ArgumentTokenizer:reset()
180192
self.position = 1
181193
end
182194

195+
--- Checks if the tokenizer is at the end of the line
196+
--- @return boolean If the end of line is reached
183197
function ArgumentTokenizer:eol()
184198
return self.position > self.line:len()
185199
end
186200

187201
--- Creates an argument tokenizer based upon the current state
188202
--- of the creating tokenizer.
189-
---
203+
---
190204
--- @return table The argument tokenizer
191205
function Tokenizer:argument_tokenizer()
192206
local obj = {}

0 commit comments

Comments
 (0)