1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-04-24 15:03:22 -07:00

move arg_types to TokenIter

This commit is contained in:
Connor Olding 2016-11-27 06:06:48 -08:00
parent 0d1527a773
commit fb2e588f79
2 changed files with 10 additions and 10 deletions

View File

@ -11,14 +11,6 @@ function Collector:init(options)
self.options = options or {}
end
Collector.arg_types = { -- for instructions
NUM = true,
REG = true,
VARSYM = true,
LABELSYM = true,
RELLABELSYM = true,
}
function Collector:statement(...)
local I = self.iter
local s = Statement(I.fn, I.line, ...)
@ -186,7 +178,7 @@ function Collector:instruction(name)
I:next()
elseif I.tt == 'SEP' then
I:error('extraneous comma')
elseif not self.arg_types[I.tt] then
elseif not I.arg_types[I.tt] then
I:error('unexpected argument type in instruction', I.tt)
else
insert(s, t)

View File

@ -16,6 +16,14 @@ function TokenIter:init(tokens)
self:reset()
end
TokenIter.arg_types = {
NUM = true,
REG = true,
VARSYM = true,
LABELSYM = true,
RELLABELSYM = true,
}
function TokenIter:error(msg, got)
if got ~= nil then
msg = msg..', got '..tostring(got)
@ -176,7 +184,7 @@ function TokenIter:special()
local args = {}
while true do
local arg = self:advance()
if not arg_types[arg.tt] then
if not self.arg_types[arg.tt] then
self:error('invalid argument type', arg.tt)
else
self:advance()