1
0
Fork 0
mirror of https://github.com/Reuh/candran.git synced 2025-10-27 17:59:30 +00:00
candran/compiler/lua51.can
Reuh 91948109ca Fixed using break and continue in the same loop, added vanilla Lua 5.1 target
somehow I never encountered this before... well now there's more tests
2019-08-23 19:50:49 +02:00

26 lines
642 B
Text

states.continue = {} -- when in a loop that use continue
CONTINUE_START = ()
return "local " .. var("break") .. newline() .. "repeat" .. indent() .. push("continue", var("break"))
end
CONTINUE_STOP = ()
return pop("continue") .. unindent() .. "until true" .. newline() .. "if " .. var("break") .. " then break end"
end
tags.Continue = ()
return "break"
end
tags.Break = ()
local inContinue = peek("continue")
if inContinue then
return inContinue .. " = true" .. newline() .. "break"
else
return "break"
end
end
#local patch = output
#output = ""
#import("compiler.luajit", { patch = patch, loadPackage = false })
return luajit