Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

command_line_luc_exe.ml 3.18 KB
Newer Older
1
(*-----------------------------------------------------------------------
2
** Copyright (C) 2002 - Verimag.
3
4
5
6
** This file may only be copied under the terms of the GNU Library General
** Public License 
**-----------------------------------------------------------------------
**
7
** File: command_line_luc_exe.ml
8
9
10
11
12
** Main author: jahier@imag.fr
*)


type optionsT = {
13
  mutable show_automata : bool ;
14
  mutable boot : bool ;
15
  mutable user_seed : int 
16
17
18
}

type cmd_line_optionT = 
19
    Seed | Inside | Edges | Vertices | Precision | Boot | ShowAut | NoShowAut | Verbose
20
21
22
23

(* Names of the command line options to override the defaults. *)
let (string_to_option: (string * cmd_line_optionT) list) = [
  ("--boot", Boot);
24
25
  ("-boot", Boot);
  ("-b", Boot);
26
27

  ("--with-seed", Seed);
28
29
  ("-seed", Seed);

30
31
32
33
  ("--precision", Precision);

  ("--draw-inside", Inside);
  ("--draw-edges", Edges);
34
  ("--draw-vertices", Vertices);
35

36
37
38
  ("--show-aut", ShowAut);
  ("-s", ShowAut);

39
  ("--no-show-aut", NoShowAut);
40

41
42
  ("--verbose", Verbose);
  ("-v", Verbose)
43
44
45
46
47
]

let (option_to_usage: cmd_line_optionT -> string) =
  fun opt -> 
    match opt with
48
	Boot -> "The automata starts generating values.\n"
49
      |	ShowAut -> "Run lucky showing the lucky automata.\n"
50
      | NoShowAut ->  "Do not show the luc automata (Default).\n"
51
52
53
      | Precision ->  "Set the precision used for numerical values (number of digits).\n"
      | Inside -> "Draw inside the convex hull of solutions.\n "
      | Edges -> "Draw inside the convex hull of solutions, but a little bit more at edges and vertices.\n "
54
      | Vertices -> "Draw among the vertices of the convex hull of solutions.\n "
55
      |	Seed -> "Set the value of the seed the random engine is initialized with (0 lets the system draw a seed).\n"
56
      | Verbose -> "Set on a verbose mode.\n"
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

let (group_common_options: (string * cmd_line_optionT) list -> 
       (string * cmd_line_optionT) list) =
  fun list -> 
    List.fold_left
      (fun acc (str, opt) -> 
         match acc with
             (str2, opt2)::tail -> 
	       if 
		 (opt = opt2)
	       then
		 (((str2  ^ "\n\t\t" ^ str), opt)::tail)
	       else
		 ((str, opt)::(str2, opt2)::tail)
	   | [] -> [(str, opt)]
      )
      []
      list
let usage_options = 
  List.fold_left 
    (fun acc (str, opt) -> acc ^ "\n\t\t" ^ str ^ "\n\t\t\t" ^ (option_to_usage opt))
    ""
    (List.rev (group_common_options string_to_option))

let usage = 
82
  ("\n\nusage: lucky [options]* <file>.luc ([x] <file>.luc)* \n" ^
83
   "   where: " ^
84
   "\n\t o `<file>.luc contains an environment automata. Environments " ^
85
86
87
88
89
90
   "\n\t   separated by `x' will executed as if their automata where " ^
   "\n\t   multiplied (necessary if they have common output variables).\n " ^

   "\n\t o `options' is a list of options. The available options are: " ^ 
   usage_options ^ "\n\n" ^

91
   "Example:  lucky env1.luc x env2.luc x env3.luc env4\n\t" ^
92
93
94
95
96
97
98
99
100
101
102
103
   "will run the environment `env1', `env2', and `env3' as a product,  \n\t" ^
   "and `env4' in parallel.\n\n ")


let cmd_line_string_to_int str errmsg =
  try 
    (int_of_string str) 
  with Failure("int_of_string") 
      -> 
	print_string usage ;
	print_string errmsg ;
	flush stdout ;
104
	failwith "\n *** Error when calling lucky.\n"
105
106