diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1995-09-05 12:30:26 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1995-09-05 12:30:26 +0000 |
commit | 4832a208b5f2ab83a073680c2db6e3f44185755c (patch) | |
tree | 72bffcc878b833b72890163352d990b5fbc64788 /stdlib | |
parent | 777dab66ba319f1167f8039a4560d861be226922 (diff) |
Introduction de Arg.Set et Arg.Clear.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@249 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/arg.ml | 12 | ||||
-rw-r--r-- | stdlib/arg.mli | 14 |
2 files changed, 16 insertions, 10 deletions
diff --git a/stdlib/arg.ml b/stdlib/arg.ml index 0d214b7a9..3cd16739f 100644 --- a/stdlib/arg.ml +++ b/stdlib/arg.ml @@ -12,10 +12,12 @@ (* $Id$ *) type spec = - String of (string -> unit) - | Int of (int -> unit) - | Unit of (unit -> unit) - | Float of (float -> unit) + Unit of (unit -> unit) (* Call the function with no argument *) + | Set of bool ref (* Set the reference to true *) + | Clear of bool ref (* Set the reference to false *) + | String of (string -> unit) (* Call the function with a string argument *) + | Int of (int -> unit) (* Call the function with an int argument *) + | Float of (float -> unit) (* Call the function with a float argument *) exception Bad of string @@ -59,6 +61,8 @@ let parse speclist anonfun = try match (action, l) with (Unit f, l) -> f (); p l + | (Set r, l) -> r := true; p l + | (Clear r, l) -> r := false; p l | (String f, arg::t) -> f arg; p t | (Int f, arg::t) -> begin try f (int_of_string arg) diff --git a/stdlib/arg.mli b/stdlib/arg.mli index d40a7068a..b7fb1a464 100644 --- a/stdlib/arg.mli +++ b/stdlib/arg.mli @@ -19,8 +19,8 @@ (* Syntax of command lines: A keyword is a character string starting with a [-]. An option is a keyword alone or followed by an argument. - There are four types of keywords: [Unit], [String], [Int], and [Float]. - [Unit] keywords do not take an argument. + There are six types of keywords: [Unit], [String], [Int], and [Float]. + [Unit], [Set_flag] and [Clear_flag] keywords do not take an argument. [String], [Int], and [Float] keywords take the following word on the command line as an argument. Arguments not preceded by a keyword are called anonymous arguments. *) @@ -34,10 +34,12 @@ *) type spec = - String of (string -> unit) - | Int of (int -> unit) - | Unit of (unit -> unit) - | Float of (float -> unit) + Unit of (unit -> unit) (* Call the function with no argument *) + | Set of bool ref (* Set the reference to true *) + | Clear of bool ref (* Set the reference to false *) + | String of (string -> unit) (* Call the function with a string argument *) + | Int of (int -> unit) (* Call the function with an int argument *) + | Float of (float -> unit) (* Call the function with a float argument *) (* The concrete type describing the behavior associated with a keyword. *) |