X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fpxp%2Fpxp%2Fexamples%2Freadme%2Fmain.ml;fp=helm%2FDEVEL%2Fpxp%2Fpxp%2Fexamples%2Freadme%2Fmain.ml;h=4e3837aa98832de0168616a9a96b19c0cad4c0e8;hb=c03d2c1fdab8d228cb88aaba5ca0f556318bebc5;hp=0000000000000000000000000000000000000000;hpb=758057e85325f94cd88583feb1fdf6b038e35055;p=helm.git diff --git a/helm/DEVEL/pxp/pxp/examples/readme/main.ml b/helm/DEVEL/pxp/pxp/examples/readme/main.ml new file mode 100644 index 000000000..4e3837aa9 --- /dev/null +++ b/helm/DEVEL/pxp/pxp/examples/readme/main.ml @@ -0,0 +1,108 @@ +(* $Id$ + * ---------------------------------------------------------------------- + * + *) + +open Pxp_types +open Pxp_document +open Pxp_yacc + + +let rec print_error e = + prerr_endline(string_of_exn e) +;; + + +let run f a = + try f a with + e -> print_error e +;; + + +let convert_to_html filename = + (* read in style definition *) + let document = + parse_document_entity + { default_config with encoding = `Enc_iso88591 } + (from_file filename) + To_html.tag_map + in + let root = document # root in + let store = new To_html.store in + root # extension # to_html store stdout +;; + + +let convert_to_text filename = + (* read in style definition *) + let document = + parse_document_entity + default_config + (from_file filename) + To_text.tag_map + in + let root = document # root in + let store = new To_text.store in + let box = new To_text.box 79 79 in + root # extension # to_box store box; + box # output 0 0 stdout +;; + + +let main() = + let want_html = ref false in + let want_text = ref false in + let filename = ref None in + Arg.parse + [ "-html", Arg.Set want_html, + " convert file to html"; + "-text", Arg.Set want_text, + " convert file to text"; + ] + (fun s -> + match !filename with + None -> filename := Some s + | Some _ -> + raise (Arg.Bad "Multiple arguments not allowed.")) + "usage: readme [ -text | -html ] input.xml >output"; + let fn = + match !filename with + None -> + prerr_endline "readme: no input"; + exit 1 + | Some s -> s + in + match !want_html, !want_text with + true, false -> + run convert_to_html fn + | false, true -> + run convert_to_text fn + | _ -> + prerr_endline ("readme: Please select exactly one output format") +;; + +main();; + +(* ====================================================================== + * History: + * + * $Log$ + * Revision 1.1 2000/11/17 09:57:31 lpadovan + * Initial revision + * + * Revision 1.5 2000/07/08 17:58:17 gerd + * Updated because of PXP API changes. + * + * Revision 1.4 2000/06/04 20:25:38 gerd + * Updates because of renamed PXP modules. + * + * Revision 1.3 2000/05/01 16:46:40 gerd + * Using the new error formatter. + * + * Revision 1.2 1999/08/23 16:54:19 gerd + * Minor changes. + * + * Revision 1.1 1999/08/22 22:29:32 gerd + * Initial revision. + * + *)