on master help sign in
break and goto
commit4ed8acbbb10b001622fce04fcfd12735325423af authoriko <mail@iko.soy> dateSat 18 May 2024, 13:33 (2 years ago) parent907ae4d
3 files changed+23
zod/luau/TODO.md+1 zod/luau/lib/lua.hoon+18 zod/luau/tests/foo.lua+4
zod/luau/TODO.md+1
@@ -3,3 +3,4 @@
33- [ ] functioncall
44- [ ] any string apart from the basic string with no escapes
55- [ ] check if int fits in int or make it a float
6+- [ ] strip out comments before parsing
zod/luau/lib/lua.hoon+18
@@ -465,7 +465,9 @@
465465 [%blok blok]
466466 [%asmnt varlist exprlist]
467467 [%label label]
468+ [%goto label]
468469 [%func-call functioncall]
470+ [%break ~]
469471 [%empty ~]
470472 ==
471473++ parse-stat
@@ -474,6 +476,15 @@
474476 ;~ pose
475477 (cold [%empty ~] (just ';'))
476478 ::
479+ (cold [%break ~] (jest 'break'))
480+ ::
481+ %+ cook
482+ |= [* =label] [%goto label]
483+ ;~ (glue ws)
484+ (jest 'goto')
485+ parse-name
486+ ==
487+ ::
477488 %+ cook
478489 |= =label [%label label]
479490 parse-label
@@ -513,6 +524,13 @@
513524 ==
514525 %label (print-label +.stat)
515526 %func-call (print-functioncall +.stat)
527+ %break "break"
528+ %goto
529+ %- zing
530+ :~
531+ "goto "
532+ (trip +.stat)
533+ ==
516534 ==
517535:: functioncall
518536::
zod/luau/tests/foo.lua+4
@@ -55,3 +55,7 @@ print('the way of the future')
5555print 'hello'
5656
5757h{key1 = 'Sonmi~451'}
58+
59+goto helli
60+
61+break