on master help sign in
Added somw loops
commitad74107a2c4debd359b0eca98fa5288ba1e2e194 authoriko <mail@iko.soy> dateSat 18 May 2024, 14:33 (2 years ago) parent4ed8acb
2 files changed+49
zod/luau/lib/lua.hoon+37 zod/luau/tests/foo.lua+12
zod/luau/lib/lua.hoon+37
@@ -467,6 +467,8 @@
467467 [%label label]
468468 [%goto label]
469469 [%func-call functioncall]
470+ [%while cond=expr body=blok]
471+ [%repeat body=blok cond=expr]
470472 [%break ~]
471473 [%empty ~]
472474 ==
@@ -478,6 +480,25 @@
478480 ::
479481 (cold [%break ~] (jest 'break'))
480482 ::
483+ %+ cook
484+ |= [* cond=expr * body=blok *] [%while cond body]
485+ ;~ (glue wss)
486+ (jest 'while')
487+ parse-expr
488+ (jest 'do')
489+ parse-blok
490+ (jest 'end')
491+ ==
492+ ::
493+ %+ cook
494+ |= [* body=blok * cond=expr] [%repeat body cond]
495+ ;~ (glue wss)
496+ (jest 'repeat')
497+ parse-blok
498+ (jest 'until')
499+ parse-expr
500+ ==
501+ ::
481502 %+ cook
482503 |= [* =label] [%goto label]
483504 ;~ (glue ws)
@@ -531,6 +552,22 @@
531552 "goto "
532553 (trip +.stat)
533554 ==
555+ %while
556+ %- zing
557+ :~
558+ "while "
559+ (print-expr cond.stat)
560+ " do\0a"
561+ (print-blok body.stat)
562+ ==
563+ %repeat
564+ %- zing
565+ :~
566+ "repeat\0a"
567+ (print-blok body.stat)
568+ "until "
569+ (print-expr cond.stat)
570+ ==
534571 ==
535572:: functioncall
536573::
zod/luau/tests/foo.lua+12
@@ -59,3 +59,15 @@ h{key1 = 'Sonmi~451'}
5959goto helli
6060
6161break
62+
63+while true do
64+ break
65+end
66+
67+repeat
68+do
69+ foo = 9
70+ ;
71+end
72+until true
73+