On Wed, 12 Oct 2011, ben wrote:

> 
> >
> >Sorry, I thought you wanted to create a nested function.  There is
> >currently no way to match a nested function.  It is not an intrinsic
> >limitation, just a matter of development effort.
> >
> >julia
> 
> Then we come to the point I've mentioned in my initial posting: Writing
> nonfunctional but valid C, in order to write an extension.
> 
> In the case of the nested function I would assemble it from:
> - a function declaration
> - a label
> - a block
> 
> I use the label, because I think it's not possible for coccinelle to match an
> 'anonymous' block.
> 
> ~ ~ ~ ~ ~ ~ ~ nestedfunction.pseudoc ~~~~~~~~~~~
> void outer(){
>    void inner (); // declaration
>    inner: { // a goto label and the beginning of a block
>       printf("look Ma, I'm nested\n");
>    } // end of the block
> }
> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
> 
> to
> 
> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ nested.c ~~~~~~~~~~~~
> void outer(){
>    void inner ();

Is this supposed to be the declaration of a function pointer?  You can 
write code to match the declaration of a function pointer, and then use 
a statement metavariable to match the block after it.  Then use that 
metavariable (with extra braces around it) to create the new function 
definition.

julia

>    inner();
> }
> 
> void inner () {
>    printf("look Ma, I'm nested\n");
> }
> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
> 
> Would this be possible?
> 
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to