On Wed, 13 Jan 2010, Michael Stefaniuc wrote:

> Nicolas Palix wrote:
> > On Wednesday 13 January 2010 12:10:20 Michael Stefaniuc wrote:
> >> Nicolas Palix wrote:
> >>> On Saturday 09 January 2010 17:26:37 Michael Stefaniuc wrote:
> >>>> coccinelle 0.1.11 introduced regexp support for meta-identifier/function 
> >>>> and constant. The release notes says it's an OCaml regexp and points to 
> >>>> "man Str" for details but I don
> >>>>
> >>>> I tried to make use of grouping and alternatives but I get errors like:
> >>>> identifier SPAM ~= "\(WINE_\)?\(ERR\|FIXME\|WARN\)";
> >>>>    Fatal error: exception Lexer_cocci.Lexical("unrecognised symbol:\(")
> >>>> identifier SPAM ~= "ERR\|FIXME\|WARN";
> >>>>    Fatal error: exception Lexer_cocci.Lexical("unrecognised symbol:\|")
> >>>>
> >>>> Is this a known limitation or just a bug?
> >>> The following patch will fix this bug.
> >> thanks for the fix; I have tried coccinelle 0.2.0 and it works fine.
> >> Using the coccinelle/OCaml regexp seems to be way faster than just using
> >> "identifier SPAM;" and filtering it later on in python. For my script on
> >> a Wine C file it's the difference between finishing in 12 minutes or
> >> killing the spatch process after 90+ minutes of burned CPU time (though
> >> the python variant was timed with coccinelle 0.2.0-rc1).
> >>
> > 
> > You're welcome.
> > 
> > Have you tried to inline your SPAM identifier in the matching part
> > of the semantic patch? It is maybe faster than using regexp but I haven't 
> > checked.
> > Indeed, as you're matching the regexp (~=), and not it's negation, you may 
> > replace
> > 
> > ====================================
> > @@
> > identifier SPAM ~= "ERR\|FIXME"
> > @@
> > 
> > SPAM
> > 
> > ====================================
> > 
> > by
> > 
> > ====================================
> > @@
> > @@
> > 
> >   \(ERR\|FIXME\)
> > ====================================
> > 
> > Please, could you report any performance improvement/degradation if you try 
> > this?
> Heh, I tried it already but I need to know the type of "SPAM" aka if
> it's an ERR or FIXME or WARN. I've done \(e...@p\|fi...@p\|w...@p\) and
> the last element matched is stored in p but that seems to be the
> function name and not the element to which p is attached.

Not sure to understand.  A position variable should always give the 
position of the token or metavariable to which it is attached.  If you can 
reproduce the problem, please send an example.

On the other hand, in your case, you would probably want a different 
position variable for each one, to know which one was matched.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to