2a5f0762ecc0c0da9770d12f44b0157203e425c0
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.
25 module Ast0
= Ast0_cocci
26 module Ast
= Ast_cocci
28 (* types that clutter the .mly file *)
29 (* for iso metavariables, true if they can only match nonmodified, unitary
34 Include
of string | Iso
of (string,string) Common.either
35 | Virt
of string list
(* virtual rules *)
38 line_type
* int * int * int * int (* starting spaces *) *
39 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code before *) *
40 (Ast_cocci.added_string
* Ast0.position_info
) list
(* code after *) *
41 Ast0.meta_pos
(* position variable, minus only *)
43 (* ---------------------------------------------------------------------- *)
45 (* Things that need to be seen by the lexer and parser. *)
48 MINUS
| OPTMINUS
| UNIQUEMINUS
50 | CONTEXT
| UNIQUE
| OPT
52 type iconstraints
= Ast.idconstraint
53 type econstraints
= Ast0.constraints
54 type pconstraints
= Ast.meta_name list
56 let in_rule_name = ref false
57 let in_meta = ref false
58 let in_iso = ref false
59 let in_generating = ref false
60 let ignore_patch_or_match = ref false
61 let in_prolog = ref false
62 (* state machine for lexer..., allows smpl keywords as type names *)
63 let saw_struct = ref false
64 let inheritable_positions =
65 ref ([] : string list
) (* rules from which posns can be inherited *)
68 in_meta := true; saw_struct := false;
74 (Hashtbl.create
(100) : (string, Ast.metavar list
) Hashtbl.t
)
76 let clear_meta: (unit -> unit) ref =
77 ref (fun _
-> failwith
"uninitialized add_meta")
79 let add_meta_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
80 ref (fun _
-> failwith
"uninitialized add_meta")
83 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
84 ref (fun _
-> failwith
"uninitialized add_meta")
86 let add_virt_id_meta_found: (string -> string -> unit) ref =
87 ref (fun _
-> failwith
"uninitialized add_meta")
89 let add_virt_id_meta_not_found:
90 (Ast_cocci.meta_name
-> Ast0_cocci.pure
-> unit) ref =
91 ref (fun _
-> failwith
"uninitialized add_meta")
93 let add_fresh_id_meta: (Ast.meta_name
-> unit) ref =
94 ref (fun _
-> failwith
"uninitialized add_meta")
96 let add_type_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
97 ref (fun _
-> failwith
"uninitialized add_meta")
99 let add_init_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
100 ref (fun _
-> failwith
"uninitialized add_meta")
102 let add_param_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
103 ref (fun _
-> failwith
"uninitialized add_meta")
105 let add_paramlist_meta:
106 (Ast.meta_name
-> Ast.list_len
-> Ast0.pure
-> unit) ref =
107 ref (fun _
-> failwith
"uninitialized add_meta")
110 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
113 ref (fun _
-> failwith
"uninitialized add_meta")
116 (Ast.meta_name
-> econstraints
-> Ast0.pure
-> unit) ref =
117 ref (fun _
-> failwith
"uninitialized add_meta")
120 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
123 ref (fun _
-> failwith
"uninitialized add_meta")
126 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
129 ref (fun _
-> failwith
"uninitialized add_meta")
131 let add_local_idexp_meta:
132 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
135 ref (fun _
-> failwith
"uninitialized add_meta")
137 let add_explist_meta:
138 (Ast.meta_name
-> Ast.list_len
-> Ast0.pure
-> unit) ref =
139 ref (fun _
-> failwith
"uninitialized add_meta")
141 let add_decl_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
142 ref (fun _
-> failwith
"uninitialized add_meta")
144 let add_field_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
145 ref (fun _
-> failwith
"uninitialized add_meta")
147 let add_stm_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
148 ref (fun _
-> failwith
"uninitialized add_meta")
150 let add_stmlist_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
151 ref (fun _
-> failwith
"uninitialized add_meta")
154 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
155 ref (fun _
-> failwith
"uninitialized add_meta")
157 let add_local_func_meta:
158 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
159 ref (fun _
-> failwith
"uninitialized add_meta")
161 let add_declarer_meta:
162 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
163 ref (fun _
-> failwith
"uninitialized add_decl")
165 let add_iterator_meta:
166 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
167 ref (fun _
-> failwith
"uninitialized add_iter")
170 (Ast.meta_name
-> pconstraints
-> Ast.meta_collect
-> unit) ref =
171 ref (fun _
-> failwith
"uninitialized add_meta")
173 let add_type_name: (string -> unit) ref =
174 ref (fun _
-> failwith
"uninitialized add_type")
176 let add_declarer_name: (string -> unit) ref =
177 ref (fun _
-> failwith
"uninitialized add_decl")
179 let add_iterator_name: (string -> unit) ref =
180 ref (fun _
-> failwith
"uninitialized add_iter")
182 let init_rule: (unit -> unit) ref =
183 ref (fun _
-> failwith
"uninitialized install_bindings")
185 let install_bindings: (string -> unit) ref =
186 ref (fun _
-> failwith
"uninitialized install_bindings")