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_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
71 ref (fun _ -> failwith "uninitialized add_meta")
73 let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
74 ref (fun _ -> failwith "uninitialized add_meta")
76 let add_paramlist_meta:
77 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
78 ref (fun _ -> failwith "uninitialized add_meta")
81 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
84 ref (fun _ -> failwith "uninitialized add_meta")
87 (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref =
88 ref (fun _ -> failwith "uninitialized add_meta")
91 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
94 ref (fun _ -> failwith "uninitialized add_meta")
97 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
100 ref (fun _ -> failwith "uninitialized add_meta")
102 let add_local_idexp_meta:
103 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
106 ref (fun _ -> failwith "uninitialized add_meta")
108 let add_explist_meta:
109 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
110 ref (fun _ -> failwith "uninitialized add_meta")
112 let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
113 ref (fun _ -> failwith "uninitialized add_meta")
115 let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
116 ref (fun _ -> failwith "uninitialized add_meta")
119 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
120 ref (fun _ -> failwith "uninitialized add_meta")
122 let add_local_func_meta:
123 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
124 ref (fun _ -> failwith "uninitialized add_meta")
126 let add_declarer_meta:
127 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
128 ref (fun _ -> failwith "uninitialized add_decl")
130 let add_iterator_meta:
131 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
132 ref (fun _ -> failwith "uninitialized add_iter")
135 (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref =
136 ref (fun _ -> failwith "uninitialized add_meta")
138 let add_type_name: (string -> unit) ref =
139 ref (fun _ -> failwith "uninitialized add_type")
141 let add_declarer_name: (string -> unit) ref =
142 ref (fun _ -> failwith "uninitialized add_decl")
144 let add_iterator_name: (string -> unit) ref =
145 ref (fun _ -> failwith "uninitialized add_iter")
147 let init_rule: (unit -> unit) ref =
148 ref (fun _ -> failwith "uninitialized install_bindings")
150 let install_bindings: (string -> unit) ref =
151 ref (fun _ -> failwith "uninitialized install_bindings")