]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/cic_transformations/boxPp.ml
new (box based) pretty printer
[helm.git] / helm / ocaml / cic_transformations / boxPp.ml
1
2 let to_string object_to_string b =
3   let layout = ref [] in
4   let rec aux_h current_s =
5     function
6         [] -> layout := current_s::!layout
7       | Box.Text (_,s)::tl -> aux_h (current_s ^ s) tl
8       | (Box.Space _)::_ -> assert false
9       | Box.H (_,bl)::tl -> aux_h current_s (bl@tl)
10       | Box.V (_,[])::tl -> aux_h current_s tl
11       | Box.V (_,[b])::tl -> aux_h current_s (b::tl)
12       | Box.V (_,b::bl')::tl ->
13           aux_h current_s [b] ; 
14           aux_h (String.make (String.length current_s) ' ') (Box.V([],bl')::tl)
15       | Box.Object (_,obj)::tl -> aux_h (current_s ^ (object_to_string obj)) tl
16       | (Box.Action _)::tl -> assert false
17   in
18     aux_h "" [b] ;
19     List.rev !layout
20
21 let pp_term t = String.concat "\n" (to_string CicAstPp.pp_term (Ast2pres.ast2box t))