control flow
This commit is contained in:
@@ -43,6 +43,30 @@ to-funcons:
|
||||
to-funcons:
|
||||
|[ execute[: fun(:Id:)((:Params:))(:Block:) :] ]| ->
|
||||
|[ null ]|
|
||||
to-funcons:
|
||||
|[ execute[: if((:Exp:))(:Block:) :] ]| ->
|
||||
|[ if-else (eval-exp[: (:Exp:) :],
|
||||
execute-block[: (:Block:) :],
|
||||
null) ]|
|
||||
to-funcons:
|
||||
|[ execute[: if((:Exp:))(:Block1:)else(:Block2:) :] ]| ->
|
||||
|[ if-else (eval-exp[: (:Exp:) :],
|
||||
execute-block[: (:Block1:) :],
|
||||
execute-block[: (:Block2:) :]) ]|
|
||||
to-funcons:
|
||||
|[ execute[: while((:Exp:))(:Block:) :] ]| ->
|
||||
|[ while (eval-exp[: (:Exp:) :],
|
||||
execute-block[: (:Block:) :]) ]|
|
||||
to-funcons:
|
||||
|[ execute[: for(int(:Id:)=(:Exp1:);(:Exp2:))(:Block:) :] ]| ->
|
||||
|[ scope (bind (id[: (:Id:) :],
|
||||
allocate-initialised-variable (integers,
|
||||
eval-exp[: (:Exp1:) :])),
|
||||
while (eval-exp[: (:Exp2:) :],
|
||||
sequential (execute-block[: (:Block:) :],
|
||||
assign (bound id[: (:Id:) :],
|
||||
int-add (1,
|
||||
assigned bound id[: (:Id:) :]))))) ]|
|
||||
to-funcons:
|
||||
|[ execute[: :] ]| ->
|
||||
|[ null ]|
|
||||
|
||||
Reference in New Issue
Block a user