permit multiline comments and strings in macros
[bpt/coccinelle.git] / engine / lib_engine.ml
CommitLineData
f537ebc4 1(*
17ba0788
C
2 * Copyright 2012, INRIA
3 * Julia Lawall, Gilles Muller
4 * Copyright 2010-2011, INRIA, University of Copenhagen
f537ebc4
C
5 * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
6 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
7 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
8 * This file is part of Coccinelle.
9 *
10 * Coccinelle is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, according to version 2 of the License.
13 *
14 * Coccinelle is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * The authors reserve the right to distribute this or future versions of
23 * Coccinelle under other licenses.
24 *)
25
26
feec80c3 27# 0 "./lib_engine.ml"
34e49164
C
28open Ograph_extended
29
30(*****************************************************************************)
31(* the different ctl formula related types *)
32(*****************************************************************************)
33type mvar = Ast_cocci.meta_name
34
35type predicate =
36 InLoop | TrueBranch | FalseBranch
37 | After (* pointer to the code after an if or while *)
951c7801 38 | FallThrough | LoopFallThrough
34e49164 39 | Return (* any exit from the current function *)
5427db06 40 | FunHeader | UnsafeBrace | Top | Exit | ErrorExit | Goto
34e49164
C
41 | Paren of Ast_cocci.meta_name
42 | Match of Ast_cocci.rule_elem
43 | Label of Ast_cocci.meta_name
44 | BCLabel of Ast_cocci.meta_name (* parent of break or continue *)
45 | PrefixLabel of Ast_cocci.meta_name
46 | BindGood of Ast_cocci.meta_name (* used to implement \+ *)
47 | BindBad of Ast_cocci.meta_name
48 | FakeBrace
49
485bce71 50(* coccionly: *)
34e49164
C
51type ctlcocci = (predicate, Ast_cocci.meta_name) Wrapper_ctl.wrapped_ctl
52
53
54(*****************************************************************************)
55(* the different binding types *)
56(*****************************************************************************)
57type metavars_binding = Ast_c.metavars_binding
58
59(* used in ctlcocci_integration *)
ae4735db 60type metavar_binding_kind2 =
34e49164
C
61 | NormalMetaVal of Ast_c.metavar_binding_kind
62 | ParenVal of Ast_cocci.meta_name
7f004419 63 | LabelVal of labelval
34e49164
C
64 | GoodVal | BadVal (* used to implement \+ *)
65
7f004419
C
66and labelval = Absolute of int list | Prefix of int list
67
34e49164
C
68and metavars_binding2 = (mvar, metavar_binding_kind2) Common.assoc
69
70
71
72(*****************************************************************************)
73(* the CTL model related types *)
74(*****************************************************************************)
485bce71 75(* coccionly: *)
ae4735db
C
76type label_ctlcocci =
77 predicate ->
78 (nodei *
79 (predicate * (mvar, metavar_binding_kind2) Ast_ctl.generic_substitution))
34e49164 80 list
ae4735db 81
34e49164
C
82type model = Control_flow_c.cflow * label_ctlcocci * nodei list
83
ae4735db 84type transformation_info =
34e49164
C
85 (nodei * metavars_binding * Ast_cocci.rule_elem) list
86
ae4735db 87type numbered_transformation_info =
708f4980
C
88 (int list * (nodei * metavars_binding * Ast_cocci.rule_elem)) list
89
34e49164
C
90
91(*****************************************************************************)
92(* comparing binding *)
93(*****************************************************************************)
94
ae4735db 95let equal_binding xs ys =
34e49164 96 List.sort compare xs = List.sort compare ys