Added somw loops

This commit is contained in:
iko 2024-05-18 14:33:40 +03:00
parent 4ed8acbbb1
commit ad74107a2c
Signed by untrusted user: iko
GPG Key ID: 82C257048D1026F2
2 changed files with 49 additions and 0 deletions

View File

@ -467,6 +467,8 @@
[%label label]
[%goto label]
[%func-call functioncall]
[%while cond=expr body=blok]
[%repeat body=blok cond=expr]
[%break ~]
[%empty ~]
==
@ -478,6 +480,25 @@
::
(cold [%break ~] (jest 'break'))
::
%+ cook
|= [* cond=expr * body=blok *] [%while cond body]
;~ (glue wss)
(jest 'while')
parse-expr
(jest 'do')
parse-blok
(jest 'end')
==
::
%+ cook
|= [* body=blok * cond=expr] [%repeat body cond]
;~ (glue wss)
(jest 'repeat')
parse-blok
(jest 'until')
parse-expr
==
::
%+ cook
|= [* =label] [%goto label]
;~ (glue ws)
@ -531,6 +552,22 @@
"goto "
(trip +.stat)
==
%while
%- zing
:~
"while "
(print-expr cond.stat)
" do\0a"
(print-blok body.stat)
==
%repeat
%- zing
:~
"repeat\0a"
(print-blok body.stat)
"until "
(print-expr cond.stat)
==
==
:: functioncall
::

View File

@ -59,3 +59,15 @@ h{key1 = 'Sonmi~451'}
goto helli
break
while true do
break
end
repeat
do
foo = 9
;
end
until true