Added desugar phase for converting cond into a chain of if's

This commit is contained in:
2025-12-27 17:00:16 +03:00
parent 93ba06a6b0
commit 9981c222eb
2 changed files with 39 additions and 16 deletions

View File

@@ -21,7 +21,11 @@ and dbg_print_start = function
let def = Parser.parse_str "(define (f x) (+ x 1))
(define (f)
(define (g y) (* y 2))
(or (g 5) (g 6)))";;
(or (g 5) (g 6)))
(cond
((> 1 2) 0)
((> 3 2) 3)
(t -1))";;
let desugared = List.map Compiler.Sugar.desugar def
let () = List.iter (fun x -> Printf.printf "%s\n" (dbg_print_start x) ) desugared
let () = print_newline ()