1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-05-03 18:13:23 -07:00

rename internal DEF to VAR

This commit is contained in:
Connor Olding 2016-04-20 16:28:59 -07:00
parent 486ccb99af
commit 91e028ef6a
4 changed files with 11 additions and 11 deletions

View File

@ -9,7 +9,7 @@ local Muncher = require(path.."Muncher")
local arg_types = { -- for instructions
NUM = true,
REG = true,
DEFSYM = true,
VARSYM = true,
LABELSYM = true,
RELLABELSYM = true,
}
@ -78,7 +78,7 @@ function Collector:variable()
local t = self.t
local t2 = self:advance()
local s = self:statement('!DEF', t, t2)
local s = self:statement('!VAR', t, t2)
insert(self.statements, s)
self:advance()
end
@ -165,7 +165,7 @@ function Collector:instruction()
insert(s, t)
elseif self.tt == 'UNARY' then
local peek = self.tokens[self.i + 1]
if peek.tt == 'DEFSYM' then
if peek.tt == 'VARSYM' then
t = self:advance()
t = Token(t):set('negate')
insert(s, t)
@ -216,7 +216,7 @@ function Collector:collect(tokens, fn)
elseif self.tt == 'EOL' then
-- empty line
self:advance()
elseif self.tt == 'DEF' then
elseif self.tt == 'VAR' then
self:variable() -- handles advancing
elseif self.tt == 'LABEL' or self.tt == 'RELLABEL' then
insert(self.statements, self:statement('!LABEL', self.t))

View File

@ -358,7 +358,7 @@ function Lexer:lex(_yield)
self:error('expected a colon after closing bracket')
end
self:nextc()
yield('DEF', buff)
yield('VAR', buff)
elseif self.chr == ']' then
self:error('unmatched closing bracket')
elseif self.chr == '(' then
@ -391,7 +391,7 @@ function Lexer:lex(_yield)
elseif self.chr == '@' then
self:nextc()
local buff = self:read_chars('[%w_]')
yield('DEFSYM', buff)
yield('VARSYM', buff)
elseif self.chr == '%' then
self:nextc()
if self.chr:find('[%a_]') then

View File

@ -9,7 +9,7 @@ local Token = require(path.."Token")
local arg_types = {
NUM = true,
REG = true,
DEFSYM = true,
VARSYM = true,
LABELSYM = true,
RELLABELSYM = true,
}
@ -115,7 +115,7 @@ function Muncher:deref()
end
function Muncher:const(relative, no_label)
if self.tt ~= 'NUM' and self.tt ~= 'DEFSYM' and self.tt ~= 'LABELSYM' then
if self.tt ~= 'NUM' and self.tt ~= 'VARSYM' and self.tt ~= 'LABELSYM' then
self:error('expected constant', self.tt)
end
if no_label and self.tt == 'LABELSYM' then

View File

@ -52,7 +52,7 @@ function Preproc:process(tokens)
elseif peek.tt == 'EOL' or peek.tt == 'SEP' then
t.tt = 'RELLABELSYM'
t.tok = sign == 1 and '+' or sign == -1 and '-'
elseif peek.tt == 'DEFSYM' then
elseif peek.tt == 'VARSYM' then
t = self:advance()
else
self:error('expected a symbolic constant after unary operator')
@ -60,13 +60,13 @@ function Preproc:process(tokens)
end
if t.tt == nil then
error('Internal Error: missing token')
elseif t.tt == 'DEF' then
elseif t.tt == 'VAR' then
local t2 = self:advance()
if t2.tt ~= 'NUM' then
self:error('expected number for variable')
end
variables[t.tok] = t2.tok
elseif t.tt == 'DEFSYM' then
elseif t.tt == 'VARSYM' then
local tt = 'NUM'
local tok = variables[t.tok]
if tok == nil then