On Wed, 29 Jun 2011, Ajay Panyala wrote: > But isn't the portion you know again an expression? > > Yes, It can be. A simple example could be like > > ... + deviceA * inpB + ... > > and the only thing I know is deviceA * inpB occours as > part of the expression or only deviceA in some cases. > There is no information about the remaining number of > operands and type of operators involved in the expression.
You could try it like that :) If that is all there is you will have a paring problem, because it won't know if the first ... should be an expression or statement. You can put the word expression between the initial @@ to say that the entire rule should be parsed as an expression. Note that eg x || ... matches any disjunction with x at top level. So it matches a || x || b or x || a || b or a || b || x. I believe that something similar is done with + and *. You can also write <+... a + b ...+> to match an expression that has a + b somewhere as a subterm. If you have some more concrete things that you don't see how to express, feel free to ask. julia > Thanks > Ajay > > On Wed, Jun 29, 2011 at 2:26 PM, Michael Stefaniuc <[email protected]>wrote: > > > On 06/29/2011 07:11 PM, Ajay Panyala wrote: > > > That's not an expression but an identifier. > > > > > > Sorry for not being clear. By 'knownPart' I meant > > > the portion of the expression that is known to me. > > But isn't the portion you know again an expression? Or multiple > > expressions with operators between them. You can match that just fine > > without the need of regexps. > > > > > I will check out the regexps in wiki and the example > > > from demos. > > > > > On Wed, Jun 29, 2011 at 11:59 AM, Michael Stefaniuc <[email protected] > > >wrote: > > > > > >> Ajay Panyala wrote: > > >>> Is it also possible to match partial expressions? > > >>> > > >>> For example I know only a part of an expression > > >>> that I want to match. > > >>> > > >>> xxx_knownPart_xxx > > >>> > > >>> Can a patch be written to match the above example? > > >> That's not an expression but an identifier. coccinelle supports regexps > > >> for identifiers, it is in the documentation and on the wiki. > > >> For other metavariables you'd have to loop them through a python or > > >> ocaml rule, a python example is on the wiki too afair. > > >> > > > > bye > > michael > > > _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
