Debian Codegraph @

tools/spgen/source/user_input.mli

raw
1 (*
2 * This file is part of Coccinelle, licensed under the terms of the GPL v2.
3 * See copyright.txt in the Coccinelle source code for more information.
4 * The Coccinelle source code can be obtained at http://coccinelle.lip6.fr
5 *)
6
7 (* Types and functionality for user input
8 * Turns the raw input from the config/interactive into printable strings and
9 * information ready to use by the generators.
10 *)
11
12 (* ------------------------------------------------------------------------- *)
13 (* CONFIDENCE *)
14
15 (* The confidence level of the script. Low, Moderate, or High. *)
16
17 module Confidence : sig
18 type t = Low | Moderate | High
19
20 exception Not_confidence of string
21
22 val to_string : t -> string
23
24 (* fails with Not_confidence if the string is not l, m, h, low, moderate, or
25 * high. Case insensitive.
26 *)
27 val from_string : string -> t
28 end
29
30
31 (* ------------------------------------------------------------------------- *)
32 (* USER RULE *)
33
34 (* user-specified data (new name + org and report messages) for one rule. *)
35
36 module Rule : sig
37 type t
38
39 (* rule_name is the new rulename (or the original one if a new one is not
40 * needed). org and report are (error message, list of metavariables).
41 *)
42 val make :
43 rule_name:string ->
44 org:(string * string list) ->
45 report:(string * string list) ->
46 t
47
48 val get_name : t -> string
49 val get_org : t -> string * Meta_variable.t list
50 val get_report : t -> string * Meta_variable.t list
51 end
52
53
54 (* ------------------------------------------------------------------------- *)
55 (* USER INPUT *)
56
57 (* The user input type. encapsulates the stuff that is specified by the user*)
58 type t
59
60 (* constructor; description and confidence level are required *)
61 val make : description:string -> confidence:Confidence.t -> t
62
63 (* setters *)
64 val set_keys : string -> t -> t
65 val set_conf : Confidence.t -> t -> t
66 val set_comments : string -> t -> t
67 val set_options : string -> t -> t
68 val set_url : string -> t -> t
69 val set_limits : string list -> t -> t
70 val add_limit : string -> t -> t
71 val set_authors : string list -> t -> t
72 val add_author : string -> t -> t
73 val add_rule : rule_name:string -> Rule.t -> t -> t
74
75 (* check if there's already a rule with that name *)
76 val check_name : string -> t -> unit
77
78 (* get string formatted version of preface *)
79 val get_preface : year:int -> t -> string
80
81 (* returns rule with associated metadata, default generated if not found *)
82 val get_rule : rule_name:string -> t -> Rule.t
83
84 (* turns a user input into the config that generates it *)
85 val unparse : t -> string
86
87 (* format string checking *)
88 val check_format_string : string * string list -> unit
89 val count_format_vars : string -> int