xref: /dragonfly/test/cocci/comma.cocci (revision 7ff0fc30)
1//
2//  convert comma to semicolon
3//    needs devel/ocaml-findlib
4//
5// Target: Linux
6// Copyright:  Copyright: 2014 - LIP6/INRIA
7// License:  Licensed under GPLv2 or any later version.
8// Author: Julia Lawall <Julia.Lawall@lip6.fr>
9// URL: http://coccinelle.lip6.fr/
10// URL: http://coccinellery.org/
11
12@initialize:ocaml@
13@@
14let tbl = Hashtbl.create(100)
15
16let add_if_not_present file =
17try let _ = Hashtbl.find tbl file in ()
18with Not_found ->
19   Hashtbl.add tbl file ();
20   let it = new iteration() in
21   it#set_files [file];
22   it#register()
23
24@script:ocaml@
25@@
26Hashtbl.clear tbl
27
28@r@
29expression e1,e2,e;
30position p1,p2;
31type T;
32identifier i;
33@@
34
35(
36T i = ...;
37|
38 e;
39)
40 e1,@p1 e2@p2;
41
42@script:ocaml@
43p1 << r.p1;
44p2 << r.p2;
45@@
46
47if (List.hd p1).line = (List.hd p2).line
48then include_match false
49else add_if_not_present ((List.hd p1).file)
50
51@@
52expression e1,e2;
53position r.p1;
54@@
55
56 e1
57- ,@p1
58+ ;
59  e2;
60