mirror of
https://github.com/notwa/lips
synced 2024-05-19 00:33:23 -07: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:
parent
996d148ed5
commit
fffe542d10
|
@ -124,7 +124,7 @@ function Dumper:add_directive(line, name, a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Dumper:desym(tok)
|
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
|
if type(tok[2]) == 'number' then
|
||||||
return tok[2]
|
return tok[2]
|
||||||
elseif tok[1] == 'LABELSYM' then
|
elseif tok[1] == 'LABELSYM' then
|
||||||
|
|
|
@ -154,8 +154,8 @@ function Lexer:lex_hex(yield)
|
||||||
local entered = false
|
local entered = false
|
||||||
while true do
|
while true do
|
||||||
if self.chr == '\n' then
|
if self.chr == '\n' then
|
||||||
self:nextc()
|
|
||||||
yield('EOL', '\n')
|
yield('EOL', '\n')
|
||||||
|
self:nextc()
|
||||||
elseif self.ord == self.EOF then
|
elseif self.ord == self.EOF then
|
||||||
self:error('unexpected EOF; incomplete hex directive')
|
self:error('unexpected EOF; incomplete hex directive')
|
||||||
elseif self.chr == ';' then
|
elseif self.chr == ';' then
|
||||||
|
@ -206,8 +206,8 @@ end
|
||||||
function Lexer:lex_block_comment(yield)
|
function Lexer:lex_block_comment(yield)
|
||||||
while true do
|
while true do
|
||||||
if self.chr == '\n' then
|
if self.chr == '\n' then
|
||||||
self:nextc()
|
|
||||||
yield('EOL', '\n')
|
yield('EOL', '\n')
|
||||||
|
self:nextc()
|
||||||
elseif self.ord == self.EOF then
|
elseif self.ord == self.EOF then
|
||||||
self:error('unexpected EOF; incomplete block comment')
|
self:error('unexpected EOF; incomplete block comment')
|
||||||
elseif self.chrchr == '*/' then
|
elseif self.chrchr == '*/' then
|
||||||
|
@ -230,8 +230,8 @@ function Lexer:lex_string(yield)
|
||||||
while true do
|
while true do
|
||||||
if self.chr == '\n' then
|
if self.chr == '\n' then
|
||||||
self:error('unimplemented')
|
self:error('unimplemented')
|
||||||
self:nextc()
|
|
||||||
yield('EOL', '\n')
|
yield('EOL', '\n')
|
||||||
|
self:nextc()
|
||||||
elseif self.ord == self.EOF then
|
elseif self.ord == self.EOF then
|
||||||
self:nextc()
|
self:nextc()
|
||||||
self:error('unexpected EOF; incomplete string')
|
self:error('unexpected EOF; incomplete string')
|
||||||
|
@ -288,8 +288,8 @@ function Lexer:lex(_yield)
|
||||||
end
|
end
|
||||||
while true do
|
while true do
|
||||||
if self.chr == '\n' then
|
if self.chr == '\n' then
|
||||||
self:nextc()
|
|
||||||
yield('EOL', '\n')
|
yield('EOL', '\n')
|
||||||
|
self:nextc()
|
||||||
elseif self.ord == self.EOF then
|
elseif self.ord == self.EOF then
|
||||||
yield('EOF', self.EOF)
|
yield('EOF', self.EOF)
|
||||||
break
|
break
|
||||||
|
|
|
@ -258,10 +258,8 @@ function Parser:instruction()
|
||||||
local h = data.instructions[name]
|
local h = data.instructions[name]
|
||||||
self:advance()
|
self:advance()
|
||||||
|
|
||||||
-- FIXME: errors thrown here probably have the wrong line number (+1)
|
|
||||||
|
|
||||||
if h == nil then
|
if h == nil then
|
||||||
self:error('undefined instruction')
|
error('Internal Error: undefined instruction')
|
||||||
elseif overrides[name] then
|
elseif overrides[name] then
|
||||||
overrides[name](self, name)
|
overrides[name](self, name)
|
||||||
elseif h[2] == 'tob' then -- TODO: or h[2] == 'Tob' then
|
elseif h[2] == 'tob' then -- TODO: or h[2] == 'Tob' then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user