mirror of
https://github.com/notwa/lips
synced 2024-11-10 11:39:04 -08:00
rename internal DEF to VAR
This commit is contained in:
parent
486ccb99af
commit
91e028ef6a
4 changed files with 11 additions and 11 deletions
|
@ -9,7 +9,7 @@ local Muncher = require(path.."Muncher")
|
||||||
local arg_types = { -- for instructions
|
local arg_types = { -- for instructions
|
||||||
NUM = true,
|
NUM = true,
|
||||||
REG = true,
|
REG = true,
|
||||||
DEFSYM = true,
|
VARSYM = true,
|
||||||
LABELSYM = true,
|
LABELSYM = true,
|
||||||
RELLABELSYM = true,
|
RELLABELSYM = true,
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ function Collector:variable()
|
||||||
local t = self.t
|
local t = self.t
|
||||||
local t2 = self:advance()
|
local t2 = self:advance()
|
||||||
|
|
||||||
local s = self:statement('!DEF', t, t2)
|
local s = self:statement('!VAR', t, t2)
|
||||||
insert(self.statements, s)
|
insert(self.statements, s)
|
||||||
self:advance()
|
self:advance()
|
||||||
end
|
end
|
||||||
|
@ -165,7 +165,7 @@ function Collector:instruction()
|
||||||
insert(s, t)
|
insert(s, t)
|
||||||
elseif self.tt == 'UNARY' then
|
elseif self.tt == 'UNARY' then
|
||||||
local peek = self.tokens[self.i + 1]
|
local peek = self.tokens[self.i + 1]
|
||||||
if peek.tt == 'DEFSYM' then
|
if peek.tt == 'VARSYM' then
|
||||||
t = self:advance()
|
t = self:advance()
|
||||||
t = Token(t):set('negate')
|
t = Token(t):set('negate')
|
||||||
insert(s, t)
|
insert(s, t)
|
||||||
|
@ -216,7 +216,7 @@ function Collector:collect(tokens, fn)
|
||||||
elseif self.tt == 'EOL' then
|
elseif self.tt == 'EOL' then
|
||||||
-- empty line
|
-- empty line
|
||||||
self:advance()
|
self:advance()
|
||||||
elseif self.tt == 'DEF' then
|
elseif self.tt == 'VAR' then
|
||||||
self:variable() -- handles advancing
|
self:variable() -- handles advancing
|
||||||
elseif self.tt == 'LABEL' or self.tt == 'RELLABEL' then
|
elseif self.tt == 'LABEL' or self.tt == 'RELLABEL' then
|
||||||
insert(self.statements, self:statement('!LABEL', self.t))
|
insert(self.statements, self:statement('!LABEL', self.t))
|
||||||
|
|
|
@ -358,7 +358,7 @@ function Lexer:lex(_yield)
|
||||||
self:error('expected a colon after closing bracket')
|
self:error('expected a colon after closing bracket')
|
||||||
end
|
end
|
||||||
self:nextc()
|
self:nextc()
|
||||||
yield('DEF', buff)
|
yield('VAR', buff)
|
||||||
elseif self.chr == ']' then
|
elseif self.chr == ']' then
|
||||||
self:error('unmatched closing bracket')
|
self:error('unmatched closing bracket')
|
||||||
elseif self.chr == '(' then
|
elseif self.chr == '(' then
|
||||||
|
@ -391,7 +391,7 @@ function Lexer:lex(_yield)
|
||||||
elseif self.chr == '@' then
|
elseif self.chr == '@' then
|
||||||
self:nextc()
|
self:nextc()
|
||||||
local buff = self:read_chars('[%w_]')
|
local buff = self:read_chars('[%w_]')
|
||||||
yield('DEFSYM', buff)
|
yield('VARSYM', buff)
|
||||||
elseif self.chr == '%' then
|
elseif self.chr == '%' then
|
||||||
self:nextc()
|
self:nextc()
|
||||||
if self.chr:find('[%a_]') then
|
if self.chr:find('[%a_]') then
|
||||||
|
|
|
@ -9,7 +9,7 @@ local Token = require(path.."Token")
|
||||||
local arg_types = {
|
local arg_types = {
|
||||||
NUM = true,
|
NUM = true,
|
||||||
REG = true,
|
REG = true,
|
||||||
DEFSYM = true,
|
VARSYM = true,
|
||||||
LABELSYM = true,
|
LABELSYM = true,
|
||||||
RELLABELSYM = true,
|
RELLABELSYM = true,
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ function Muncher:deref()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Muncher:const(relative, no_label)
|
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)
|
self:error('expected constant', self.tt)
|
||||||
end
|
end
|
||||||
if no_label and self.tt == 'LABELSYM' then
|
if no_label and self.tt == 'LABELSYM' then
|
||||||
|
|
|
@ -52,7 +52,7 @@ function Preproc:process(tokens)
|
||||||
elseif peek.tt == 'EOL' or peek.tt == 'SEP' then
|
elseif peek.tt == 'EOL' or peek.tt == 'SEP' then
|
||||||
t.tt = 'RELLABELSYM'
|
t.tt = 'RELLABELSYM'
|
||||||
t.tok = sign == 1 and '+' or sign == -1 and '-'
|
t.tok = sign == 1 and '+' or sign == -1 and '-'
|
||||||
elseif peek.tt == 'DEFSYM' then
|
elseif peek.tt == 'VARSYM' then
|
||||||
t = self:advance()
|
t = self:advance()
|
||||||
else
|
else
|
||||||
self:error('expected a symbolic constant after unary operator')
|
self:error('expected a symbolic constant after unary operator')
|
||||||
|
@ -60,13 +60,13 @@ function Preproc:process(tokens)
|
||||||
end
|
end
|
||||||
if t.tt == nil then
|
if t.tt == nil then
|
||||||
error('Internal Error: missing token')
|
error('Internal Error: missing token')
|
||||||
elseif t.tt == 'DEF' then
|
elseif t.tt == 'VAR' then
|
||||||
local t2 = self:advance()
|
local t2 = self:advance()
|
||||||
if t2.tt ~= 'NUM' then
|
if t2.tt ~= 'NUM' then
|
||||||
self:error('expected number for variable')
|
self:error('expected number for variable')
|
||||||
end
|
end
|
||||||
variables[t.tok] = t2.tok
|
variables[t.tok] = t2.tok
|
||||||
elseif t.tt == 'DEFSYM' then
|
elseif t.tt == 'VARSYM' then
|
||||||
local tt = 'NUM'
|
local tt = 'NUM'
|
||||||
local tok = variables[t.tok]
|
local tok = variables[t.tok]
|
||||||
if tok == nil then
|
if tok == nil then
|
||||||
|
|
Loading…
Reference in a new issue