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