1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is the parser that reads the configuration file of helm *)
10 (******************************************************************************)
14 Sys.getenv "HELM_STYLECONFIGURATION_PATH"
17 let tmp_filename = C.tmpdir ^ "/style-configuration.xml" in
18 if Sys.file_exists tmp_filename then tmp_filename
20 let styleconf = Getter.raw_get "getstyleconf" in
21 let out_channel = open_out tmp_filename in
22 output_string out_channel styleconf;
23 close_out out_channel;
32 print_endline ("WARNING: " ^ w) ;
33 (raise Warnings : unit)
38 let module Y = Pxp_yacc in
40 let config = {Y.default_config with Y.warner = new warner} in
41 Y.parse_document_entity config (Y.from_file filename) Y.default_spec
44 print_endline (Pxp_types.string_of_exn e) ;
48 exception Impossible;;
50 let styles = Hashtbl.create 13;;
51 let applies = Hashtbl.create 13;;
53 (* we trust the xml file to be valid because of the validating xml parser *)
58 match n#node_type with
59 Pxp_document.T_element "style" ->
65 Hashtbl.add styles key n#data
66 | Pxp_document.T_element "apply" ->
69 match n#node_type with
70 Pxp_document.T_element "style-ref" -> n#attribute "key"
71 | _ -> raise Impossible
75 Hashtbl.add applies (n#attribute "name") keys
76 | _ -> raise Impossible
78 ((xml_document ())#root#sub_nodes)
81 let style_of_key key =
82 Hashtbl.lookup styles key
84 let key_list_of_mode_name name =
85 Hashtbl.lookup applies name