Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argument a plusieurs arguments ... #2465

Closed
vicuna opened this issue May 22, 2000 · 1 comment
Closed

argument a plusieurs arguments ... #2465

vicuna opened this issue May 22, 2000 · 1 comment

Comments

@vicuna
Copy link

vicuna commented May 22, 2000

Original bug ID: 124
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: fabrice le fessant
Version: 3.00
OS: linux...
Submission from: cremant.inria.fr (128.93.8.143)

Un nouveau constructeur List dans Arg.spec, pour prendre plusieurs arguments
apres
une option ...

arg.mli:

type spec =
| Unit of (unit -> unit) (* Call the function with unit 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 )
| Rest of (string -> unit) (
Stop interpreting keywords and call the
function with each remaining argument )
| List of spec list (
This argument takes several arguments )
(
The concrete type describing the behavior associated
with a keyword. *)

arg.ml:
type spec =
| Unit of (unit -> unit) (* Call the function with unit 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 )
| Rest of (string -> unit) (
Stop interpreting keywords and call the
function with each remaining argument *)
| List of spec list

let parse speclist anonfun errmsg =
...
let rec iter action =
match action with
| Unit f -> f ();
| Set r -> r := true;
| Clear r -> r := false;
| String f when !current + 1 < l ->
let arg = Sys.argv.(!current+1) in
f arg;
incr current;
| Int f when !current + 1 < l ->
let arg = Sys.argv.(!current+1) in
begin try f (int_of_string arg)
with Failure "int_of_string" -> stop (Wrong (s, arg, "an
int
eger"))
end;
incr current;
| Float f when !current + 1 < l ->
let arg = Sys.argv.(!current+1) in
f (float_of_string arg);
incr current;
| Rest f ->
while !current < l-1 do
f Sys.argv.(!current+1);
incr current;
done;
| List list ->
let rec iter_list list =
match list with
[] -> ()
| action :: tail ->
iter action;
iter_list tail
in
iter_list list
| _ -> stop (Missing s)
in
iter action

@vicuna
Copy link
Author

vicuna commented Jul 3, 2004

Comment author: administrator

Added Arg.Tuple 2003/04/25 PW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant