Commit | Line | Data |
---|---|---|
0708f913 C |
1 | (* |
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. | |
5 | * | |
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. | |
9 | * | |
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. | |
14 | * | |
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/>. | |
17 | * | |
18 | * The authors reserve the right to distribute this or future versions of | |
19 | * Coccinelle under other licenses. | |
20 | *) | |
21 | ||
22 | ||
23 | module Ast0 = Ast0_cocci | |
24 | module Ast = Ast_cocci | |
25 | ||
26 | (* types that clutter the .mly file *) | |
27 | (* for iso metavariables, true if they can only match nonmodified, unitary | |
28 | metavariables *) | |
29 | type fresh = bool | |
30 | ||
31 | type clt = | |
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 *) | |
35 | ||
36 | (* ---------------------------------------------------------------------- *) | |
37 | ||
38 | (* Things that need to be seen by the lexer and parser. *) | |
39 | ||
40 | and line_type = | |
41 | MINUS | OPTMINUS | UNIQUEMINUS | |
42 | | PLUS | |
43 | | CONTEXT | UNIQUE | OPT | |
44 | ||
45 | type iconstraints = Ast0.ident list | |
46 | type econstraints = Ast0.expression list | |
47 | type pconstraints = Ast.meta_name list | |
48 | ||
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 *) | |
56 | ||
57 | let all_metadecls = | |
58 | (Hashtbl.create(100) : (string, Ast.metavar list) Hashtbl.t) | |
59 | ||
60 | let clear_meta: (unit -> unit) ref = | |
61 | ref (fun _ -> failwith "uninitialized add_meta") | |
62 | ||
63 | let add_id_meta: | |
64 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
65 | ref (fun _ -> failwith "uninitialized add_meta") | |
66 | ||
67 | let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
68 | ref (fun _ -> failwith "uninitialized add_meta") | |
69 | ||
70 | let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
71 | ref (fun _ -> failwith "uninitialized add_meta") | |
72 | ||
73 | let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
74 | ref (fun _ -> failwith "uninitialized add_meta") | |
75 | ||
76 | let add_paramlist_meta: | |
77 | (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref = | |
78 | ref (fun _ -> failwith "uninitialized add_meta") | |
79 | ||
80 | let add_const_meta: | |
81 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
82 | Ast0.pure -> unit) | |
83 | ref = | |
84 | ref (fun _ -> failwith "uninitialized add_meta") | |
85 | ||
86 | let add_err_meta: | |
87 | (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref = | |
88 | ref (fun _ -> failwith "uninitialized add_meta") | |
89 | ||
90 | let add_exp_meta: | |
91 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
92 | Ast0.pure -> unit) | |
93 | ref = | |
94 | ref (fun _ -> failwith "uninitialized add_meta") | |
95 | ||
96 | let add_idexp_meta: | |
97 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
98 | Ast0.pure -> unit) | |
99 | ref = | |
100 | ref (fun _ -> failwith "uninitialized add_meta") | |
101 | ||
102 | let add_local_idexp_meta: | |
103 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
104 | Ast0.pure -> unit) | |
105 | ref = | |
106 | ref (fun _ -> failwith "uninitialized add_meta") | |
107 | ||
108 | let add_explist_meta: | |
109 | (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref = | |
110 | ref (fun _ -> failwith "uninitialized add_meta") | |
111 | ||
112 | let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
113 | ref (fun _ -> failwith "uninitialized add_meta") | |
114 | ||
115 | let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
116 | ref (fun _ -> failwith "uninitialized add_meta") | |
117 | ||
118 | let add_func_meta: | |
119 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
120 | ref (fun _ -> failwith "uninitialized add_meta") | |
121 | ||
122 | let add_local_func_meta: | |
123 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
124 | ref (fun _ -> failwith "uninitialized add_meta") | |
125 | ||
126 | let add_declarer_meta: | |
127 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
128 | ref (fun _ -> failwith "uninitialized add_decl") | |
129 | ||
130 | let add_iterator_meta: | |
131 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
132 | ref (fun _ -> failwith "uninitialized add_iter") | |
133 | ||
134 | let add_pos_meta: | |
135 | (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref = | |
136 | ref (fun _ -> failwith "uninitialized add_meta") | |
137 | ||
138 | let add_type_name: (string -> unit) ref = | |
139 | ref (fun _ -> failwith "uninitialized add_type") | |
140 | ||
141 | let add_declarer_name: (string -> unit) ref = | |
142 | ref (fun _ -> failwith "uninitialized add_decl") | |
143 | ||
144 | let add_iterator_name: (string -> unit) ref = | |
145 | ref (fun _ -> failwith "uninitialized add_iter") | |
146 | ||
147 | let init_rule: (unit -> unit) ref = | |
148 | ref (fun _ -> failwith "uninitialized install_bindings") | |
149 | ||
150 | let install_bindings: (string -> unit) ref = | |
151 | ref (fun _ -> failwith "uninitialized install_bindings") |