exception No_output let () = let usage = "" in let backend = ref "c" in let file = ref None in let ismodule = ref false in let arguments = [ "--backend", Arg.Set_string backend, "set backend (default \"c\")"; "--module" , Arg.Set ismodule , "build the source as a module"; ] in Arg.parse arguments (fun x -> file := Some x) usage; let channel = match !file with | None -> stdin | Some f -> open_in f in let buf = Lexing.from_channel channel in let ast = try Parser.main Lexer.token buf with | Lexer.Error msg -> Printf.fprintf stderr "%s%!" msg; exit 1 | Parser.Error -> Printf.fprintf stderr "At offset %d: syntax error.\n%!" (Lexing.lexeme_start buf); exit 1 in (match !backend with | "echo" -> Echo.print ast | "c" -> C.print !ismodule !file ast | _ -> failwith "Unknown backend" ); close_in channel; ()