2 * ----------------------------------------------------------------------
11 let error_happened = ref false;;
13 let rec prerr_error e =
14 prerr_endline (string_of_exn e)
21 prerr_endline ("WARNING: " ^ w)
26 let compile in_filename out_filename print super_root pis comments =
28 let e = new element_impl default_extension in
29 make_spec_from_mapping
30 ~super_root_exemplar: e
31 ~default_pinstr_exemplar: e
33 ~data_exemplar: (new data_impl default_extension)
34 ~default_element_exemplar: e
35 ~element_mapping: (Hashtbl.create 1)
42 enable_super_root_node = super_root;
43 enable_pinstr_nodes = pis;
44 enable_comment_nodes = comments;
51 (from_file in_filename)
55 let ch = open_out out_filename in
56 Pxp_codewriter.write_document ch tree;
57 output_string ch "(create_document (new Pxp_types.drop_warnings) Pxp_yacc.default_spec) # write (Pxp_types.Out_channel stdout) `Enc_utf8;;\n";
61 tree # write (Out_channel stdout) `Enc_utf8;
64 error_happened := true;
70 let in_file = ref "" in
71 let out_file = ref "" in
72 let print_file = ref false in
73 let super_root = ref false in
74 let pis = ref false in
75 let comments = ref false in
77 [ "-in", (Arg.String (fun s -> in_file := s)),
78 " <file> Set the XML file to read";
79 "-out", (Arg.String (fun s -> out_file := s)),
80 " <file> Set the Ocaml file to write";
81 "-print", (Arg.Set print_file),
82 " Print the XML file in standard form";
83 "-super-root", Arg.Set super_root,
84 " Generate a super root node";
86 " Generate wrapper nodes for processing instructions";
87 "-comments", Arg.Set comments,
88 " Generate nodes for comments";
90 (fun x -> raise (Arg.Bad "Unexpected argument"))
92 usage: compile [ options ]
95 if !in_file = "" then begin
96 prerr_endline "No input file specified.";
99 if !out_file = "" then begin
100 prerr_endline "No output file specified.";
103 compile !in_file !out_file !print_file !super_root !pis !comments
108 if !error_happened then exit(1);;
110 (* ======================================================================
114 * Revision 1.1 2000/11/17 09:57:35 lpadovan
117 * Revision 1.4 2000/08/17 01:20:15 gerd
118 * Update: Also tested whether super root nodes, pinstr nodes
119 * and comment nodes work.
120 * Note: comment nodes are not fully tested yet.
122 * Revision 1.3 2000/08/16 23:44:19 gerd
123 * Updates because of changes of the PXP API.
125 * Revision 1.2 2000/07/16 17:54:15 gerd
126 * Updated because of PXP interface changes.
128 * Revision 1.1 2000/07/09 00:33:32 gerd