]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_notation/test_parser.ml
snapshot
[helm.git] / helm / ocaml / cic_notation / test_parser.ml
index 58880b9d5b781279600bda07825dbb2cb652742d..0ff7c558e119e3435d461e382998e727d5cbe1e0 100644 (file)
@@ -29,6 +29,22 @@ let _ =
   Helm_registry.load_from "test_parser.conf.xml"
 (*   Http_getter.init () *)
 
+let xml_stream_of_markup =
+  let rec print_box (t: CicNotationPres.boxml_markup) =
+    Box.box2xml print_mpres t
+  and print_mpres (t: CicNotationPres.mathml_markup) =
+    Mpresentation.print_mpres print_box t
+  in
+  print_mpres
+
+let dump_xml t id_to_uri fname =
+  print_endline (sprintf "dumping MathML to %s ..." fname);
+  flush stdout;
+  let oc = open_out fname in
+  let markup = CicNotationPres.render id_to_uri t in
+  Xml.pp_to_outchan (xml_stream_of_markup markup) oc;
+  close_out oc
+
 let _ =
   let module P = CicNotationPt in
   let level = ref ~-1 in
@@ -49,7 +65,9 @@ let _ =
                 prerr_endline "====";
                 print_endline (CicNotationPp.pp_term t); flush stdout;
                 let t' = CicNotationRew.pp_ast t in
-                print_endline (CicNotationPp.pp_term t'); flush stdout
+                print_endline (CicNotationPp.pp_term t'); flush stdout;
+                let tbl = Hashtbl.create 0 in
+                dump_xml t' tbl "out.xml"
             | P.Notation (l1, associativity, precedence, l2) ->
                 print_endline "Extending parser ..."; flush stdout;
                 let time1 = Unix.gettimeofday () in
@@ -98,6 +116,7 @@ let _ =
                 let t' = CicNotationRew.pp_ast t in
                 let time4 = Unix.gettimeofday () in
                 printf "pretty printing took %f seconds\n" (time4 -. time3);
+                dump_xml t id_to_uri "out.xml";
                 print_endline (CicNotationPp.pp_term t'); flush stdout
                 )
 (*                 CicNotationParser.print_l2_pattern ()) *)