[Cocci] how to pass a regexp for a virtual identifier
Julia Lawall
julia.lawall at lip6.fr
Sat Mar 3 15:30:27 CET 2012
On Fri, 2 Mar 2012, Julia Lawall wrote:
> On Fri, 2 Mar 2012, David Wagner wrote:
>
>> Hi all,
>>
>> I have successfully used a regular expression for a function name but
>> I didn't find how to pass it on the command line.
>>
>> I first tried
>> identifier virtual.func
>> with
>> -D func=~"^nvm_"
>> but realised that it didn't make sense and then tried
>> identifier func =~ virtual.regexp
>> with
>> -D regexp="^nvm_"
>> but that doesn't work either.
>>
>> Does that functionality exists yet and if yes, how should it be used ?
>
> No it doesn't exist. Regular expressions are not currently metavariables. It
> could probably be added. Identifier metavariables can be used in fresh
> identifier declarations, for example.
Maybe you can just use the regular expression in a script:
@r@
identifier f;
@@
f (...) { ... }
@script:ocaml@
f << r.f;
re << virtual.re;
@@
if not (Str.string_match (Str.regexp re) f 0)
then Coccilib.include_match(false)
In python, you would say cocci.include_match(False) for the cases you want
to discard.
julia
More information about the Cocci
mailing list