From d200cf6df19c97db5881bebf319182fe95171c04 Mon Sep 17 00:00:00 2001 From: Damien Doligez Date: Fri, 29 Aug 2003 17:33:45 +0000 Subject: [PATCH] PR#1803 git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5815 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- lex/common.ml | 2 ++ lex/common.mli | 2 ++ lex/main.ml | 4 +++- lex/output.ml | 15 ++++++++------- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lex/common.ml b/lex/common.ml index 53b58650eda5..f56e7a869de2 100644 --- a/lex/common.ml +++ b/lex/common.ml @@ -149,3 +149,5 @@ let output_env oc env = let output_args oc args = List.iter (fun x -> (output_string oc x; output_char oc ' ')) args +(* quiet flag *) +let quiet_mode = ref false;; diff --git a/lex/common.mli b/lex/common.mli index 2647dfb8a6e2..4210d21d882e 100644 --- a/lex/common.mli +++ b/lex/common.mli @@ -21,3 +21,5 @@ val output_memory_actions : string -> out_channel -> Lexgen.memory_action list -> unit val output_env : out_channel -> (string * Lexgen.ident_info) list -> unit val output_args : out_channel -> string list -> unit + +val quiet_mode : bool ref;; diff --git a/lex/main.ml b/lex/main.ml index 0c61ee7e5119..d1416c07b7e4 100644 --- a/lex/main.ml +++ b/lex/main.ml @@ -18,6 +18,7 @@ open Syntax open Lexgen let ml_automata = ref false +let quiet_mode = ref false let source_name = ref None let output_name = ref None @@ -26,8 +27,9 @@ let usage = "usage: ocamlex [options] sourcefile" let specs = ["-ml", Arg.Set ml_automata, " Output code that does not use the Lexing module built-in automata interpreter"; - "-o", Arg.String (fun x -> source_name := Some x), + "-o", Arg.String (fun x -> source_name := Some x), " Set output file name to "; + "-q", Arg.Set Common.quiet_mode, " Do not display informational messages"; ] let _ = diff --git a/lex/output.ml b/lex/output.ml index 53345aa8c505..c01b76ff0389 100644 --- a/lex/output.ml +++ b/lex/output.ml @@ -108,12 +108,13 @@ let output_entry sourcefile ic oc oci e = exception Table_overflow let output_lexdef sourcefile ic oc oci header tables entry_points trailer = - Printf.printf "%d states, %d transitions, table size %d bytes\n" - (Array.length tables.tbl_base) - (Array.length tables.tbl_trans) - (2 * (Array.length tables.tbl_base + Array.length tables.tbl_backtrk + - Array.length tables.tbl_default + Array.length tables.tbl_trans + - Array.length tables.tbl_check)); + if not !Common.quiet_mode then + Printf.printf "%d states, %d transitions, table size %d bytes\n" + (Array.length tables.tbl_base) + (Array.length tables.tbl_trans) + (2 * (Array.length tables.tbl_base + Array.length tables.tbl_backtrk + + Array.length tables.tbl_default + Array.length tables.tbl_trans + + Array.length tables.tbl_check)); let size_groups = (2 * (Array.length tables.tbl_base_code + Array.length tables.tbl_backtrk_code + @@ -121,7 +122,7 @@ let output_lexdef sourcefile ic oc oci header tables entry_points trailer = Array.length tables.tbl_trans_code + Array.length tables.tbl_check_code) + Array.length tables.tbl_code) in - if size_groups > 0 then + if size_groups > 0 && not !Common.quiet_mode then Printf.printf "%d additional bytes used for bindings\n" size_groups ; flush stdout; if Array.length tables.tbl_trans > 0x8000 then raise Table_overflow;