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

don't use coroutines for lexing

this turned out to be unnecessary,
and some flavors of Lua don't even have coroutines!
This commit is contained in:
Connor Olding 2016-04-20 02:43:01 -07:00
parent a655e67bd3
commit c47136442e

View file

@ -226,27 +226,20 @@ end
function Parser:tokenize(asm)
self.i = 0
local routine = coroutine.create(function()
local lexer = Lexer(asm, self.main_fn, self.options)
lexer:lex(coroutine.yield)
end)
local tokens = {}
while true do
local ok, a, b, c, d = coroutine.resume(routine)
if not ok then
a = a or 'Internal Error: lexer coroutine has stopped'
error(a)
end
assert(a, 'Internal Error: missing token')
local t = Token(c, d, a, b)
local loop = true
while loop do
lexer:lex(function(tt, tok, fn, line)
assert(tt, 'Internal Error: missing token')
local t = Token(fn, line, tt, tok)
insert(tokens, t)
-- don't break if this is an included file's EOF
if t.tt == 'EOF' and t.fn == self.main_fn then
break
if tt == 'EOF' and fn == self.main_fn then
loop = false
end
end)
end
local preproc = Preproc(self.options)