mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
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
This commit is contained in:
parent
ea7720b7c3
commit
91948109ca
8 changed files with 1883 additions and 1093 deletions
26
compiler/lua51.can
Normal file
26
compiler/lua51.can
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue