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