2 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
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 line_type * int * int * int * int (* starting spaces *) *
33 string list (* code before *) * string list (* code after *) *
34 Ast0.meta_pos (* position variable, minus only *)
36 (* ---------------------------------------------------------------------- *)
38 (* Things that need to be seen by the lexer and parser. *)
41 MINUS | OPTMINUS | UNIQUEMINUS
43 | CONTEXT | UNIQUE | OPT
45 type iconstraints = Ast0.ident list
46 type econstraints = Ast0.expression list
47 type pconstraints = Ast.meta_name list
49 let in_rule_name = ref false
50 let in_meta = ref false
51 let in_iso = ref false
52 let in_generating = ref false
53 let in_prolog = ref false
54 let inheritable_positions =
55 ref ([] : string list) (* rules from which posns can be inherited *)
58 (Hashtbl.create(100) : (string, Ast.metavar list) Hashtbl.t)
60 let clear_meta: (unit -> unit) ref =
61 ref (fun _ -> failwith "uninitialized add_meta")
64 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
65 ref (fun _ -> failwith "uninitialized add_meta")
67 let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
68 ref (fun _ -> failwith "uninitialized add_meta")
70 let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
71 ref (fun _ -> failwith "uninitialized add_meta")
73 let add_paramlist_meta:
74 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
75 ref (fun _ -> failwith "uninitialized add_meta")
78 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
81 ref (fun _ -> failwith "uninitialized add_meta")
84 (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref =
85 ref (fun _ -> failwith "uninitialized add_meta")
88 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
91 ref (fun _ -> failwith "uninitialized add_meta")
94 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
97 ref (fun _ -> failwith "uninitialized add_meta")
99 let add_local_idexp_meta:
100 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
103 ref (fun _ -> failwith "uninitialized add_meta")
105 let add_explist_meta:
106 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
107 ref (fun _ -> failwith "uninitialized add_meta")
109 let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
110 ref (fun _ -> failwith "uninitialized add_meta")
112 let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
113 ref (fun _ -> failwith "uninitialized add_meta")
116 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
117 ref (fun _ -> failwith "uninitialized add_meta")
119 let add_local_func_meta:
120 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
121 ref (fun _ -> failwith "uninitialized add_meta")
123 let add_declarer_meta:
124 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
125 ref (fun _ -> failwith "uninitialized add_decl")
127 let add_iterator_meta:
128 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
129 ref (fun _ -> failwith "uninitialized add_iter")
132 (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref =
133 ref (fun _ -> failwith "uninitialized add_meta")
135 let add_type_name: (string -> unit) ref =
136 ref (fun _ -> failwith "uninitialized add_type")
138 let add_declarer_name: (string -> unit) ref =
139 ref (fun _ -> failwith "uninitialized add_decl")
141 let add_iterator_name: (string -> unit) ref =
142 ref (fun _ -> failwith "uninitialized add_iter")
144 let init_rule: (unit -> unit) ref =
145 ref (fun _ -> failwith "uninitialized install_bindings")
147 let install_bindings: (string -> unit) ref =
148 ref (fun _ -> failwith "uninitialized install_bindings")