From fb2e588f791ff8f012082fede51748f2f9aac2f6 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 27 Nov 2016 06:06:48 -0800 Subject: [PATCH] move arg_types to TokenIter --- lips/Collector.lua | 10 +--------- lips/TokenIter.lua | 10 +++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lips/Collector.lua b/lips/Collector.lua index ff37f7a..1fb0724 100644 --- a/lips/Collector.lua +++ b/lips/Collector.lua @@ -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) diff --git a/lips/TokenIter.lua b/lips/TokenIter.lua index 1532cb8..3ad5173 100644 --- a/lips/TokenIter.lua +++ b/lips/TokenIter.lua @@ -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()