[SOLVED] CS open Types

$25

File Name: CS_open_Types.zip
File Size: 122.46 KB

5/5 - (1 vote)

open Types
open Format

let string_of_const =
function True -> true
| False ->false
| Int n -> string_of_int n
let string_of_op =
function
Plus -> (+)
| Minus -> (-)
| Times -> (*)
| Div -> (/)
| Lt -> (<)”| Gt -> (>)
| Le -> (<=)”| Ge -> (>=)
| Eq -> (=)
| And -> (&&)
| Or -> (||)

let rec fprint_val f =
function Const c -> fprintf f %s (string_of_const c)
| Fun (x, e) -> fprintf f @[ fun %s ->@ %a@] x fprint_exp e
| Op o -> fprintf f %s (string_of_op o)
and fprint_exp f =
function Var v -> fprintf f %s v
| Value v -> fprint_val f v
| Let (x, e1, e2) ->
fprintf f @[ let %s =@ %a@ in@ @[ %a@]@]
x
fprint_exp e1
fprint_exp e2
| If (e1, e2, e3) ->
fprintf f @[ if@ %a@ then@ %a@ else@ %a@]
fprint_exp e1
fprint_exp e2
fprint_exp e3
| App (e1, e2) ->
fprintf f @[ app@ %a@ to@ %a@]
fprint_exp e1
fprint_exp e2
let pprint_exp e =
(fprint_exp Format.std_formatter e;
Format.print_newline ())

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS open Types
$25