Release coccinelle-0.1.3
[bpt/coccinelle.git] / parsing_cocci / .#ast_cocci.ml.1.143
CommitLineData
1be43e12
C
1(*
2* Copyright 2005-2008, 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(* --------------------------------------------------------------------- *)
24(* Modified code *)
25
26type info = { line : int; column : int;
27 strbef : string list; straft : string list }
28type line = int
29type meta_name = string * string
30(* need to be careful about rewrapping, to avoid duplicating pos info
31currently, the pos info is always None until asttoctl2. *)
32type 'a wrap =
33 {node : 'a;
34 node_line : line;
35 free_vars : meta_name list; (*free vars*)
36 minus_free_vars : meta_name list; (*minus free vars*)
37 fresh_vars : meta_name list; (*fresh vars*)
38 inherited : meta_name list; (*inherited vars*)
39 saved_witness : meta_name list; (*witness vars*)
40 bef_aft : dots_bef_aft;
41 (* the following is for or expressions *)
42 pos_info : meta_name mcode option; (* pos info, try not to duplicate *)
43 true_if_test_exp : bool;(* true if "test_exp from iso", only for exprs *)
44 (* isos relevant to the term; ultimately only used for rule_elems *)
45 iso_info : (string*anything) list }
46
47and 'a befaft =
48 BEFORE of 'a list list
49 | AFTER of 'a list list
50 | BEFOREAFTER of 'a list list * 'a list list
51 | NOTHING
52
53and 'a mcode = 'a * info * mcodekind * meta_pos (* pos variable *)
54 (* pos is an offset indicating where in the C code the mcodekind has an
55 effect *)
56 and mcodekind =
57 MINUS of pos * anything list list
58 | CONTEXT of pos * anything befaft
59 | PLUS
60 and fixpos =
61 Real of int (* charpos *) | Virt of int * int (* charpos + offset *)
62 and pos = NoPos | DontCarePos | FixPos of (fixpos * fixpos)
63
64and dots_bef_aft =
65 NoDots
66 | AddingBetweenDots of statement * int (*index of let var*)
67 | DroppingBetweenDots of statement * int (*index of let var*)
68
69and inherited = Type_cocci.inherited
70and keep_binding = Type_cocci.keep_binding
71and multi = bool (*true if a nest is one or more, false if it is zero or more*)
72
73and end_info =
74 meta_name list (*free vars*) * meta_name list (*inherited vars*) *
75 meta_name list (*witness vars*) * mcodekind
76
77(* --------------------------------------------------------------------- *)
78(* Metavariables *)
79
80and arity = UNIQUE | OPT | MULTI | NONE
81
82and metavar =
83 MetaIdDecl of arity * meta_name (* name *)
84 | MetaFreshIdDecl of arity * meta_name (* name *)
85 | MetaTypeDecl of arity * meta_name (* name *)
86 | MetaListlenDecl of meta_name (* name *)
87 | MetaParamDecl of arity * meta_name (* name *)
88 | MetaParamListDecl of arity * meta_name (*name*) * meta_name option (*len*)
89 | MetaConstDecl of
90 arity * meta_name (* name *) * Type_cocci.typeC list option
91 | MetaErrDecl of arity * meta_name (* name *)
92 | MetaExpDecl of
93 arity * meta_name (* name *) * Type_cocci.typeC list option
94 | MetaIdExpDecl of
95 arity * meta_name (* name *) * Type_cocci.typeC list option
96 | MetaLocalIdExpDecl of
97 arity * meta_name (* name *) * Type_cocci.typeC list option
98 | MetaExpListDecl of arity * meta_name (*name*) * meta_name option (*len*)
99 | MetaStmDecl of arity * meta_name (* name *)
100 | MetaStmListDecl of arity * meta_name (* name *)
101 | MetaFuncDecl of arity * meta_name (* name *)
102 | MetaLocalFuncDecl of arity * meta_name (* name *)
103 | MetaPosDecl of arity * meta_name (* name *)
104 | MetaDeclarerDecl of arity * meta_name (* name *)
105 | MetaIteratorDecl of arity * meta_name (* name *)
106
107(* --------------------------------------------------------------------- *)
108(* --------------------------------------------------------------------- *)
109(* Dots *)
110
111and 'a base_dots =
112 DOTS of 'a list
113 | CIRCLES of 'a list
114 | STARS of 'a list
115
116and 'a dots = 'a base_dots wrap
117
118(* --------------------------------------------------------------------- *)
119(* Identifier *)
120
121and base_ident =
122 Id of string mcode
123
124 | MetaId of meta_name mcode * ident list * keep_binding * inherited
125 | MetaFunc of meta_name mcode * ident list * keep_binding * inherited
126 | MetaLocalFunc of meta_name mcode * ident list * keep_binding * inherited
127
128 | OptIdent of ident
129 | UniqueIdent of ident
130
131and ident = base_ident wrap
132
133(* --------------------------------------------------------------------- *)
134(* Expression *)
135
136and base_expression =
137 Ident of ident
138 | Constant of constant mcode
139 | FunCall of expression * string mcode (* ( *) *
140 expression dots * string mcode (* ) *)
141 | Assignment of expression * assignOp mcode * expression *
142 bool (* true if it can match an initialization *)
143 | CondExpr of expression * string mcode (* ? *) * expression option *
144 string mcode (* : *) * expression
145 | Postfix of expression * fixOp mcode
146 | Infix of expression * fixOp mcode
147 | Unary of expression * unaryOp mcode
148 | Binary of expression * binaryOp mcode * expression
149 | Nested of expression * binaryOp mcode * expression
150 | ArrayAccess of expression * string mcode (* [ *) * expression *
151 string mcode (* ] *)
152 | RecordAccess of expression * string mcode (* . *) * ident
153 | RecordPtAccess of expression * string mcode (* -> *) * ident
154 | Cast of string mcode (* ( *) * fullType * string mcode (* ) *) *
155 expression
156 | SizeOfExpr of string mcode (* sizeof *) * expression
157 | SizeOfType of string mcode (* sizeof *) * string mcode (* ( *) *
158 fullType * string mcode (* ) *)
159 | TypeExp of fullType (*type name used as an expression, only in
160 arg or #define*)
161
162 | Paren of string mcode (* ( *) * expression *
163 string mcode (* ) *)
164
165 | MetaErr of meta_name mcode * expression list * keep_binding *
166 inherited
167 | MetaExpr of meta_name mcode * expression list * keep_binding *
168 Type_cocci.typeC list option * form * inherited
169 | MetaExprList of meta_name mcode * listlen option * keep_binding *
170 inherited (* only in arg lists *)
171
172 | EComma of string mcode (* only in arg lists *)
173
174 | DisjExpr of expression list
175 | NestExpr of expression dots * expression option * multi
176
177 (* can appear in arg lists, and also inside Nest, as in:
178 if(< ... X ... Y ...>)
179 In the following, the expression option is the WHEN *)
180 | Edots of string mcode (* ... *) * expression option
181 | Ecircles of string mcode (* ooo *) * expression option
182 | Estars of string mcode (* *** *) * expression option
183
184 | OptExp of expression
185 | UniqueExp of expression
186
187(* ANY = int E; ID = idexpression int X; CONST = constant int X; *)
188and form = ANY | ID | LocalID | CONST (* form for MetaExp *)
189
190and expression = base_expression wrap
191
192and listlen = meta_name mcode * keep_binding * inherited
193
194and unaryOp = GetRef | DeRef | UnPlus | UnMinus | Tilde | Not
195and assignOp = SimpleAssign | OpAssign of arithOp
196and fixOp = Dec | Inc
197
198and binaryOp = Arith of arithOp | Logical of logicalOp
199and arithOp =
200 Plus | Minus | Mul | Div | Mod | DecLeft | DecRight | And | Or | Xor
201and logicalOp = Inf | Sup | InfEq | SupEq | Eq | NotEq | AndLog | OrLog
202
203and constant =
204 String of string
205 | Char of string
206 | Int of string
207 | Float of string
208
209(* --------------------------------------------------------------------- *)
210(* Types *)
211
212and base_fullType =
213 Type of const_vol mcode option * typeC
214 | DisjType of fullType list (* only after iso *)
215 | OptType of fullType
216 | UniqueType of fullType
217
218and base_typeC =
219 BaseType of baseType mcode * sign mcode option
220 | ImplicitInt of sign mcode
221 | Pointer of fullType * string mcode (* * *)
222 | FunctionPointer of fullType *
223 string mcode(* ( *)*string mcode(* * *)*string mcode(* ) *)*
224 string mcode (* ( *)*parameter_list*string mcode(* ) *)
225
226 (* used for the automatic managment of prototypes *)
227 | FunctionType of bool (* true if all minus for dropping return type *) *
228 fullType option *
229 string mcode (* ( *) * parameter_list *
230 string mcode (* ) *)
231
232 | Array of fullType * string mcode (* [ *) *
233 expression option * string mcode (* ] *)
234 | StructUnionName of structUnion mcode * ident option (* name *)
235 | StructUnionDef of fullType (* either StructUnionName or metavar *) *
236 string mcode (* { *) * declaration dots * string mcode (* } *)
237 | TypeName of string mcode
238
239 | MetaType of meta_name mcode * keep_binding * inherited
240
241and fullType = base_fullType wrap
242and typeC = base_typeC wrap
243
244and baseType = VoidType | CharType | ShortType | IntType | DoubleType
245| FloatType | LongType
246
247and structUnion = Struct | Union
248
249and sign = Signed | Unsigned
250
251and const_vol = Const | Volatile
252
253(* --------------------------------------------------------------------- *)
254(* Variable declaration *)
255(* Even if the Cocci program specifies a list of declarations, they are
256 split out into multiple declarations of a single variable each. *)
257
258and base_declaration =
259 Init of storage mcode option * fullType * ident * string mcode (*=*) *
260 initialiser * string mcode (*;*)
261 | UnInit of storage mcode option * fullType * ident * string mcode (* ; *)
262 | TyDecl of fullType * string mcode (* ; *)
263 | MacroDecl of ident (* name *) * string mcode (* ( *) *
264 expression dots * string mcode (* ) *) * string mcode (* ; *)
265 | Typedef of string mcode (*typedef*) * fullType *
266 typeC (* either TypeName or metavar *) * string mcode (*;*)
267 | DisjDecl of declaration list
268 (* Ddots is for a structure declaration *)
269 | Ddots of string mcode (* ... *) * declaration option (* whencode *)
270
271 | MetaDecl of meta_name mcode * keep_binding * inherited
272
273 | OptDecl of declaration
274 | UniqueDecl of declaration
275
276and declaration = base_declaration wrap
277
278(* --------------------------------------------------------------------- *)
279(* Initializers *)
280
281and base_initialiser =
282 InitExpr of expression
283 | InitList of string mcode (*{*) * initialiser list * string mcode (*}*) *
284 initialiser list (* whencode: elements that shouldn't appear in init *)
285 | InitGccDotName of
286 string mcode (*.*) * ident (* name *) * string mcode (*=*) *
287 initialiser (* gccext: *)
288 | InitGccName of ident (* name *) * string mcode (*:*) *
289 initialiser
290 | InitGccIndex of
291 string mcode (*[*) * expression * string mcode (*]*) *
292 string mcode (*=*) * initialiser
293 | InitGccRange of
294 string mcode (*[*) * expression * string mcode (*...*) *
295 expression * string mcode (*]*) * string mcode (*=*) * initialiser
296 | IComma of string mcode (* , *)
297
298 | OptIni of initialiser
299 | UniqueIni of initialiser
300
301and initialiser = base_initialiser wrap
302
303(* --------------------------------------------------------------------- *)
304(* Parameter *)
305
306and base_parameterTypeDef =
307 VoidParam of fullType
308 | Param of fullType * ident option
309
310 | MetaParam of meta_name mcode * keep_binding * inherited
311 | MetaParamList of meta_name mcode * listlen option * keep_binding *
312 inherited
313
314 | PComma of string mcode
315
316 | Pdots of string mcode (* ... *)
317 | Pcircles of string mcode (* ooo *)
318
319 | OptParam of parameterTypeDef
320 | UniqueParam of parameterTypeDef
321
322and parameterTypeDef = base_parameterTypeDef wrap
323
324and parameter_list = parameterTypeDef dots
325
326(* --------------------------------------------------------------------- *)
327(* #define Parameters *)
328
329and base_define_param =
330 DParam of ident
331 | DPComma of string mcode
332 | DPdots of string mcode (* ... *)
333 | DPcircles of string mcode (* ooo *)
334 | OptDParam of define_param
335 | UniqueDParam of define_param
336
337and define_param = base_define_param wrap
338
339and base_define_parameters =
340 NoParams (* not parameter list, not an empty one *)
341 | DParams of string mcode(*( *) * define_param dots * string mcode(* )*)
342
343and define_parameters = base_define_parameters wrap
344
345(* --------------------------------------------------------------------- *)
346(* positions *)
347
348(* PER = keep bindings separate, ALL = collect them *)
349and meta_collect = PER | ALL
350
351and meta_pos =
352 MetaPos of meta_name mcode * meta_name list *
353 meta_collect * keep_binding * inherited
354 | NoMetaPos
355
356(* --------------------------------------------------------------------- *)
357(* Function declaration *)
358
359and storage = Static | Auto | Register | Extern
360
361(* --------------------------------------------------------------------- *)
362(* Top-level code *)
363
364and base_rule_elem =
365 FunHeader of mcodekind (* before the function header *) *
366 bool (* true if all minus, for dropping static, etc *) *
367 fninfo list * ident (* name *) *
368 string mcode (* ( *) * parameter_list *
369 string mcode (* ) *)
370 | Decl of mcodekind (* before the decl *) *
371 bool (* true if all minus *) * declaration
372
373 | SeqStart of string mcode (* { *)
374 | SeqEnd of string mcode (* } *)
375
376 | ExprStatement of expression * string mcode (*;*)
377 | IfHeader of string mcode (* if *) * string mcode (* ( *) *
378 expression * string mcode (* ) *)
379 | Else of string mcode (* else *)
380 | WhileHeader of string mcode (* while *) * string mcode (* ( *) *
381 expression * string mcode (* ) *)
382 | DoHeader of string mcode (* do *)
383 | WhileTail of string mcode (* while *) * string mcode (* ( *) *
384 expression * string mcode (* ) *) *
385 string mcode (* ; *)
386 | ForHeader of string mcode (* for *) * string mcode (* ( *) *
387 expression option * string mcode (*;*) *
388 expression option * string mcode (*;*) *
389 expression option * string mcode (* ) *)
390 | IteratorHeader of ident (* name *) * string mcode (* ( *) *
391 expression dots * string mcode (* ) *)
392 | SwitchHeader of string mcode (* switch *) * string mcode (* ( *) *
393 expression * string mcode (* ) *)
394 | Break of string mcode (* break *) * string mcode (* ; *)
395 | Continue of string mcode (* continue *) * string mcode (* ; *)
396 | Label of ident * string mcode (* : *)
397 | Goto of string mcode (* goto *) * ident * string mcode (* ; *)
398 | Return of string mcode (* return *) * string mcode (* ; *)
399 | ReturnExpr of string mcode (* return *) * expression *
400 string mcode (* ; *)
401
402 | MetaRuleElem of meta_name mcode * keep_binding * inherited
403 | MetaStmt of meta_name mcode * keep_binding * metaStmtInfo *
404 inherited
405 | MetaStmtList of meta_name mcode * keep_binding * inherited
406
407 | Exp of expression (* matches a subterm *)
408 | TopExp of expression (* for macros body, exp at top level,
409 not subexp *)
410 | Ty of fullType (* only at SP top level, matches a subterm *)
411 | Include of string mcode (*#include*) * inc_file mcode (*file *)
412 | DefineHeader of string mcode (* #define *) * ident (* name *) *
413 define_parameters (*params*)
414 | Case of string mcode (* case *) * expression * string mcode (*:*)
415 | Default of string mcode (* default *) * string mcode (*:*)
416 | DisjRuleElem of rule_elem list
417
418and fninfo =
419 FStorage of storage mcode
420 | FType of fullType
421 | FInline of string mcode
422 | FAttr of string mcode
423
424and metaStmtInfo =
425 NotSequencible | SequencibleAfterDots of dots_whencode list | Sequencible
426
427and rule_elem = base_rule_elem wrap
428
429and base_statement =
430 Seq of rule_elem (* { *) * statement dots *
431 statement dots * rule_elem (* } *)
432 | IfThen of rule_elem (* header *) * statement * end_info (* endif *)
433 | IfThenElse of rule_elem (* header *) * statement *
434 rule_elem (* else *) * statement * end_info (* endif *)
435 | While of rule_elem (* header *) * statement * end_info (*endwhile*)
436 | Do of rule_elem (* do *) * statement * rule_elem (* tail *)
437 | For of rule_elem (* header *) * statement * end_info (*endfor*)
438 | Iterator of rule_elem (* header *) * statement * end_info (*enditer*)
439 | Switch of rule_elem (* header *) * rule_elem (* { *) *
440 case_line list * rule_elem (* } *)
441 | Atomic of rule_elem
442 | Disj of statement dots list
443 | Nest of statement dots *
444 (statement dots,statement) whencode list * multi *
445 dots_whencode list * dots_whencode list
446 | FunDecl of rule_elem (* header *) * rule_elem (* { *) *
447 statement dots * statement dots * rule_elem (* } *)
448 | Define of rule_elem (* header *) * statement dots
449 | Dots of string mcode (* ... *) *
450 (statement dots,statement) whencode list *
451 dots_whencode list * dots_whencode list
452 | Circles of string mcode (* ooo *) *
453 (statement dots,statement) whencode list *
454 dots_whencode list * dots_whencode list
455 | Stars of string mcode (* *** *) *
456 (statement dots,statement) whencode list *
457 dots_whencode list * dots_whencode list
458 | OptStm of statement
459 | UniqueStm of statement
460
461and ('a,'b) whencode =
462 WhenNot of 'a
463 | WhenAlways of 'b
464 | WhenModifier of when_modifier
465 | WhenNotTrue of rule_elem (* useful for fvs *)
466 | WhenNotFalse of rule_elem
467
468and when_modifier =
469 (* The following removes the shortest path constraint. It can be used
470 with other when modifiers *)
471 WhenAny
472 (* The following removes the special consideration of error paths. It
473 can be used with other when modifiers *)
474 | WhenStrict
475 | WhenForall
476 | WhenExists
477
478(* only used with asttoctl *)
479and dots_whencode =
480 WParen of rule_elem * meta_name (*pren_var*)
481 | Other of statement
482 | Other_dots of statement dots
483
484and statement = base_statement wrap
485
486and base_case_line =
487 CaseLine of rule_elem (* case/default header *) * statement dots
488 | OptCase of case_line
489
490and case_line = base_case_line wrap
491
492and inc_file =
493 Local of inc_elem list
494 | NonLocal of inc_elem list
495
496and inc_elem =
497 IncPath of string
498 | IncDots
499
500and base_top_level =
501 DECL of statement
502 | CODE of statement dots
503 | FILEINFO of string mcode (* old file *) * string mcode (* new file *)
504 | ERRORWORDS of expression list
505
506and top_level = base_top_level wrap
507
508and rulename =
509 CocciRulename of string option * dependency *
510 string list * string list * exists * bool
511 | ScriptRulename of string * dependency
512
513and rule =
514 CocciRule of string (* name *) *
515 (dependency * string list (* dropped isos *) * exists) * top_level list
516 * bool list
517 | ScriptRule of string * dependency * (string * meta_name) list * string
518
519and dependency =
520 Dep of string (* rule applies for the current binding *)
521 | AntiDep of string (* rule doesn't apply for the current binding *)
522 | EverDep of string (* rule applies for some binding *)
523 | NeverDep of string (* rule never applies for any binding *)
524 | AndDep of dependency * dependency
525 | OrDep of dependency * dependency
526 | NoDep
527
528and rule_with_metavars = metavar list * rule
529
530and anything =
531 FullTypeTag of fullType
532 | BaseTypeTag of baseType
533 | StructUnionTag of structUnion
534 | SignTag of sign
535 | IdentTag of ident
536 | ExpressionTag of expression
537 | ConstantTag of constant
538 | UnaryOpTag of unaryOp
539 | AssignOpTag of assignOp
540 | FixOpTag of fixOp
541 | BinaryOpTag of binaryOp
542 | ArithOpTag of arithOp
543 | LogicalOpTag of logicalOp
544 | DeclarationTag of declaration
545 | InitTag of initialiser
546 | StorageTag of storage
547 | IncFileTag of inc_file
548 | Rule_elemTag of rule_elem
549 | StatementTag of statement
550 | CaseLineTag of case_line
551 | ConstVolTag of const_vol
552 | Token of string * info option
553 | Code of top_level
554 | ExprDotsTag of expression dots
555 | ParamDotsTag of parameterTypeDef dots
556 | StmtDotsTag of statement dots
557 | DeclDotsTag of declaration dots
558 | TypeCTag of typeC
559 | ParamTag of parameterTypeDef
560 | SgrepStartTag of string
561 | SgrepEndTag of string
562
563(* --------------------------------------------------------------------- *)
564
565and exists = Exists | Forall | ReverseForall | Undetermined
566
567(* --------------------------------------------------------------------- *)
568
569let mkToken x = Token (x,None)
570
571(* --------------------------------------------------------------------- *)
572
573let rewrap model x = {model with node = x}
574let rewrap_mcode (_,a,b,c) x = (x,a,b,c)
575let unwrap x = x.node
576let unwrap_mcode (x,_,_,_) = x
577let get_mcodekind (_,_,x,_) = x
578let get_line x = x.node_line
579let get_mcode_line (_,l,_,_) = l.line
580let get_fvs x = x.free_vars
581let set_fvs fvs x = {x with free_vars = fvs}
582let get_mfvs x = x.minus_free_vars
583let set_mfvs mfvs x = {x with minus_free_vars = mfvs}
584let get_fresh x = x.fresh_vars
585let get_inherited x = x.inherited
586let get_saved x = x.saved_witness
587let get_dots_bef_aft x = x.bef_aft
588let set_dots_bef_aft d x = {x with bef_aft = d}
589let get_pos x = x.pos_info
590let set_pos x pos = {x with pos_info = pos}
591let get_test_exp x = x.true_if_test_exp
592let set_test_exp x = {x with true_if_test_exp = true}
593let get_isos x = x.iso_info
594let set_isos x isos = {x with iso_info = isos}
595let get_pos_var (_,_,_,p) = p
596let set_pos_var vr (a,b,c,_) = (a,b,c,vr)
597let drop_pos (a,b,c,_) = (a,b,c,NoMetaPos)
598
599let get_wcfvs (whencode : ('a wrap, 'b wrap) whencode list) =
600 Common.union_all
601 (List.map
602 (function
603 WhenNot(a) -> get_fvs a
604 | WhenAlways(a) -> get_fvs a
605 | WhenModifier(_) -> []
606 | WhenNotTrue(e) -> get_fvs e
607 | WhenNotFalse(e) -> get_fvs e)
608 whencode)
609
610(* --------------------------------------------------------------------- *)
611
612let get_meta_name = function
613 MetaIdDecl(ar,nm) -> nm
614 | MetaFreshIdDecl(ar,nm) -> nm
615 | MetaTypeDecl(ar,nm) -> nm
616 | MetaListlenDecl(nm) -> nm
617 | MetaParamDecl(ar,nm) -> nm
618 | MetaParamListDecl(ar,nm,nm1) -> nm
619 | MetaConstDecl(ar,nm,ty) -> nm
620 | MetaErrDecl(ar,nm) -> nm
621 | MetaExpDecl(ar,nm,ty) -> nm
622 | MetaIdExpDecl(ar,nm,ty) -> nm
623 | MetaLocalIdExpDecl(ar,nm,ty) -> nm
624 | MetaExpListDecl(ar,nm,nm1) -> nm
625 | MetaStmDecl(ar,nm) -> nm
626 | MetaStmListDecl(ar,nm) -> nm
627 | MetaFuncDecl(ar,nm) -> nm
628 | MetaLocalFuncDecl(ar,nm) -> nm
629 | MetaPosDecl(ar,nm) -> nm
630 | MetaDeclarerDecl(ar,nm) -> nm
631 | MetaIteratorDecl(ar,nm) -> nm
632
633(* --------------------------------------------------------------------- *)
634
635let no_info = { line = 0; column = 0; strbef = []; straft = [] }
636
637let make_term x =
638 {node = x;
639 node_line = 0;
640 free_vars = [];
641 minus_free_vars = [];
642 fresh_vars = [];
643 inherited = [];
644 saved_witness = [];
645 bef_aft = NoDots;
646 pos_info = None;
647 true_if_test_exp = false;
648 iso_info = [] }
649
650let make_meta_rule_elem s d (fvs,fresh,inh) =
651 {(make_term
652 (MetaRuleElem((("",s),no_info,d,NoMetaPos),Type_cocci.Unitary,false)))
653 with free_vars = fvs; fresh_vars = fresh; inherited = inh}
654
655let make_meta_decl s d (fvs,fresh,inh) =
656 {(make_term
657 (MetaDecl((("",s),no_info,d,NoMetaPos),Type_cocci.Unitary,false))) with
658 free_vars = fvs; fresh_vars = fresh; inherited = inh}
659
660let make_mcode x = (x,no_info,CONTEXT(NoPos,NOTHING),NoMetaPos)
661
662(* --------------------------------------------------------------------- *)
663
664let equal_pos x y = x = y
665
666(* --------------------------------------------------------------------- *)
667
668let undots x =
669 match unwrap x with
670 DOTS e -> e
671 | CIRCLES e -> e
672 | STARS e -> e