2018-02-15 21:26:15 +01:00
|
|
|
module S = Tail
|
|
|
|
|
2018-02-15 22:01:14 +01:00
|
|
|
open PrettyCommon
|
2018-02-15 21:26:15 +01:00
|
|
|
|
|
|
|
let rec fmt_block fmt (S.Lam (self, vars, body)) =
|
|
|
|
Format.fprintf fmt "λ%a(%a) ·@ %a"
|
|
|
|
fmt_self self
|
|
|
|
fmt_vars vars
|
|
|
|
fmt_term body
|
|
|
|
|
|
|
|
and fmt_term fmt (t: S.term) = match t with
|
|
|
|
| S.Exit ->
|
|
|
|
Format.fprintf fmt "Exit";
|
|
|
|
| S.TailCall(fct, args) ->
|
|
|
|
Format.fprintf fmt "Call %a %a" fmt_val fct fmt_vals args
|
|
|
|
| S.Print (value, next) ->
|
|
|
|
Format.fprintf fmt "Print %a;@ %a" fmt_val value fmt_term next
|
|
|
|
| S.LetVal (var, value, next) ->
|
|
|
|
Format.fprintf fmt "@[<v 4>let %a = %a@] in@ %a"
|
|
|
|
fmt_var var fmt_val value fmt_term next
|
|
|
|
| S.LetBlo (var, block, next) ->
|
|
|
|
Format.fprintf fmt "@[<v 4>let %a = %a@] in@ %a"
|
|
|
|
fmt_var var fmt_block block fmt_term next
|
2018-02-16 00:43:44 +01:00
|
|
|
| S.IfZero (cond, tIf, tElse) ->
|
|
|
|
Format.fprintf fmt "@[<v 4>ifzero %a then@ %a@]@ @[<v 4>else@ %a@]@ "
|
|
|
|
fmt_val cond
|
|
|
|
fmt_term tIf
|
|
|
|
fmt_term tElse
|
2018-02-15 21:26:15 +01:00
|
|
|
|
|
|
|
let show term =
|
2018-02-15 22:28:26 +01:00
|
|
|
Format.asprintf "@[<v 0>%a@]" fmt_term term
|