Commit | Line | Data |
---|---|---|
f537ebc4 C |
1 | (* |
2 | * Copyright 2010, INRIA, University of Copenhagen | |
3 | * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix | |
4 | * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen | |
5 | * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix | |
6 | * This file is part of Coccinelle. | |
7 | * | |
8 | * Coccinelle is free software: you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation, according to version 2 of the License. | |
11 | * | |
12 | * Coccinelle is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>. | |
19 | * | |
20 | * The authors reserve the right to distribute this or future versions of | |
21 | * Coccinelle under other licenses. | |
22 | *) | |
23 | ||
24 | ||
34e49164 C |
25 | (* --------------------------------------------------------------------- *) |
26 | (* Modified code *) | |
27 | ||
190f1acf | 28 | type added_string = Noindent of string | Indent of string | Space of string |
c3e37e97 | 29 | |
34e49164 | 30 | type info = { line : int; column : int; |
c3e37e97 C |
31 | strbef : (added_string * int (* line *) * int (* col *)) list; |
32 | straft : (added_string * int (* line *) * int (* col *)) list } | |
34e49164 C |
33 | type line = int |
34 | type meta_name = string * string | |
35 | type 'a wrap = | |
36 | {node : 'a; | |
37 | node_line : line; | |
38 | free_vars : meta_name list; (*free vars*) | |
39 | minus_free_vars : meta_name list; (*minus free vars*) | |
978fd7e5 | 40 | fresh_vars : (meta_name * seed) list; (*fresh vars*) |
34e49164 C |
41 | inherited : meta_name list; (*inherited vars*) |
42 | saved_witness : meta_name list; (*witness vars*) | |
43 | bef_aft : dots_bef_aft; | |
44 | pos_info : meta_name mcode option; (* pos info, try not to duplicate *) | |
45 | true_if_test_exp : bool;(* true if "test_exp from iso", only for exprs *) | |
690d68d1 C |
46 | (* the following is only for declarations *) |
47 | safe_for_multi_decls : bool; | |
34e49164 C |
48 | (* isos relevant to the term; ultimately only used for rule_elems *) |
49 | iso_info : (string*anything) list } | |
50 | ||
51 | and 'a befaft = | |
951c7801 C |
52 | BEFORE of 'a list list * count |
53 | | AFTER of 'a list list * count | |
54 | | BEFOREAFTER of 'a list list * 'a list list * count | |
34e49164 C |
55 | | NOTHING |
56 | ||
8babbc8f C |
57 | and 'a replacement = REPLACEMENT of 'a list list * count | NOREPLACEMENT |
58 | ||
8f657093 | 59 | and 'a mcode = 'a * info * mcodekind * meta_pos list (* pos variables *) |
34e49164 C |
60 | (* pos is an offset indicating where in the C code the mcodekind has an |
61 | effect *) | |
8babbc8f | 62 | and adjacency = ALLMINUS | ADJ of int |
34e49164 | 63 | and mcodekind = |
8babbc8f | 64 | MINUS of pos * int list * adjacency * anything replacement |
34e49164 | 65 | | CONTEXT of pos * anything befaft |
951c7801 C |
66 | | PLUS of count |
67 | and count = ONE (* + *) | MANY (* ++ *) | |
34e49164 C |
68 | and fixpos = |
69 | Real of int (* charpos *) | Virt of int * int (* charpos + offset *) | |
70 | and pos = NoPos | DontCarePos | FixPos of (fixpos * fixpos) | |
71 | ||
72 | and dots_bef_aft = | |
73 | NoDots | |
74 | | AddingBetweenDots of statement * int (*index of let var*) | |
75 | | DroppingBetweenDots of statement * int (*index of let var*) | |
76 | ||
77 | and inherited = Type_cocci.inherited | |
78 | and keep_binding = Type_cocci.keep_binding | |
79 | and multi = bool (*true if a nest is one or more, false if it is zero or more*) | |
80 | ||
81 | and end_info = | |
978fd7e5 | 82 | meta_name list (*free vars*) * (meta_name * seed) list (*fresh*) * |
b1b2de81 | 83 | meta_name list (*inherited vars*) * mcodekind |
34e49164 C |
84 | |
85 | (* --------------------------------------------------------------------- *) | |
86 | (* Metavariables *) | |
87 | ||
88 | and arity = UNIQUE | OPT | MULTI | NONE | |
89 | ||
90 | and metavar = | |
b23ff9c7 C |
91 | MetaMetaDecl of arity * meta_name (* name *) |
92 | | MetaIdDecl of arity * meta_name (* name *) | |
978fd7e5 | 93 | | MetaFreshIdDecl of meta_name (* name *) * seed (* seed *) |
34e49164 | 94 | | MetaTypeDecl of arity * meta_name (* name *) |
113803cf | 95 | | MetaInitDecl of arity * meta_name (* name *) |
8f657093 | 96 | | MetaInitListDecl of arity * meta_name (* name *) * list_len (*len*) |
34e49164 C |
97 | | MetaListlenDecl of meta_name (* name *) |
98 | | MetaParamDecl of arity * meta_name (* name *) | |
88e71198 | 99 | | MetaParamListDecl of arity * meta_name (*name*) * list_len (*len*) |
34e49164 C |
100 | | MetaConstDecl of |
101 | arity * meta_name (* name *) * Type_cocci.typeC list option | |
102 | | MetaErrDecl of arity * meta_name (* name *) | |
103 | | MetaExpDecl of | |
104 | arity * meta_name (* name *) * Type_cocci.typeC list option | |
105 | | MetaIdExpDecl of | |
106 | arity * meta_name (* name *) * Type_cocci.typeC list option | |
107 | | MetaLocalIdExpDecl of | |
108 | arity * meta_name (* name *) * Type_cocci.typeC list option | |
88e71198 | 109 | | MetaExpListDecl of arity * meta_name (*name*) * list_len (*len*) |
413ffc02 C |
110 | | MetaDeclDecl of arity * meta_name (* name *) |
111 | | MetaFieldDecl of arity * meta_name (* name *) | |
190f1acf | 112 | | MetaFieldListDecl of arity * meta_name (* name *) * list_len (*len*) |
34e49164 C |
113 | | MetaStmDecl of arity * meta_name (* name *) |
114 | | MetaStmListDecl of arity * meta_name (* name *) | |
115 | | MetaFuncDecl of arity * meta_name (* name *) | |
116 | | MetaLocalFuncDecl of arity * meta_name (* name *) | |
117 | | MetaPosDecl of arity * meta_name (* name *) | |
118 | | MetaDeclarerDecl of arity * meta_name (* name *) | |
119 | | MetaIteratorDecl of arity * meta_name (* name *) | |
120 | ||
88e71198 C |
121 | and list_len = AnyLen | MetaLen of meta_name | CstLen of int |
122 | ||
978fd7e5 C |
123 | and seed = NoVal | StringSeed of string | ListSeed of seed_elem list |
124 | and seed_elem = SeedString of string | SeedId of meta_name | |
125 | ||
34e49164 C |
126 | (* --------------------------------------------------------------------- *) |
127 | (* --------------------------------------------------------------------- *) | |
128 | (* Dots *) | |
129 | ||
130 | and 'a base_dots = | |
131 | DOTS of 'a list | |
132 | | CIRCLES of 'a list | |
133 | | STARS of 'a list | |
134 | ||
135 | and 'a dots = 'a base_dots wrap | |
136 | ||
137 | (* --------------------------------------------------------------------- *) | |
138 | (* Identifier *) | |
139 | ||
140 | and base_ident = | |
951c7801 C |
141 | Id of string mcode |
142 | | MetaId of meta_name mcode * idconstraint * keep_binding * inherited | |
143 | | MetaFunc of meta_name mcode * idconstraint * keep_binding * inherited | |
144 | | MetaLocalFunc of meta_name mcode * idconstraint * keep_binding * inherited | |
34e49164 | 145 | |
d3f655c6 | 146 | | DisjId of ident list |
34e49164 C |
147 | | OptIdent of ident |
148 | | UniqueIdent of ident | |
149 | ||
150 | and ident = base_ident wrap | |
151 | ||
152 | (* --------------------------------------------------------------------- *) | |
153 | (* Expression *) | |
154 | ||
faf9a90c | 155 | and base_expression = |
34e49164 C |
156 | Ident of ident |
157 | | Constant of constant mcode | |
158 | | FunCall of expression * string mcode (* ( *) * | |
159 | expression dots * string mcode (* ) *) | |
160 | | Assignment of expression * assignOp mcode * expression * bool | |
161 | | CondExpr of expression * string mcode (* ? *) * expression option * | |
162 | string mcode (* : *) * expression | |
163 | | Postfix of expression * fixOp mcode | |
164 | | Infix of expression * fixOp mcode | |
165 | | Unary of expression * unaryOp mcode | |
166 | | Binary of expression * binaryOp mcode * expression | |
167 | | Nested of expression * binaryOp mcode * expression | |
168 | | ArrayAccess of expression * string mcode (* [ *) * expression * | |
169 | string mcode (* ] *) | |
170 | | RecordAccess of expression * string mcode (* . *) * ident | |
171 | | RecordPtAccess of expression * string mcode (* -> *) * ident | |
172 | | Cast of string mcode (* ( *) * fullType * string mcode (* ) *) * | |
173 | expression | |
174 | ||
175 | | SizeOfExpr of string mcode (* sizeof *) * expression | |
176 | | SizeOfType of string mcode (* sizeof *) * string mcode (* ( *) * | |
177 | fullType * string mcode (* ) *) | |
178 | | TypeExp of fullType | |
179 | ||
180 | | Paren of string mcode (* ( *) * expression * | |
181 | string mcode (* ) *) | |
182 | ||
951c7801 | 183 | | MetaErr of meta_name mcode * constraints * keep_binding * |
34e49164 | 184 | inherited |
951c7801 | 185 | | MetaExpr of meta_name mcode * constraints * keep_binding * |
34e49164 | 186 | Type_cocci.typeC list option * form * inherited |
88e71198 | 187 | | MetaExprList of meta_name mcode * listlen * |
34e49164 C |
188 | keep_binding * inherited (* only in arg lists *) |
189 | ||
190 | | EComma of string mcode (* only in arg lists *) | |
191 | ||
192 | | DisjExpr of expression list | |
5636bb2c C |
193 | | NestExpr of string mcode (* <.../<+... *) * |
194 | expression dots * | |
195 | string mcode (* ...>/...+> *) * | |
196 | expression option * multi | |
34e49164 C |
197 | |
198 | (* can appear in arg lists, and also inside Nest, as in: | |
199 | if(< ... X ... Y ...>) | |
200 | In the following, the expression option is the WHEN *) | |
201 | | Edots of string mcode (* ... *) * expression option | |
202 | | Ecircles of string mcode (* ooo *) * expression option | |
203 | | Estars of string mcode (* *** *) * expression option | |
204 | ||
205 | | OptExp of expression | |
206 | | UniqueExp of expression | |
207 | ||
951c7801 C |
208 | and constraints = |
209 | NoConstraint | |
5636bb2c | 210 | | NotIdCstrt of reconstraint |
951c7801 | 211 | | NotExpCstrt of expression list |
5636bb2c C |
212 | | SubExpCstrt of meta_name list |
213 | ||
214 | (* Constraints on Meta-* Identifiers, Functions *) | |
215 | and idconstraint = | |
216 | IdNoConstraint | |
217 | | IdNegIdSet of string list * meta_name list | |
218 | | IdRegExpConstraint of reconstraint | |
219 | ||
220 | and reconstraint = | |
221 | | IdRegExp of string * Str.regexp | |
222 | | IdNotRegExp of string * Str.regexp | |
951c7801 | 223 | |
34e49164 C |
224 | and form = ANY | ID | LocalID | CONST (* form for MetaExp *) |
225 | ||
226 | and expression = base_expression wrap | |
227 | ||
88e71198 C |
228 | and listlen = |
229 | MetaListLen of meta_name mcode * keep_binding * inherited | |
230 | | CstListLen of int | |
231 | | AnyListLen | |
34e49164 | 232 | |
8babbc8f | 233 | and unaryOp = GetRef | GetRefLabel | DeRef | UnPlus | UnMinus | Tilde | Not |
34e49164 C |
234 | and assignOp = SimpleAssign | OpAssign of arithOp |
235 | and fixOp = Dec | Inc | |
236 | ||
237 | and binaryOp = Arith of arithOp | Logical of logicalOp | |
238 | and arithOp = | |
239 | Plus | Minus | Mul | Div | Mod | DecLeft | DecRight | And | Or | Xor | |
240 | and logicalOp = Inf | Sup | InfEq | SupEq | Eq | NotEq | AndLog | OrLog | |
241 | ||
242 | and constant = | |
243 | String of string | |
244 | | Char of string | |
245 | | Int of string | |
246 | | Float of string | |
247 | ||
248 | (* --------------------------------------------------------------------- *) | |
249 | (* Types *) | |
250 | ||
251 | and base_fullType = | |
252 | Type of const_vol mcode option * typeC | |
253 | | DisjType of fullType list (* only after iso *) | |
254 | | OptType of fullType | |
255 | | UniqueType of fullType | |
256 | ||
faf9a90c C |
257 | and base_typeC = |
258 | BaseType of baseType * string mcode list (* Yoann style *) | |
259 | | SignedT of sign mcode * typeC option | |
34e49164 C |
260 | | Pointer of fullType * string mcode (* * *) |
261 | | FunctionPointer of fullType * | |
262 | string mcode(* ( *)*string mcode(* * *)*string mcode(* ) *)* | |
263 | string mcode (* ( *)*parameter_list*string mcode(* ) *) | |
264 | | FunctionType of bool (* true if all minus for dropping return type *) * | |
265 | fullType option * | |
266 | string mcode (* ( *) * parameter_list * | |
267 | string mcode (* ) *) | |
268 | | Array of fullType * string mcode (* [ *) * | |
269 | expression option * string mcode (* ] *) | |
c491d8ee C |
270 | | EnumName of string mcode (*enum*) * ident option (* name *) |
271 | | EnumDef of fullType (* either EnumName or metavar *) * | |
272 | string mcode (* { *) * expression dots * string mcode (* } *) | |
34e49164 C |
273 | | StructUnionName of structUnion mcode * ident option (* name *) |
274 | | StructUnionDef of fullType (* either StructUnionName or metavar *) * | |
275 | string mcode (* { *) * declaration dots * string mcode (* } *) | |
276 | | TypeName of string mcode | |
277 | ||
278 | | MetaType of meta_name mcode * keep_binding * inherited | |
279 | ||
280 | and fullType = base_fullType wrap | |
281 | and typeC = base_typeC wrap | |
faf9a90c | 282 | |
34e49164 | 283 | and baseType = VoidType | CharType | ShortType | IntType | DoubleType |
1eddfd50 | 284 | | FloatType | LongType | LongLongType | SizeType | SSizeType | PtrDiffType |
34e49164 C |
285 | |
286 | and structUnion = Struct | Union | |
287 | ||
288 | and sign = Signed | Unsigned | |
289 | ||
290 | and const_vol = Const | Volatile | |
291 | ||
292 | (* --------------------------------------------------------------------- *) | |
293 | (* Variable declaration *) | |
294 | (* Even if the Cocci program specifies a list of declarations, they are | |
295 | split out into multiple declarations of a single variable each. *) | |
296 | ||
297 | and base_declaration = | |
298 | Init of storage mcode option * fullType * ident * string mcode (*=*) * | |
299 | initialiser * string mcode (*;*) | |
300 | | UnInit of storage mcode option * fullType * ident * string mcode (* ; *) | |
301 | | TyDecl of fullType * string mcode (* ; *) | |
302 | | MacroDecl of ident (* name *) * string mcode (* ( *) * | |
303 | expression dots * string mcode (* ) *) * string mcode (* ; *) | |
304 | | Typedef of string mcode (*typedef*) * fullType * typeC * string mcode (*;*) | |
305 | | DisjDecl of declaration list | |
306 | | Ddots of string mcode (* ... *) * declaration option (* whencode *) | |
307 | ||
308 | | MetaDecl of meta_name mcode * keep_binding * inherited | |
413ffc02 | 309 | | MetaField of meta_name mcode * keep_binding * inherited |
190f1acf | 310 | | MetaFieldList of meta_name mcode * listlen * keep_binding * inherited |
34e49164 C |
311 | |
312 | | OptDecl of declaration | |
313 | | UniqueDecl of declaration | |
314 | ||
315 | and declaration = base_declaration wrap | |
316 | ||
317 | (* --------------------------------------------------------------------- *) | |
318 | (* Initializers *) | |
319 | ||
320 | and base_initialiser = | |
113803cf | 321 | MetaInit of meta_name mcode * keep_binding * inherited |
8f657093 | 322 | | MetaInitList of meta_name mcode * listlen * keep_binding * inherited |
113803cf | 323 | | InitExpr of expression |
c491d8ee C |
324 | | ArInitList of string mcode (*{*) * initialiser dots * string mcode (*}*) |
325 | | StrInitList of bool (* true if all are - *) * | |
90aeb998 | 326 | string mcode (*{*) * initialiser list * string mcode (*}*) * |
34e49164 | 327 | initialiser list (* whencode: elements that shouldn't appear in init *) |
113803cf C |
328 | | InitGccExt of |
329 | designator list (* name *) * string mcode (*=*) * | |
34e49164 C |
330 | initialiser (* gccext: *) |
331 | | InitGccName of ident (* name *) * string mcode (*:*) * | |
332 | initialiser | |
34e49164 | 333 | | IComma of string mcode (* , *) |
c491d8ee | 334 | | Idots of string mcode (* ... *) * initialiser option (* whencode *) |
34e49164 C |
335 | | OptIni of initialiser |
336 | | UniqueIni of initialiser | |
337 | ||
113803cf C |
338 | and designator = |
339 | DesignatorField of string mcode (* . *) * ident | |
340 | | DesignatorIndex of string mcode (* [ *) * expression * string mcode (* ] *) | |
341 | | DesignatorRange of | |
342 | string mcode (* [ *) * expression * string mcode (* ... *) * | |
343 | expression * string mcode (* ] *) | |
344 | ||
34e49164 C |
345 | and initialiser = base_initialiser wrap |
346 | ||
347 | (* --------------------------------------------------------------------- *) | |
348 | (* Parameter *) | |
349 | ||
350 | and base_parameterTypeDef = | |
351 | VoidParam of fullType | |
352 | | Param of fullType * ident option | |
353 | ||
354 | | MetaParam of meta_name mcode * keep_binding * inherited | |
88e71198 | 355 | | MetaParamList of meta_name mcode * listlen * keep_binding * inherited |
34e49164 C |
356 | |
357 | | PComma of string mcode | |
358 | ||
359 | | Pdots of string mcode (* ... *) | |
360 | | Pcircles of string mcode (* ooo *) | |
361 | ||
362 | | OptParam of parameterTypeDef | |
363 | | UniqueParam of parameterTypeDef | |
364 | ||
365 | and parameterTypeDef = base_parameterTypeDef wrap | |
366 | ||
367 | and parameter_list = parameterTypeDef dots | |
368 | ||
369 | (* --------------------------------------------------------------------- *) | |
370 | (* #define Parameters *) | |
371 | ||
372 | and base_define_param = | |
373 | DParam of ident | |
374 | | DPComma of string mcode | |
375 | | DPdots of string mcode (* ... *) | |
376 | | DPcircles of string mcode (* ooo *) | |
377 | | OptDParam of define_param | |
378 | | UniqueDParam of define_param | |
379 | ||
380 | and define_param = base_define_param wrap | |
381 | ||
382 | and base_define_parameters = | |
383 | NoParams | |
384 | | DParams of string mcode(*( *) * define_param dots * string mcode(* )*) | |
385 | ||
386 | and define_parameters = base_define_parameters wrap | |
387 | ||
388 | (* --------------------------------------------------------------------- *) | |
389 | (* positions *) | |
390 | ||
391 | (* PER = keep bindings separate, ANY = collect them *) | |
392 | and meta_collect = PER | ALL | |
393 | ||
394 | and meta_pos = | |
395 | MetaPos of meta_name mcode * meta_name list * | |
396 | meta_collect * keep_binding * inherited | |
34e49164 C |
397 | |
398 | (* --------------------------------------------------------------------- *) | |
399 | (* Function declaration *) | |
400 | ||
401 | and storage = Static | Auto | Register | Extern | |
402 | ||
403 | (* --------------------------------------------------------------------- *) | |
404 | (* Top-level code *) | |
405 | ||
406 | and base_rule_elem = | |
407 | FunHeader of mcodekind (* before the function header *) * | |
408 | bool (* true if all minus, for dropping static, etc *) * | |
409 | fninfo list * ident (* name *) * | |
410 | string mcode (* ( *) * parameter_list * | |
411 | string mcode (* ) *) | |
faf9a90c | 412 | | Decl of mcodekind (* before the decl *) * |
34e49164 C |
413 | bool (* true if all minus *) * declaration |
414 | ||
415 | | SeqStart of string mcode (* { *) | |
416 | | SeqEnd of string mcode (* } *) | |
417 | ||
8babbc8f | 418 | | ExprStatement of expression option * string mcode (*;*) |
34e49164 C |
419 | | IfHeader of string mcode (* if *) * string mcode (* ( *) * |
420 | expression * string mcode (* ) *) | |
421 | | Else of string mcode (* else *) | |
422 | | WhileHeader of string mcode (* while *) * string mcode (* ( *) * | |
423 | expression * string mcode (* ) *) | |
424 | | DoHeader of string mcode (* do *) | |
425 | | WhileTail of string mcode (* while *) * string mcode (* ( *) * | |
426 | expression * string mcode (* ) *) * | |
427 | string mcode (* ; *) | |
428 | | ForHeader of string mcode (* for *) * string mcode (* ( *) * | |
429 | expression option * string mcode (*;*) * | |
430 | expression option * string mcode (*;*) * | |
431 | expression option * string mcode (* ) *) | |
432 | | IteratorHeader of ident (* name *) * string mcode (* ( *) * | |
433 | expression dots * string mcode (* ) *) | |
434 | | SwitchHeader of string mcode (* switch *) * string mcode (* ( *) * | |
435 | expression * string mcode (* ) *) | |
436 | | Break of string mcode (* break *) * string mcode (* ; *) | |
437 | | Continue of string mcode (* continue *) * string mcode (* ; *) | |
438 | | Label of ident * string mcode (* : *) | |
439 | | Goto of string mcode (* goto *) * ident * string mcode (* ; *) | |
440 | | Return of string mcode (* return *) * string mcode (* ; *) | |
441 | | ReturnExpr of string mcode (* return *) * expression * | |
442 | string mcode (* ; *) | |
443 | ||
444 | | MetaRuleElem of meta_name mcode * keep_binding * inherited | |
445 | | MetaStmt of meta_name mcode * keep_binding * metaStmtInfo * | |
446 | inherited | |
447 | | MetaStmtList of meta_name mcode * keep_binding * inherited | |
448 | ||
449 | | Exp of expression | |
450 | | TopExp of expression (* for macros body *) | |
451 | | Ty of fullType (* only at top level *) | |
1be43e12 | 452 | | TopInit of initialiser (* only at top level *) |
34e49164 | 453 | | Include of string mcode (*#include*) * inc_file mcode (*file *) |
3a314143 | 454 | | Undef of string mcode (* #define *) * ident (* name *) |
34e49164 C |
455 | | DefineHeader of string mcode (* #define *) * ident (* name *) * |
456 | define_parameters (*params*) | |
457 | | Case of string mcode (* case *) * expression * string mcode (*:*) | |
458 | | Default of string mcode (* default *) * string mcode (*:*) | |
459 | | DisjRuleElem of rule_elem list | |
460 | ||
461 | and fninfo = | |
462 | FStorage of storage mcode | |
463 | | FType of fullType | |
464 | | FInline of string mcode | |
465 | | FAttr of string mcode | |
466 | ||
467 | and metaStmtInfo = | |
468 | NotSequencible | SequencibleAfterDots of dots_whencode list | Sequencible | |
469 | ||
470 | and rule_elem = base_rule_elem wrap | |
471 | ||
472 | and base_statement = | |
708f4980 | 473 | Seq of rule_elem (* { *) * |
34e49164 C |
474 | statement dots * rule_elem (* } *) |
475 | | IfThen of rule_elem (* header *) * statement * end_info | |
476 | | IfThenElse of rule_elem (* header *) * statement * | |
477 | rule_elem (* else *) * statement * end_info | |
478 | | While of rule_elem (* header *) * statement * end_info | |
479 | | Do of rule_elem (* do *) * statement * rule_elem (* tail *) | |
480 | | For of rule_elem (* header *) * statement * end_info | |
481 | | Iterator of rule_elem (* header *) * statement * end_info (*enditer*) | |
482 | | Switch of rule_elem (* header *) * rule_elem (* { *) * | |
fc1ad971 | 483 | statement (*decl*) dots * case_line list * rule_elem(*}*) |
34e49164 C |
484 | | Atomic of rule_elem |
485 | | Disj of statement dots list | |
5636bb2c C |
486 | | Nest of string mcode (* <.../<+... *) * statement dots * |
487 | string mcode (* ...>/...+> *) * | |
34e49164 C |
488 | (statement dots,statement) whencode list * multi * |
489 | dots_whencode list * dots_whencode list | |
490 | | FunDecl of rule_elem (* header *) * rule_elem (* { *) * | |
708f4980 | 491 | statement dots * rule_elem (* } *) |
34e49164 C |
492 | | Define of rule_elem (* header *) * statement dots |
493 | | Dots of string mcode (* ... *) * | |
494 | (statement dots,statement) whencode list * | |
495 | dots_whencode list * dots_whencode list | |
496 | | Circles of string mcode (* ooo *) * | |
497 | (statement dots,statement) whencode list * | |
498 | dots_whencode list * dots_whencode list | |
499 | | Stars of string mcode (* *** *) * | |
500 | (statement dots,statement) whencode list * | |
501 | dots_whencode list * dots_whencode list | |
502 | | OptStm of statement | |
503 | | UniqueStm of statement | |
504 | ||
505 | and ('a,'b) whencode = | |
506 | WhenNot of 'a | |
507 | | WhenAlways of 'b | |
508 | | WhenModifier of when_modifier | |
1be43e12 C |
509 | | WhenNotTrue of rule_elem |
510 | | WhenNotFalse of rule_elem | |
34e49164 C |
511 | |
512 | and when_modifier = | |
513 | WhenAny | |
514 | | WhenStrict | |
515 | | WhenForall | |
516 | | WhenExists | |
517 | ||
518 | and dots_whencode = | |
519 | WParen of rule_elem * meta_name (*pren_var*) | |
520 | | Other of statement | |
521 | | Other_dots of statement dots | |
522 | ||
523 | and statement = base_statement wrap | |
524 | ||
525 | and base_case_line = | |
526 | CaseLine of rule_elem (* case/default header *) * statement dots | |
527 | | OptCase of case_line | |
528 | ||
529 | and case_line = base_case_line wrap | |
530 | ||
531 | and inc_file = | |
532 | Local of inc_elem list | |
533 | | NonLocal of inc_elem list | |
534 | ||
535 | and inc_elem = | |
536 | IncPath of string | |
537 | | IncDots | |
538 | ||
539 | and base_top_level = | |
65038c61 | 540 | NONDECL of statement (* cannot match all of a top-level declaration *) |
34e49164 C |
541 | | CODE of statement dots |
542 | | FILEINFO of string mcode (* old file *) * string mcode (* new file *) | |
543 | | ERRORWORDS of expression list | |
544 | ||
545 | and top_level = base_top_level wrap | |
546 | ||
547 | and rulename = | |
548 | CocciRulename of string option * dependency * string list * string list * | |
549 | exists * bool | |
550 | (* true if the whole thing is an expression *) | |
faf9a90c C |
551 | | GeneratedRulename of string option * dependency * |
552 | string list * string list * exists * bool | |
553 | (* true if the whole thing is an expression *) | |
174d1640 C |
554 | | ScriptRulename of string option (* name *) * string (* language *) * |
555 | dependency | |
556 | | InitialScriptRulename of string option (* name *) * string (* language *) * | |
557 | dependency | |
558 | | FinalScriptRulename of string option (* name *) * string (* language *) * | |
559 | dependency | |
34e49164 | 560 | |
faf9a90c C |
561 | and ruletype = Normal | Generated |
562 | ||
34e49164 C |
563 | and rule = |
564 | CocciRule of string (* name *) * | |
565 | (dependency * string list (* dropped isos *) * exists) * | |
faf9a90c | 566 | top_level list * bool list (* true if generates an exp *) * ruletype |
174d1640 | 567 | | ScriptRule of string (* name *) * |
aba5c457 | 568 | string * dependency * |
413ffc02 C |
569 | (script_meta_name * meta_name * metavar) list * |
570 | meta_name list (*script vars*) * string | |
174d1640 C |
571 | | InitialScriptRule of string (* name *) * |
572 | string * dependency * string | |
573 | | FinalScriptRule of string (* name *) * | |
574 | string * dependency * string | |
34e49164 | 575 | |
aba5c457 C |
576 | and script_meta_name = string option (*string*) * string option (*ast*) |
577 | ||
34e49164 C |
578 | and dependency = |
579 | Dep of string (* rule applies for the current binding *) | |
580 | | AntiDep of string (* rule doesn't apply for the current binding *) | |
581 | | EverDep of string (* rule applies for some binding *) | |
582 | | NeverDep of string (* rule never applies for any binding *) | |
583 | | AndDep of dependency * dependency | |
584 | | OrDep of dependency * dependency | |
7f004419 | 585 | | NoDep | FailDep |
34e49164 C |
586 | |
587 | and rule_with_metavars = metavar list * rule | |
588 | ||
589 | and anything = | |
590 | FullTypeTag of fullType | |
591 | | BaseTypeTag of baseType | |
592 | | StructUnionTag of structUnion | |
593 | | SignTag of sign | |
594 | | IdentTag of ident | |
595 | | ExpressionTag of expression | |
596 | | ConstantTag of constant | |
597 | | UnaryOpTag of unaryOp | |
598 | | AssignOpTag of assignOp | |
599 | | FixOpTag of fixOp | |
600 | | BinaryOpTag of binaryOp | |
601 | | ArithOpTag of arithOp | |
602 | | LogicalOpTag of logicalOp | |
603 | | DeclarationTag of declaration | |
604 | | InitTag of initialiser | |
605 | | StorageTag of storage | |
606 | | IncFileTag of inc_file | |
607 | | Rule_elemTag of rule_elem | |
608 | | StatementTag of statement | |
609 | | CaseLineTag of case_line | |
610 | | ConstVolTag of const_vol | |
611 | | Token of string * info option | |
c3e37e97 | 612 | | Pragma of added_string list |
34e49164 C |
613 | | Code of top_level |
614 | | ExprDotsTag of expression dots | |
615 | | ParamDotsTag of parameterTypeDef dots | |
616 | | StmtDotsTag of statement dots | |
617 | | DeclDotsTag of declaration dots | |
618 | | TypeCTag of typeC | |
619 | | ParamTag of parameterTypeDef | |
620 | | SgrepStartTag of string | |
621 | | SgrepEndTag of string | |
622 | ||
623 | (* --------------------------------------------------------------------- *) | |
624 | ||
978fd7e5 | 625 | and exists = Exists | Forall | Undetermined |
34e49164 C |
626 | |
627 | (* --------------------------------------------------------------------- *) | |
628 | ||
629 | val mkToken : string -> anything | |
630 | ||
631 | val undots : 'a dots -> 'a list | |
632 | ||
951c7801 C |
633 | val lub_count : count -> count -> count |
634 | ||
34e49164 C |
635 | (* --------------------------------------------------------------------- *) |
636 | ||
637 | val rewrap : 'a wrap -> 'b -> 'b wrap | |
638 | val rewrap_mcode : 'a mcode -> 'a -> 'a mcode | |
639 | val unwrap : 'a wrap -> 'a | |
640 | val unwrap_mcode : 'a mcode -> 'a | |
641 | val get_mcodekind : 'a mcode -> mcodekind | |
642 | val get_line : 'a wrap -> line | |
643 | val get_mcode_line : 'a mcode -> line | |
708f4980 | 644 | val get_mcode_col : 'a mcode -> int |
34e49164 C |
645 | val get_fvs : 'a wrap -> meta_name list |
646 | val get_wcfvs : ('a wrap,'b wrap) whencode list -> meta_name list | |
647 | val set_fvs : meta_name list -> 'a wrap -> 'a wrap | |
648 | val get_mfvs : 'a wrap -> meta_name list | |
649 | val set_mfvs : meta_name list -> 'a wrap -> 'a wrap | |
978fd7e5 | 650 | val get_fresh : 'a wrap -> (meta_name * seed) list |
34e49164 C |
651 | val get_inherited : 'a wrap -> meta_name list |
652 | val get_saved : 'a wrap -> meta_name list | |
653 | val get_dots_bef_aft : statement -> dots_bef_aft | |
654 | val set_dots_bef_aft : dots_bef_aft -> statement -> statement | |
655 | val get_pos : 'a wrap -> meta_name mcode option | |
656 | val set_pos : 'a wrap -> meta_name mcode option -> 'a wrap | |
657 | val get_test_exp : 'a wrap -> bool | |
658 | val set_test_exp : expression -> expression | |
690d68d1 | 659 | val get_safe_decl : 'a wrap -> bool |
34e49164 C |
660 | val get_isos : 'a wrap -> (string*anything) list |
661 | val set_isos : 'a wrap -> (string*anything) list -> 'a wrap | |
8f657093 C |
662 | val get_pos_var : 'a mcode -> meta_pos list |
663 | val set_pos_var : meta_pos list -> 'a mcode -> 'a mcode | |
34e49164 C |
664 | val drop_pos : 'a mcode -> 'a mcode |
665 | ||
666 | val get_meta_name : metavar -> meta_name | |
667 | ||
0708f913 C |
668 | val tag2c : anything -> string |
669 | ||
34e49164 C |
670 | val no_info : info |
671 | ||
672 | val make_meta_rule_elem : | |
673 | string -> mcodekind -> | |
978fd7e5 | 674 | (meta_name list * (meta_name * seed) list * meta_name list) -> |
34e49164 C |
675 | rule_elem |
676 | ||
677 | val make_meta_decl : | |
678 | string -> mcodekind -> | |
978fd7e5 | 679 | (meta_name list * (meta_name * seed) list * meta_name list) -> |
34e49164 C |
680 | declaration |
681 | ||
682 | val make_term : 'a -> 'a wrap | |
683 | val make_mcode : 'a -> 'a mcode | |
684 | ||
685 | val equal_pos : fixpos -> fixpos -> bool |