From 996ab8bc2039c3bb1c3caa8686d47cf00fc1f28c Mon Sep 17 00:00:00 2001 From: iko Date: Fri, 17 May 2024 23:30:50 +0300 Subject: [PATCH] Returns --- zod/luau/lib/lua.hoon | 40 +++++++++++++++++++++++++++++++++++++--- zod/luau/tests/foo.lua | 5 +++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/zod/luau/lib/lua.hoon b/zod/luau/lib/lua.hoon index 4bbfe86..60de9ac 100644 --- a/zod/luau/lib/lua.hoon +++ b/zod/luau/lib/lua.hoon @@ -532,17 +532,51 @@ == :: Blok :: -+$ blok (lest stat) ++$ blok [body=(lest stat) ret=(unit ret)] ++ print-blok |= [=blok] ^- tape %- zing %+ join "\0a" - (turn blok print-stat) + %+ weld + (turn body.blok print-stat) + ?~ ret.blok ~ + ~[(print-ret u.ret.blok)] ++ parse-blok %+ knee *blok |. - (most wss parse-stat) + ;~ plug + (most wss parse-stat) + :: + %- punt + ;~ pfix + wss + parse-ret + == + == +:: ret +:: ++$ ret exprlist +++ print-ret + |= =ret + ^- tape + %- zing + :~ + "return " + (print-exprlist ret) + == +++ parse-ret + %+ knee *ret + |. + %+ cook + |= [[* =exprlist] *] exprlist + ;~ plug + ;~ (glue wss) + (jest 'return') + parse-exprlist + == + (punt (just ';')) + == :: Helpers :: ++ commaed diff --git a/zod/luau/tests/foo.lua b/zod/luau/tests/foo.lua index 5ab8c64..1aad1fc 100644 --- a/zod/luau/tests/foo.lua +++ b/zod/luau/tests/foo.lua @@ -44,3 +44,8 @@ foo = { 3.0, 3.1416, 314.16e-2, 0.31416E1, 34e1, 0x0.1E, 0xA23p-4, 0xA23p-4, 0X1.921FB54442D18P+1, 0x1.fp10 } + +do + foo = 1 + return 8, foo; +end