-(**********************************************************************\r
-\r
-let rec string_of_term = function\r
- | Tvar n -> string_of_int n\r
- | Tapp(t1, t2) -> "(" ^ string_of_term t1 ^ " " ^ string_of_term t2 ^ ")"\r
- | Tlam(t1) -> "(\\" ^ string_of_term t1 ^ ")"\r
-;;\r
-\r
-let _ = prerr_endline (">>>" ^ string_of_term (parse "(\\x. x y z z1 k) z1 z j"));;\r
-\r
-\r
-**********************************************************************)\r
-\r
- let parse' strs =\r
- let (tms, free) = parse_many strs in\r
- (* Replace pacmans and bottoms *)\r
- let n_bot = try Util.index_of "BOT" free with Not_found -> min_int in\r
- let n_pac = try Util.index_of "PAC" free with Not_found -> min_int in\r
- let n_bomb = try Util.index_of "BOMB" free with Not_found -> min_int in\r
- let n_z = try Util.index_of "Z" free with Not_found -> min_int in\r
- let fix lev v =\r
- if v = lev + n_bot then failwith "Example with `Bottom"\r
- else if v = lev + n_pac then failwith "Example with `Pacman"\r
- else if v = lev + n_bomb then failwith "Example with `Bomb"\r
- else if v = lev + n_z then `Var(lev, 0) (* FIXME why zero? *)\r
- else `Var(v,1) in (* 1 by default when variable not applied *)\r
- (* Fix arity *)\r
- let open Num in\r
- let rec aux lev : nf -> nf = function\r
- | `I((n,_), args) -> `I((n,1 + Listx.length args), Listx.map (fun t -> aux lev t) args)\r
- | `Var(n,_) -> fix lev n\r
- | `Lam(_,t) -> `Lam (true, aux (lev+1) t)\r
- | `Match _ | `N _ -> assert false in\r
- List.map (aux 0) (tms :> Num.nf list), free\r
-;;\r
-\r