module A = Arg module F = Filename module L = List module O = Options module TP = TextParser module TL = TextLexer module TU = TextUnparser module P1 = Pass1 module P2 = Pass2 module P3 = Pass3 module M = Matrix module XU = XmlUnparser let help = "" let help_L = "" let help_O = "" let help_X = "" let help_d0 = "" let help_d1 = "" let help_d2 = "" let help_e1 = "" let help_e2 = "" let help_p0 = "" let help_p1 = "" let help_p2 = "" let hook = "xhtbl" let includes, tables = ref [], ref [] let set_output_dir s = O.output_dir := s let process_directive och bname (name, table, css) = tables := name :: !tables; if !O.d0 then TU.debug table; if not !O.p0 then begin let size = P1.process table in if !O.d1 then TU.debug table; if not !O.p1 then begin let matrix = M.make size in let _ = P2.process table matrix in if !O.d2 then TU.debug table; if not !O.p2 then P3.process css matrix; let name = if name = "" then bname else name in XU.output och name matrix end end let process_file fname = let bname = F.chop_extension (F.basename fname) in let ich = open_in fname in let lexbuf = Lexing.from_channel ich in let ds = TP.script TL.token lexbuf in close_in ich; includes := bname :: !includes; let och = XU.open_out true bname in L.iter (process_directive och bname) ds; XU.close_out och let main () = A.parse [ "-L", A.Set O.debug_lexer, help_L; "-O", A.String set_output_dir, help_O; "-X", A.Unit O.clear, help_X; "-d0", A.Set O.d0, help_d0; "-d1", A.Set O.d1, help_d1; "-d2", A.Set O.d2, help_d2; "-e1", A.Set O.e1, help_e1; "-e2", A.Set O.e2, help_e2; "-p0", A.Set O.p0, help_p0; "-p1", A.Set O.p1, help_p1; "-p2", A.Set O.p2, help_p2; ] process_file help; XU.write_hook hook !includes !tables let _ = main ()