Plasma GitLab Archive
Projects Blog Knowledge

#! /bin/sh
# (*
exec ../../ocaml-toploop "$0" "$@"
*)
use "../../ocaml-findlib";;

#require "pxp";;

let main() =
  let inname = ref "" in
  let outname = ref "" in
  let encoding = ref `Enc_iso88591 in
  Arg.parse
      [ "-out", Arg.String (fun s -> outname := s),
	     " Set the output file name";
	"-in", Arg.String (fun s -> inname := s),
	    "  Set the input file name";
	"-enc-utf8", Arg.Unit (fun _ -> encoding := `Enc_utf8),
	          "  Set the encoding to UTF-8 (instead of ISO-8859-1)";
      ]
      (fun _ -> raise(Arg.Bad "Unexpected argument"))
      "usage: dump-stdlib -in stdlib.xml -out stdlib.bin";

  if !inname = "" || !outname = "" then begin
    prerr_endline ("Bad usage (use -help to get synopsis)");
    exit 1;
  end;

  let config =
    { Pxp_yacc.default_config with
	Pxp_yacc.encoding = !encoding
    } in
  let source = Pxp_yacc.from_file !inname in
  let spec = Pxp_yacc.default_spec in
  let doc = Pxp_yacc.parse_document_entity config source spec in

  let out = open_out_bin !outname in

  Pxp_marshal.subtree_to_channel
    ~omit_positions:true
    out
    doc#root;
  close_out out
;;


main();;

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml