Release coccinelle-0.2.3rc1
[bpt/coccinelle.git] / parsing_cocci / visitor_ast0_types.ml
1 (*
2 * Copyright 2005-2010, 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.
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 (*
24 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
25 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
26 * This file is part of Coccinelle.
27 *
28 * Coccinelle is free software: you can redistribute it and/or modify
29 * it under the terms of the GNU General Public License as published by
30 * the Free Software Foundation, according to version 2 of the License.
31 *
32 * Coccinelle is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License
38 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
39 *
40 * The authors reserve the right to distribute this or future versions of
41 * Coccinelle under other licenses.
42 *)
43
44
45 module Ast0 = Ast0_cocci
46 module Ast = Ast_cocci
47
48 type ('a,'n) inout = 'a -> ('n * 'a)
49
50 type 'n all_functions =
51 {ident : (Ast0.ident,'n) inout;
52 expression : (Ast0.expression,'n) inout;
53 typeC : (Ast0.typeC,'n) inout;
54 declaration : (Ast0.declaration,'n) inout;
55 initialiser : (Ast0.initialiser,'n) inout;
56 initialiser_list : (Ast0.initialiser_list,'n) inout;
57 parameter : (Ast0.parameterTypeDef,'n) inout;
58 parameter_list : (Ast0.parameter_list,'n) inout;
59 statement : (Ast0.statement,'n) inout;
60 case_line : (Ast0.case_line,'n) inout;
61 top_level : (Ast0.top_level,'n) inout;
62 expression_dots : (Ast0.expression Ast0.dots,'n) inout;
63 statement_dots : (Ast0.statement Ast0.dots,'n) inout;
64 declaration_dots : (Ast0.declaration Ast0.dots,'n) inout;
65 case_line_dots : (Ast0.case_line Ast0.dots,'n) inout;
66 anything : (Ast0.anything,'n) inout}
67
68 (* ----------------------------------------------------------------------- *)
69 (* combiner *)
70
71 type ('a,'n) combiner_inout = 'a -> 'n
72
73 type 'n combiner_rec_functions =
74 {combiner_rec_ident : (Ast0.ident,'n) combiner_inout;
75 combiner_rec_expression : (Ast0.expression,'n) combiner_inout;
76 combiner_rec_typeC : (Ast0.typeC,'n) combiner_inout;
77 combiner_rec_declaration : (Ast0.declaration,'n) combiner_inout;
78 combiner_rec_initialiser : (Ast0.initialiser,'n) combiner_inout;
79 combiner_rec_initialiser_list :
80 (Ast0.initialiser_list,'n) combiner_inout;
81 combiner_rec_parameter : (Ast0.parameterTypeDef,'n) combiner_inout;
82 combiner_rec_parameter_list : (Ast0.parameter_list,'n) combiner_inout;
83 combiner_rec_statement : (Ast0.statement,'n) combiner_inout;
84 combiner_rec_case_line : (Ast0.case_line,'n) combiner_inout;
85 combiner_rec_top_level : (Ast0.top_level,'n) combiner_inout;
86 combiner_rec_expression_dots :
87 (Ast0.expression Ast0.dots,'n) combiner_inout;
88 combiner_rec_statement_dots :
89 (Ast0.statement Ast0.dots,'n) combiner_inout;
90 combiner_rec_declaration_dots :
91 (Ast0.declaration Ast0.dots,'n) combiner_inout;
92 combiner_rec_case_line_dots :
93 (Ast0.case_line Ast0.dots,'n) combiner_inout;
94 combiner_rec_anything : (Ast0.anything,'n) combiner_inout}
95
96 type ('mc,'n) cmcode = 'n -> 'mc Ast0.mcode -> 'n
97 type ('mc,'n) flat_cmcode = 'mc Ast0.mcode -> 'n
98 type ('cd,'n) ccode = 'n combiner_rec_functions -> ('cd -> 'n) -> 'cd -> 'n
99
100 type 'n combiner_functions =
101 {combiner_meta_mcode : (Ast.meta_name,'n) cmcode;
102 combiner_string_mcode : (string,'n) cmcode;
103 combiner_const_mcode : (Ast.constant,'n) cmcode;
104 combiner_assign_mcode : (Ast.assignOp,'n) cmcode;
105 combiner_fix_mcode : (Ast.fixOp,'n) cmcode;
106 combiner_unary_mcode : (Ast.unaryOp,'n) cmcode;
107 combiner_binary_mcode : (Ast.binaryOp,'n) cmcode;
108 combiner_cv_mcode : (Ast.const_vol,'n) cmcode;
109 combiner_sign_mcode : (Ast.sign,'n) cmcode;
110 combiner_struct_mcode : (Ast.structUnion,'n) cmcode;
111 combiner_storage_mcode : (Ast.storage,'n) cmcode;
112 combiner_inc_mcode : (Ast.inc_file,'n) cmcode;
113 combiner_dotsexprfn : (Ast0.expression Ast0.dots,'n) ccode;
114 combiner_dotsinitfn : (Ast0.initialiser Ast0.dots,'n) ccode;
115 combiner_dotsparamfn : (Ast0.parameterTypeDef Ast0.dots,'n) ccode;
116 combiner_dotsstmtfn : (Ast0.statement Ast0.dots,'n) ccode;
117 combiner_dotsdeclfn : (Ast0.declaration Ast0.dots,'n) ccode;
118 combiner_dotscasefn : (Ast0.case_line Ast0.dots,'n) ccode;
119 combiner_identfn : (Ast0.ident,'n) ccode;
120 combiner_exprfn : (Ast0.expression,'n) ccode;
121 combiner_tyfn : (Ast0.typeC,'n) ccode;
122 combiner_initfn : (Ast0.initialiser,'n) ccode;
123 combiner_paramfn : (Ast0.parameterTypeDef,'n) ccode;
124 combiner_declfn : (Ast0.declaration,'n) ccode;
125 combiner_stmtfn : (Ast0.statement,'n) ccode;
126 combiner_casefn : (Ast0.case_line,'n) ccode;
127 combiner_topfn : (Ast0.top_level,'n) ccode}
128
129 (* ----------------------------------------------------------------------- *)
130 (* rebuilder *)
131
132 type 'a rebuilder_inout = 'a -> 'a
133
134 type rebuilder_rec_functions =
135 {rebuilder_rec_ident : Ast0.ident rebuilder_inout;
136 rebuilder_rec_expression : Ast0.expression rebuilder_inout;
137 rebuilder_rec_typeC : Ast0.typeC rebuilder_inout;
138 rebuilder_rec_declaration : Ast0.declaration rebuilder_inout;
139 rebuilder_rec_initialiser : Ast0.initialiser rebuilder_inout;
140 rebuilder_rec_initialiser_list :
141 Ast0.initialiser_list rebuilder_inout;
142 rebuilder_rec_parameter : Ast0.parameterTypeDef rebuilder_inout;
143 rebuilder_rec_parameter_list : Ast0.parameter_list rebuilder_inout;
144 rebuilder_rec_statement : Ast0.statement rebuilder_inout;
145 rebuilder_rec_case_line : Ast0.case_line rebuilder_inout;
146 rebuilder_rec_top_level : Ast0.top_level rebuilder_inout;
147 rebuilder_rec_expression_dots :
148 Ast0.expression Ast0.dots rebuilder_inout;
149 rebuilder_rec_statement_dots :
150 Ast0.statement Ast0.dots rebuilder_inout;
151 rebuilder_rec_declaration_dots :
152 Ast0.declaration Ast0.dots rebuilder_inout;
153 rebuilder_rec_case_line_dots :
154 Ast0.case_line Ast0.dots rebuilder_inout;
155 rebuilder_rec_anything : Ast0.anything rebuilder_inout}
156
157 type 'mc rmcode = 'mc Ast0.mcode rebuilder_inout
158 type 'cd rcode =
159 rebuilder_rec_functions -> ('cd rebuilder_inout) -> 'cd rebuilder_inout
160
161 type rebuilder_functions =
162 {rebuilder_meta_mcode : Ast_cocci.meta_name rmcode;
163 rebuilder_string_mcode : string rmcode;
164 rebuilder_const_mcode : Ast.constant rmcode;
165 rebuilder_assign_mcode : Ast.assignOp rmcode;
166 rebuilder_fix_mcode : Ast.fixOp rmcode;
167 rebuilder_unary_mcode : Ast.unaryOp rmcode;
168 rebuilder_binary_mcode : Ast.binaryOp rmcode;
169 rebuilder_cv_mcode : Ast.const_vol rmcode;
170 rebuilder_sign_mcode : Ast.sign rmcode;
171 rebuilder_struct_mcode : Ast.structUnion rmcode;
172 rebuilder_storage_mcode : Ast.storage rmcode;
173 rebuilder_inc_mcode : Ast.inc_file rmcode;
174 rebuilder_dotsexprfn : Ast0.expression Ast0.dots rcode;
175 rebuilder_dotsinitfn : Ast0.initialiser Ast0.dots rcode;
176 rebuilder_dotsparamfn : Ast0.parameterTypeDef Ast0.dots rcode;
177 rebuilder_dotsstmtfn : Ast0.statement Ast0.dots rcode;
178 rebuilder_dotsdeclfn : Ast0.declaration Ast0.dots rcode;
179 rebuilder_dotscasefn : Ast0.case_line Ast0.dots rcode;
180 rebuilder_identfn : Ast0.ident rcode;
181 rebuilder_exprfn : Ast0.expression rcode;
182 rebuilder_tyfn : Ast0.typeC rcode;
183 rebuilder_initfn : Ast0.initialiser rcode;
184 rebuilder_paramfn : Ast0.parameterTypeDef rcode;
185 rebuilder_declfn : Ast0.declaration rcode;
186 rebuilder_stmtfn : Ast0.statement rcode;
187 rebuilder_casefn : Ast0.case_line rcode;
188 rebuilder_topfn : Ast0.top_level rcode}
189
190 (* ----------------------------------------------------------------------- *)
191 (* combiner_rebuilder *)
192
193 type ('mc,'a) rcmcode = 'a -> 'mc Ast0.mcode -> ('a * 'mc Ast0.mcode)
194 type ('cd,'a) rccode =
195 'a all_functions -> ('cd -> ('a * 'cd)) -> 'cd -> ('a * 'cd)
196
197 type 'n combiner_rebuilder_functions =
198 {combiner_rebuilder_meta_mcode : (Ast_cocci.meta_name,'n) rcmcode;
199 combiner_rebuilder_string_mcode : (string,'n) rcmcode;
200 combiner_rebuilder_const_mcode : (Ast.constant,'n) rcmcode;
201 combiner_rebuilder_assign_mcode : (Ast.assignOp,'n) rcmcode;
202 combiner_rebuilder_fix_mcode : (Ast.fixOp,'n) rcmcode;
203 combiner_rebuilder_unary_mcode : (Ast.unaryOp,'n) rcmcode;
204 combiner_rebuilder_binary_mcode : (Ast.binaryOp,'n) rcmcode;
205 combiner_rebuilder_cv_mcode : (Ast.const_vol,'n) rcmcode;
206 combiner_rebuilder_sign_mcode : (Ast.sign,'n) rcmcode;
207 combiner_rebuilder_struct_mcode : (Ast.structUnion,'n) rcmcode;
208 combiner_rebuilder_storage_mcode : (Ast.storage,'n) rcmcode;
209 combiner_rebuilder_inc_mcode : (Ast.inc_file,'n) rcmcode;
210 combiner_rebuilder_dotsexprfn : (Ast0.expression Ast0.dots,'n) rccode;
211 combiner_rebuilder_dotsinitfn : (Ast0.initialiser Ast0.dots,'n) rccode;
212 combiner_rebuilder_dotsparamfn :
213 (Ast0.parameterTypeDef Ast0.dots,'n) rccode;
214 combiner_rebuilder_dotsstmtfn : (Ast0.statement Ast0.dots,'n) rccode;
215 combiner_rebuilder_dotsdeclfn : (Ast0.declaration Ast0.dots,'n) rccode;
216 combiner_rebuilder_dotscasefn : (Ast0.case_line Ast0.dots,'n) rccode;
217 combiner_rebuilder_identfn : (Ast0.ident,'n) rccode;
218 combiner_rebuilder_exprfn : (Ast0.expression,'n) rccode;
219 combiner_rebuilder_tyfn : (Ast0.typeC,'n) rccode;
220 combiner_rebuilder_initfn : (Ast0.initialiser,'n) rccode;
221 combiner_rebuilder_paramfn : (Ast0.parameterTypeDef,'n) rccode;
222 combiner_rebuilder_declfn : (Ast0.declaration,'n) rccode;
223 combiner_rebuilder_stmtfn : (Ast0.statement,'n) rccode;
224 combiner_rebuilder_casefn : (Ast0.case_line,'n) rccode;
225 combiner_rebuilder_topfn : (Ast0.top_level,'n) rccode}