From 9fb29afc3e60261c6adb6bf36ff99326123b0baa Mon Sep 17 00:00:00 2001 From: Emin Arslan Date: Sat, 3 Jan 2026 20:49:17 +0300 Subject: [PATCH] syntactic_ast: Modified letrec forms to also accept a body --- lib/compiler/syntactic_ast.ml | 13 ++++++++++++- lib/compiler/syntactic_ast.mli | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/compiler/syntactic_ast.ml b/lib/compiler/syntactic_ast.ml index d0f4ab2..f0fe6e5 100644 --- a/lib/compiler/syntactic_ast.ml +++ b/lib/compiler/syntactic_ast.ml @@ -29,7 +29,7 @@ type _ t = | LetBinding : symbol * expression t -> binding 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 | Cond : clause t list -> expression t @@ -224,6 +224,17 @@ and print_expr = function (String.concat "\n" (map print_let_binding binds)) (print_defs defs) (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 | Apply (f, exprs) -> pf "(apply %s %s)" diff --git a/lib/compiler/syntactic_ast.mli b/lib/compiler/syntactic_ast.mli index 24bd2b6..6db8cb3 100644 --- a/lib/compiler/syntactic_ast.mli +++ b/lib/compiler/syntactic_ast.mli @@ -1,4 +1,5 @@ type symbol = string + (* These are just used for the GADT *) type expression type definition @@ -22,7 +23,7 @@ type _ t = | LetBinding : symbol * expression t -> binding 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 | Cond : clause t list -> expression t