This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
compilation/tp/tp-reduce-reduce/functions-multiple-arguments/printer.ml
2023-10-23 16:00:15 +02:00

18 lines
398 B
OCaml

open AST
let string_of_exp e =
let rec aux = function
| Var x ->
x
| Int x ->
string_of_int x
| Add (e1, e2) ->
Printf.sprintf "(%s + %s)" (aux e1) (aux e2)
| Fun b ->
Printf.sprintf "(fun %s -> %s)"
(String.concat " " b.bound)
(aux b.body)
| App (f, a) ->
"(" ^ String.concat " " (List.map aux (f::a)) ^ ")"
in
aux e