2 * Copyright 2005-2009, 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.
23 module Ast0
= Ast0_cocci
24 module Ast
= Ast_cocci
26 (* types that clutter the .mly file *)
27 (* for iso metavariables, true if they can only match nonmodified, unitary
32 Include
of string | Iso
of (string,string) Common.either
33 | Virt
of string list
(* virtual rules *)
36 line_type
* int * int * int * int (* starting spaces *) *
37 (string * Ast0.position_info
) list
(* code before *) *
38 (string * Ast0.position_info
) list
(* code after *) *
39 Ast0.meta_pos
(* position variable, minus only *)
41 (* ---------------------------------------------------------------------- *)
43 (* Things that need to be seen by the lexer and parser. *)
46 MINUS
| OPTMINUS
| UNIQUEMINUS
48 | CONTEXT
| UNIQUE
| OPT
50 type iconstraints
= Ast.idconstraint
51 type econstraints
= Ast0.constraints
52 type pconstraints
= Ast.meta_name list
54 let in_rule_name = ref false
55 let in_meta = ref false
56 let in_iso = ref false
57 let in_generating = ref false
58 let ignore_patch_or_match = ref false
59 let in_prolog = ref false
60 (* state machine for lexer..., allows smpl keywords as type names *)
61 let saw_struct = ref false
62 let inheritable_positions =
63 ref ([] : string list
) (* rules from which posns can be inherited *)
66 in_meta := true; saw_struct := false;
72 (Hashtbl.create
(100) : (string, Ast.metavar list
) Hashtbl.t
)
74 let clear_meta: (unit -> unit) ref =
75 ref (fun _
-> failwith
"uninitialized add_meta")
78 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
79 ref (fun _
-> failwith
"uninitialized add_meta")
81 let add_fresh_id_meta: (Ast.meta_name
-> unit) ref =
82 ref (fun _
-> failwith
"uninitialized add_meta")
84 let add_type_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
85 ref (fun _
-> failwith
"uninitialized add_meta")
87 let add_init_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
88 ref (fun _
-> failwith
"uninitialized add_meta")
90 let add_param_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
91 ref (fun _
-> failwith
"uninitialized add_meta")
93 let add_paramlist_meta:
94 (Ast.meta_name
-> Ast.meta_name
option -> Ast0.pure
-> unit) ref =
95 ref (fun _
-> failwith
"uninitialized add_meta")
98 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
101 ref (fun _
-> failwith
"uninitialized add_meta")
104 (Ast.meta_name
-> econstraints
-> Ast0.pure
-> unit) ref =
105 ref (fun _
-> failwith
"uninitialized add_meta")
108 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
111 ref (fun _
-> failwith
"uninitialized add_meta")
114 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
117 ref (fun _
-> failwith
"uninitialized add_meta")
119 let add_local_idexp_meta:
120 (Type_cocci.typeC list
option -> Ast.meta_name
-> econstraints
->
123 ref (fun _
-> failwith
"uninitialized add_meta")
125 let add_explist_meta:
126 (Ast.meta_name
-> Ast.meta_name
option -> Ast0.pure
-> unit) ref =
127 ref (fun _
-> failwith
"uninitialized add_meta")
129 let add_stm_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
130 ref (fun _
-> failwith
"uninitialized add_meta")
132 let add_stmlist_meta: (Ast.meta_name
-> Ast0.pure
-> unit) ref =
133 ref (fun _
-> failwith
"uninitialized add_meta")
136 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
137 ref (fun _
-> failwith
"uninitialized add_meta")
139 let add_local_func_meta:
140 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
141 ref (fun _
-> failwith
"uninitialized add_meta")
143 let add_declarer_meta:
144 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
145 ref (fun _
-> failwith
"uninitialized add_decl")
147 let add_iterator_meta:
148 (Ast.meta_name
-> iconstraints
-> Ast0.pure
-> unit) ref =
149 ref (fun _
-> failwith
"uninitialized add_iter")
152 (Ast.meta_name
-> pconstraints
-> Ast.meta_collect
-> unit) ref =
153 ref (fun _
-> failwith
"uninitialized add_meta")
155 let add_type_name: (string -> unit) ref =
156 ref (fun _
-> failwith
"uninitialized add_type")
158 let add_declarer_name: (string -> unit) ref =
159 ref (fun _
-> failwith
"uninitialized add_decl")
161 let add_iterator_name: (string -> unit) ref =
162 ref (fun _
-> failwith
"uninitialized add_iter")
164 let init_rule: (unit -> unit) ref =
165 ref (fun _
-> failwith
"uninitialized install_bindings")
167 let install_bindings: (string -> unit) ref =
168 ref (fun _
-> failwith
"uninitialized install_bindings")