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.
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.
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.
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/>.
20 * The authors reserve the right to distribute this or future versions of
21 * Coccinelle under other licenses.
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.
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.
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.
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/>.
44 * The authors reserve the right to distribute this or future versions of
45 * Coccinelle under other licenses.
49 module Ast0
= Ast0_cocci
50 module Ast
= Ast_cocci
52 (* types that clutter the .mly file *)
53 (* for iso metavariables, true if they can only match nonmodified, unitary
58 Include
of string | Iso
of (string,string) Common.either
59 | Virt
of string list
(* virtual rules *)
62 line_type
* int * int * int * int (* starting spaces *) *
63 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code before *) *
64 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code after *) *
65 Ast0.meta_pos
(* position variable, minus only *)
67 (* ---------------------------------------------------------------------- *)
69 (* Things that need to be seen by the lexer and parser. *)
72 MINUS
| OPTMINUS
| UNIQUEMINUS
74 | CONTEXT
| UNIQUE
| OPT
76 type iconstraints
= Ast.idconstraint
77 type econstraints
= Ast0.constraints
78 type pconstraints
= Ast.meta_name list
80 let in_rule_name = ref false
81 let in_meta = ref false
82 let in_iso = ref false
83 let in_generating = ref false
84 let ignore_patch_or_match = ref false
85 let in_prolog = ref false
86 (* state machine for lexer..., allows smpl keywords as type names *)
87 let saw_struct = ref false
88 let inheritable_positions =
89 ref ([] : string list
) (* rules from which posns can be inherited *)
92 in_meta := true; saw_struct := false;
98 (Hashtbl.create
(100) : (string, Ast.metavar list
) Hashtbl.t
)
100 let clear_meta: (unit -> unit) ref =
101 ref (fun _
-> failwith
"uninitialized add_meta")
104 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
105 ref (fun _
-> failwith
"uninitialized add_meta")
107 let add_virt_id_meta_found: (string -> string -> unit) ref =
108 ref (fun _
-> failwith
"uninitialized add_meta")
110 let add_virt_id_meta_not_found:
111 (Ast_cocci.meta_name
-> Ast0_cocci.pure
-> unit) ref =
112 ref (fun _
-> failwith
"uninitialized add_meta")
114 let add_fresh_id_meta: (Ast.meta_name
-> unit) ref =
115 ref (fun _
-> failwith
"uninitialized add_meta")
117 let add_type_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
118 ref (fun _
-> failwith
"uninitialized add_meta")
120 let add_init_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
121 ref (fun _
-> failwith
"uninitialized add_meta")
123 let add_param_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
124 ref (fun _
-> failwith
"uninitialized add_meta")
126 let add_paramlist_meta:
127 (Ast.meta_name
-> Ast.list_len
-> Ast0.pure
-> unit) ref =
128 ref (fun _
-> failwith
"uninitialized add_meta")
131 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
134 ref (fun _
-> failwith
"uninitialized add_meta")
137 (Ast.meta_name
-> econstraints
-> Ast0.pure
-> unit) ref =
138 ref (fun _
-> failwith
"uninitialized add_meta")
141 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
144 ref (fun _
-> failwith
"uninitialized add_meta")
147 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
150 ref (fun _
-> failwith
"uninitialized add_meta")
152 let add_local_idexp_meta:
153 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
156 ref (fun _
-> failwith
"uninitialized add_meta")
158 let add_explist_meta:
159 (Ast.meta_name
-> Ast.list_len
-> Ast0.pure
-> unit) ref =
160 ref (fun _
-> failwith
"uninitialized add_meta")
162 let add_decl_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
163 ref (fun _
-> failwith
"uninitialized add_meta")
165 let add_field_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
166 ref (fun _
-> failwith
"uninitialized add_meta")
168 let add_stm_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
169 ref (fun _
-> failwith
"uninitialized add_meta")
171 let add_stmlist_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
172 ref (fun _
-> failwith
"uninitialized add_meta")
175 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
176 ref (fun _
-> failwith
"uninitialized add_meta")
178 let add_local_func_meta:
179 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
180 ref (fun _
-> failwith
"uninitialized add_meta")
182 let add_declarer_meta:
183 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
184 ref (fun _
-> failwith
"uninitialized add_decl")
186 let add_iterator_meta:
187 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
188 ref (fun _
-> failwith
"uninitialized add_iter")
191 (Ast.meta_name
-> pconstraints
-> Ast.meta_collect
-> unit) ref =
192 ref (fun _
-> failwith
"uninitialized add_meta")
194 let add_type_name: (string -> unit) ref =
195 ref (fun _
-> failwith
"uninitialized add_type")
197 let add_declarer_name: (string -> unit) ref =
198 ref (fun _
-> failwith
"uninitialized add_decl")
200 let add_iterator_name: (string -> unit) ref =
201 ref (fun _
-> failwith
"uninitialized add_iter")
203 let init_rule: (unit -> unit) ref =
204 ref (fun _
-> failwith
"uninitialized install_bindings")
206 let install_bindings: (string -> unit) ref =
207 ref (fun _
-> failwith
"uninitialized install_bindings")