syntactic_ast: Modified letrec forms to also accept a body
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
2026-01-03 20:49:17 +03:00
parent 17e533dbb8
commit 9fb29afc3e
2 changed files with 14 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ type _ t =
| LetBinding : symbol * expression t -> binding t | LetBinding : symbol * expression t -> binding t
| Let : binding t list * body t -> expression t | Let : binding t list * body t -> expression t
| LetRec : binding t list * expression t list -> expression t | LetRec : binding t list * body t -> expression t
| CondClause : expression t * expression t -> clause t | CondClause : expression t * expression t -> clause t
| Cond : clause t list -> expression t | Cond : clause t list -> expression t
@@ -224,6 +224,17 @@ and print_expr = function
(String.concat "\n" (map print_let_binding binds)) (String.concat "\n" (map print_let_binding binds))
(print_defs defs) (print_defs defs)
(print_exprs exprs) (print_exprs exprs)
| LetRec (binds, Body (defs, exprs)) ->
pf "(letrec
; BINDINGS
%s
; BODY
%s
; EXPRESSIONS
%s)"
(String.concat "\n" (map print_let_binding binds))
(print_defs defs)
(print_exprs exprs)
| Var s -> s | Var s -> s
| Apply (f, exprs) -> | Apply (f, exprs) ->
pf "(apply %s %s)" pf "(apply %s %s)"

View File

@@ -1,4 +1,5 @@
type symbol = string type symbol = string
(* These are just used for the GADT *) (* These are just used for the GADT *)
type expression type expression
type definition type definition
@@ -22,7 +23,7 @@ type _ t =
| LetBinding : symbol * expression t -> binding t | LetBinding : symbol * expression t -> binding t
| Let : binding t list * body t -> expression t | Let : binding t list * body t -> expression t
| LetRec : binding t list * expression t list -> expression t | LetRec : binding t list * body t -> expression t
| CondClause : expression t * expression t -> clause t | CondClause : expression t * expression t -> clause t
| Cond : clause t list -> expression t | Cond : clause t list -> expression t