Release coccinelle-0.2.0
[bpt/coccinelle.git] / demos / regexp.cocci
1 @anyid@
2 type t;
3 identifier id;
4 @@
5
6 t id () {
7 ...
8 }
9
10 @script:python@
11 x << anyid.id;
12 @@
13
14 print "Identifier: %s" % x
15
16 @contains@
17 type t;
18 identifier foo ~= ".*foo";
19 @@
20
21 t foo () {
22 ...
23 }
24
25 @script:python@
26 x << contains.foo;
27 @@
28
29 print "Contains foo: %s" % x
30
31 @nocontain@
32 type t;
33 identifier foo !~= ".*foo";
34 @@
35
36 t foo () {
37 ...
38 }
39
40 @script:python@
41 x << nocontain.foo;
42 @@
43
44 print "Does not contain foo: %s" % x
45
46 @endsby@
47 type t;
48 identifier foo ~= ".*foo$";
49 @@
50
51 t foo () {
52 ...
53 }
54
55 @script:python@
56 x << endsby.foo;
57 @@
58
59 print "Ends by foo: %s" % x
60
61 @beginsby@
62 type t;
63 identifier foo ~= "^foo";
64 @@
65
66 t foo () {
67 ...
68 }
69
70 @script:python@
71 x << beginsby.foo;
72 @@
73
74 print "Begins by foo: %s" % x