2 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
24 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
25 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
26 * This file is part of Coccinelle.
28 * Coccinelle is free software: you can redistribute it and/or modify
29 * it under the terms of the GNU General Public License as published by
30 * the Free Software Foundation, according to version 2 of the License.
32 * Coccinelle is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
37 * You should have received a copy of the GNU General Public License
38 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
40 * The authors reserve the right to distribute this or future versions of
41 * Coccinelle under other licenses.
45 module Ast0
= Ast0_cocci
46 module Ast
= Ast_cocci
48 (* types that clutter the .mly file *)
49 (* for iso metavariables, true if they can only match nonmodified, unitary
54 Include
of string | Iso
of (string,string) Common.either
55 | Virt
of string list
(* virtual rules *)
58 line_type
* int * int * int * int (* starting spaces *) *
59 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code before *) *
60 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code after *) *
61 Ast0.meta_pos
(* position variable, minus only *)
63 (* ---------------------------------------------------------------------- *)
65 (* Things that need to be seen by the lexer and parser. *)
68 MINUS
| OPTMINUS
| UNIQUEMINUS
70 | CONTEXT
| UNIQUE
| OPT
72 type iconstraints
= Ast.idconstraint
73 type econstraints
= Ast0.constraints
74 type pconstraints
= Ast.meta_name list
76 let in_rule_name = ref false
77 let in_meta = ref false
78 let in_iso = ref false
79 let in_generating = ref false
80 let ignore_patch_or_match = ref false
81 let in_prolog = ref false
82 (* state machine for lexer..., allows smpl keywords as type names *)
83 let saw_struct = ref false
84 let inheritable_positions =
85 ref ([] : string list
) (* rules from which posns can be inherited *)
88 in_meta := true; saw_struct := false;
94 (Hashtbl.create
(100) : (string, Ast.metavar list
) Hashtbl.t
)
96 let clear_meta: (unit -> unit) ref =
97 ref (fun _
-> failwith
"uninitialized add_meta")
100 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
101 ref (fun _
-> failwith
"uninitialized add_meta")
103 let add_virt_id_meta_found: (string -> string -> unit) ref =
104 ref (fun _
-> failwith
"uninitialized add_meta")
106 let add_virt_id_meta_not_found:
107 (Ast_cocci.meta_name
-> Ast0_cocci.pure
-> unit) ref =
108 ref (fun _
-> failwith
"uninitialized add_meta")
110 let add_fresh_id_meta: (Ast.meta_name
-> unit) ref =
111 ref (fun _
-> failwith
"uninitialized add_meta")
113 let add_type_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
114 ref (fun _
-> failwith
"uninitialized add_meta")
116 let add_init_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
117 ref (fun _
-> failwith
"uninitialized add_meta")
119 let add_param_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
120 ref (fun _
-> failwith
"uninitialized add_meta")
122 let add_paramlist_meta:
123 (Ast.meta_name
-> Ast.meta_name
option -> Ast0.pure
-> unit) ref =
124 ref (fun _
-> failwith
"uninitialized add_meta")
127 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
130 ref (fun _
-> failwith
"uninitialized add_meta")
133 (Ast.meta_name
-> econstraints
-> Ast0.pure
-> unit) ref =
134 ref (fun _
-> failwith
"uninitialized add_meta")
137 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
140 ref (fun _
-> failwith
"uninitialized add_meta")
143 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
146 ref (fun _
-> failwith
"uninitialized add_meta")
148 let add_local_idexp_meta:
149 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
152 ref (fun _
-> failwith
"uninitialized add_meta")
154 let add_explist_meta:
155 (Ast.meta_name
-> Ast.meta_name
option -> Ast0.pure
-> unit) ref =
156 ref (fun _
-> failwith
"uninitialized add_meta")
158 let add_stm_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
159 ref (fun _
-> failwith
"uninitialized add_meta")
161 let add_stmlist_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
162 ref (fun _
-> failwith
"uninitialized add_meta")
165 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
166 ref (fun _
-> failwith
"uninitialized add_meta")
168 let add_local_func_meta:
169 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
170 ref (fun _
-> failwith
"uninitialized add_meta")
172 let add_declarer_meta:
173 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
174 ref (fun _
-> failwith
"uninitialized add_decl")
176 let add_iterator_meta:
177 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
178 ref (fun _
-> failwith
"uninitialized add_iter")
181 (Ast.meta_name
-> pconstraints
-> Ast.meta_collect
-> unit) ref =
182 ref (fun _
-> failwith
"uninitialized add_meta")
184 let add_type_name: (string -> unit) ref =
185 ref (fun _
-> failwith
"uninitialized add_type")
187 let add_declarer_name: (string -> unit) ref =
188 ref (fun _
-> failwith
"uninitialized add_decl")
190 let add_iterator_name: (string -> unit) ref =
191 ref (fun _
-> failwith
"uninitialized add_iter")
193 let init_rule: (unit -> unit) ref =
194 ref (fun _
-> failwith
"uninitialized install_bindings")
196 let install_bindings: (string -> unit) ref =
197 ref (fun _
-> failwith
"uninitialized install_bindings")