Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / parsing_cocci / data.mli
1 (*
2 * Copyright 2012, INRIA
3 * Julia Lawall, Gilles Muller
4 * Copyright 2010-2011, INRIA, University of Copenhagen
5 * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
6 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
7 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
8 * This file is part of Coccinelle.
9 *
10 * Coccinelle is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, according to version 2 of the License.
13 *
14 * Coccinelle is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * The authors reserve the right to distribute this or future versions of
23 * Coccinelle under other licenses.
24 *)
25
26
27 (* types that clutter the .mly file *)
28 (* for iso metavariables, true if they can only match nonmodified, unitary
29 metavariables *)
30 type fresh = bool
31
32 type incl_iso =
33 Include of string | Iso of (string,string) Common.either
34 | Virt of string list (* virtual rules *)
35
36 type clt =
37 line_type * int * int * int * int (* starting spaces *) *
38 (Ast_cocci.added_string * Ast0_cocci.position_info) list (*code before*) *
39 (Ast_cocci.added_string * Ast0_cocci.position_info) list (*code after *) *
40 Ast0_cocci.anything list (* position variable, minus only *)
41
42 (* ---------------------------------------------------------------------- *)
43
44 and line_type =
45 MINUS | OPTMINUS | UNIQUEMINUS
46 | PLUS | PLUSPLUS
47 | CONTEXT | UNIQUE | OPT
48
49 type iconstraints = Ast_cocci.idconstraint
50 type econstraints = Ast0_cocci.constraints
51 type pconstraints = Ast_cocci.meta_name list
52
53 val in_rule_name : bool ref (* true if parsing the rule name *)
54 val in_meta : bool ref (* true if parsing the metavariable decls *)
55 val in_iso : bool ref (* true if parsing the isomorphisms *)
56 val in_generating : bool ref(* true if generating a rule *)
57 val ignore_patch_or_match : bool ref (* skip rules not satisfying virt *)
58 val in_prolog : bool ref (* true if parsing the beginning of an SP *)
59 val saw_struct : bool ref (* true if saw struct/union *)
60 val inheritable_positions : string list ref
61
62 val call_in_meta : (unit -> 'a) -> 'a
63
64 val all_metadecls : (string, Ast_cocci.metavar list) Hashtbl.t
65
66 val clear_meta: (unit -> unit) ref
67
68 val add_meta_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
69
70 val add_id_meta:
71 (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref
72
73 val add_virt_id_meta_found: (string -> string -> unit) ref
74
75 val add_virt_id_meta_not_found:
76 (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
77
78 val add_fresh_id_meta: (Ast_cocci.meta_name -> Ast_cocci.seed -> unit) ref
79
80 val add_type_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
81
82 val add_init_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
83
84 val add_initlist_meta:
85 (Ast_cocci.meta_name -> Ast_cocci.list_len -> Ast0_cocci.pure ->
86 unit) ref
87
88 val add_param_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
89
90 val add_paramlist_meta:
91 (Ast_cocci.meta_name -> Ast_cocci.list_len -> Ast0_cocci.pure ->
92 unit) ref
93
94 val add_const_meta:
95 (Type_cocci.typeC list option -> Ast_cocci.meta_name -> econstraints ->
96 Ast0_cocci.pure -> unit) ref
97
98 val add_err_meta:
99 (Ast_cocci.meta_name -> econstraints -> Ast0_cocci.pure -> unit) ref
100
101 val add_exp_meta:
102 (Type_cocci.typeC list option -> Ast_cocci.meta_name -> econstraints ->
103 Ast0_cocci.pure -> unit) ref
104
105 val add_idexp_meta:
106 (Type_cocci.typeC list option -> Ast_cocci.meta_name ->
107 econstraints -> Ast0_cocci.pure -> unit) ref
108
109 val add_local_idexp_meta:
110 (Type_cocci.typeC list option -> Ast_cocci.meta_name ->
111 econstraints -> Ast0_cocci.pure -> unit) ref
112
113 val add_explist_meta:
114 (Ast_cocci.meta_name -> Ast_cocci.list_len -> Ast0_cocci.pure ->
115 unit) ref
116
117 val add_decl_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
118
119 val add_field_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
120
121 val add_symbol_meta: (string -> unit) ref
122
123 val add_field_list_meta:
124 (Ast_cocci.meta_name -> Ast_cocci.list_len -> Ast0_cocci.pure -> unit) ref
125
126 val add_stm_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
127
128 val add_stmlist_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref
129
130 val add_func_meta:
131 (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref
132
133 val add_local_func_meta:
134 (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref
135
136 val add_declarer_meta:
137 (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref
138
139 val add_iterator_meta:
140 (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref
141
142 val add_pos_meta:
143 (Ast_cocci.meta_name -> pconstraints -> Ast_cocci.meta_collect -> unit) ref
144
145 val add_type_name: (string -> unit) ref
146
147 val add_declarer_name: (string -> unit) ref
148
149 val add_iterator_name: (string -> unit) ref
150
151 val init_rule: (unit -> unit) ref
152
153 val install_bindings: (string -> unit) ref