Debian Codegraph @

tools/spgen/source/meta_variable.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 (* Extract all metavariables used in a rule. We can't really use the metavars
8 * returned by the parser since a lot of them are missing.
9 * This also means that metavariables declared in the header but unused in the
10 * rule are not included.
11 *)
12
13 (* ------------------------------------------------------------------------- *)
14 (* META_VARIABLE FUNCTIONS *)
15
16 type t
17
18 (* make a metavariable.
19 * - inherit_rule: if the metavariable is declared in a different rule than it
20 * appears in, set this to that rule's name. Default is "" (not inherited).
21 * - constraints: e.g "!=0" (default to "").
22 * - typ: type of the metavariable.
23 *)
24 val make :
25 ?inherit_rule:string ->
26 ?constraints:string ->
27 typ:string ->
28 string (* metavariable name *) ->
29 t
30
31 (* getters *)
32 val get_rule : t -> string
33 val get_name : t -> string
34 val tostring_mv : t -> string
35
36 (* adds inheritance of new_rule to the metavar.
37 * if force is false (default), inheritance is only added if the metavar is not
38 * already inherited. Otherwise, forcibly overwrite inheritance.
39 *)
40 val inherit_rule : ?force:bool -> new_rule:string -> t -> t
41
42 (* prints the metavariable in the format used in rule headers to out_channel *)
43 val print : out_channel -> t -> unit
44
45 (* prints the metavariables in the format used in rule headers to out_channel.
46 * if do_group, group by type.
47 *)
48 val print_list : out_channel -> do_group:bool -> t list -> unit
49
50 (* Given the minus abstract syntax tree (Ast0) for a rule, extracts all
51 * metavariables used in the rule.
52 * Rulename used to determine whether the metavariables are inherited or not.
53 *)
54 val extract : minus_rule:Ast0_cocci.rule -> rule_name:string -> t list