julia at diku.dk
Sat Jun 19 09:34:28 CEST 2010
0.2.3rc3 is now available. The main change is the ability to write
scripts using ocaml. The notation is the same as for python; just replace
eg script:python by script:ocaml. Terms inherited from the smpl rules are
still expressed as strings. The only change is that in positions, line
numbers etc are expressed as integers rather than strings. The script
rules and the finalize rule are wrapped in functions, but the initialize
rule is inlined into the ocaml code as is. This allows the initialize
rule to declare global variables. On the other hand, actions to be
performed in the initialize rule must be wrapped in let _ = ...
The main advantage of using ocaml scripting as compared to python
scripting is that the ocaml code is statically type checked. Indeed, the
ocaml code is type checked and compiled already when using -parse_cocci,
so you can check that your scripts are OK before applying your semantic
patch to any source code.
There are some very simple examples of the use of ocaml in the demos
directory (ocaml.cocci and ocaml1.cocci).
More information about the Cocci