X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_notation%2Ftest_parser.ml;h=ce87368bf7ae54e8e937db11cbec27a37ba0caa9;hb=08791e80816548121e81e04d3ead8c9a5171d033;hp=58880b9d5b781279600bda07825dbb2cb652742d;hpb=ec54d490477ece51c19d79750dda9805ffda663c;p=helm.git diff --git a/helm/ocaml/cic_notation/test_parser.ml b/helm/ocaml/cic_notation/test_parser.ml index 58880b9d5..ce87368bf 100644 --- a/helm/ocaml/cic_notation/test_parser.ml +++ b/helm/ocaml/cic_notation/test_parser.ml @@ -29,6 +29,21 @@ 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 + Xml.pp_to_outchan (CicNotationPres.render_to_boxml id_to_uri t) oc; + close_out oc + let _ = let module P = CicNotationPt in let level = ref ~-1 in @@ -49,7 +64,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 @@ -90,16 +107,16 @@ let _ = CicNotationRew.ast_of_acic id_to_sort annterm in let time2 = Unix.gettimeofday () in - printf "ast creation took %f seconds\n" (time2 -. time1); - prerr_endline "===="; - print_endline (CicNotationPp.pp_term t); flush stdout; + prerr_endline (sprintf "ast creation took %f seconds\n" (time2 -. time1)); + prerr_endline "AST"; + prerr_endline (CicNotationPp.pp_term t); flush stdout; let time3 = Unix.gettimeofday () in let t' = CicNotationRew.pp_ast t in let time4 = Unix.gettimeofday () in - printf "pretty printing took %f seconds\n" (time4 -. time3); - print_endline (CicNotationPp.pp_term t'); flush stdout - ) + prerr_endline (sprintf "pretty printing took %f seconds\n" (time4 -. time3)); + prerr_endline (CicNotationPp.pp_term t'); + dump_xml t' id_to_uri "out.xml") (* CicNotationParser.print_l2_pattern ()) *) | 1 -> ignore (CicNotationParser.parse_syntax_pattern istream) | 2 ->