All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] script code on metavariables
@ 2016-01-17  8:47 Julia Lawall
  2016-01-18 10:11 ` SF Markus Elfring
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2016-01-17  8:47 UTC (permalink / raw)
  To: cocci

Some time ago, the idea of putting constraints expressed as scripts was 
discussed 
(http://article.gmane.org/gmane.comp.version-control.coccinelle/1928).

This has now been implemented, only for position variables and only for 
ocaml scripting:

The basic notation is:

position p : script:ocaml(params) { expression };

Params can only be inherited metavariables.  Due to parsing constraints, 
the expression has to be a C expression, even though the script language 
is OCaml.  Fortunately, it is possible to make an OCaml function call that 
looks just like a C function call.  The expression can also refer to the 
metavariable p being defined.  The expression should return true or false, 
ie true if the proposed value of p is acceptable as a match, and false if 
it is not.

A real-life example is:
position jp : script:ocaml() { check_in_a_hunk("P",plus_hunks,jp) };

Any thoughts about the syntax?  For example, I don't think that the 
script: and the { } are strictly necessary from a parsing point of view.

This could be extended to other metavariable types, and eventully to 
Python.

thanks,
julia

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-01-18 20:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-17  8:47 [Cocci] script code on metavariables Julia Lawall
2016-01-18 10:11 ` SF Markus Elfring
2016-01-18 10:15   ` Julia Lawall
2016-01-18 10:30     ` SF Markus Elfring
2016-01-18 10:43       ` Julia Lawall
2016-01-18 12:00         ` SF Markus Elfring
2016-01-18 12:05           ` Julia Lawall
2016-01-18 12:28             ` SF Markus Elfring
2016-01-18 20:25         ` [Cocci] Documentation check for parallelisation support? SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.