1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-11-14 10:09:03 -08:00

fix most line numbers in errors

this might be a bit of a hack;
i feel like nextc() should always happen after yield(),
not a mix of before and after.
This commit is contained in:
Connor Olding 2016-01-14 10:26:56 -08:00
parent 996d148ed5
commit fffe542d10
3 changed files with 6 additions and 8 deletions

View file

@ -124,7 +124,7 @@ function Dumper:add_directive(line, name, a, b)
end
function Dumper:desym(tok)
-- FIXME: errors can give wrong filename, also off by one
-- FIXME: errors can give wrong filename
if type(tok[2]) == 'number' then
return tok[2]
elseif tok[1] == 'LABELSYM' then

View file

@ -154,8 +154,8 @@ function Lexer:lex_hex(yield)
local entered = false
while true do
if self.chr == '\n' then
self:nextc()
yield('EOL', '\n')
self:nextc()
elseif self.ord == self.EOF then
self:error('unexpected EOF; incomplete hex directive')
elseif self.chr == ';' then
@ -206,8 +206,8 @@ end
function Lexer:lex_block_comment(yield)
while true do
if self.chr == '\n' then
self:nextc()
yield('EOL', '\n')
self:nextc()
elseif self.ord == self.EOF then
self:error('unexpected EOF; incomplete block comment')
elseif self.chrchr == '*/' then
@ -230,8 +230,8 @@ function Lexer:lex_string(yield)
while true do
if self.chr == '\n' then
self:error('unimplemented')
self:nextc()
yield('EOL', '\n')
self:nextc()
elseif self.ord == self.EOF then
self:nextc()
self:error('unexpected EOF; incomplete string')
@ -288,8 +288,8 @@ function Lexer:lex(_yield)
end
while true do
if self.chr == '\n' then
self:nextc()
yield('EOL', '\n')
self:nextc()
elseif self.ord == self.EOF then
yield('EOF', self.EOF)
break

View file

@ -258,10 +258,8 @@ function Parser:instruction()
local h = data.instructions[name]
self:advance()
-- FIXME: errors thrown here probably have the wrong line number (+1)
if h == nil then
self:error('undefined instruction')
error('Internal Error: undefined instruction')
elseif overrides[name] then
overrides[name](self, name)
elseif h[2] == 'tob' then -- TODO: or h[2] == 'Tob' then