on master help sign in
Added somw loops
ad74107iko
zod/luau/lib/lua.hoon+37
@@ -467,6 +467,8 @@
467 [%label label]
467 [%label label]
468 [%goto label]
468 [%goto label]
469 [%func-call functioncall]
469 [%func-call functioncall]
470+ [%while cond=expr body=blok]
471+ [%repeat body=blok cond=expr]
470 [%break ~]
472 [%break ~]
471 [%empty ~]
473 [%empty ~]
472 ==
474 ==
@@ -478,6 +480,25 @@
478 ::
480 ::
479 (cold [%break ~] (jest 'break'))
481 (cold [%break ~] (jest 'break'))
480 ::
482 ::
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+ ::
481 %+ cook
502 %+ cook
482 |= [* =label] [%goto label]
503 |= [* =label] [%goto label]
483 ;~ (glue ws)
504 ;~ (glue ws)
@@ -531,6 +552,22 @@
531 "goto "
552 "goto "
532 (trip +.stat)
553 (trip +.stat)
533 ==
554 ==
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+ ==
534 ==
571 ==
535:: functioncall
572:: functioncall
536::
573::
zod/luau/tests/foo.lua+12
@@ -59,3 +59,15 @@ h{key1 = 'Sonmi~451'}
59goto helli
59goto helli
60
60
61break
61break
62+
63+while true do
64+ break
65+end
66+
67+repeat
68+do
69+ foo = 9
70+ ;
71+end
72+until true
73+