| 1 |
(* |
| 2 |
* This file is part of Coccinelle, lincensed under the terms of the GPL v2. |
| 3 |
* See copyright.txt in the Coccinelle source code for more information. |
| 4 |
* The Coccinelle source code can be obtained at http://coccinelle.lip6.fr |
| 5 |
*) |
| 6 |
|
| 7 |
(* |
| 8 |
* Creates two script rules like: |
| 9 |
* |
| 10 |
* @script:python depends on org@ |
| 11 |
* p1 << rulename.p1; |
| 12 |
* p2 << rulename.p2; |
| 13 |
* x << rulename.x; |
| 14 |
* @@ |
| 15 |
* |
| 16 |
* msg="Warning: This is a message! Found %s." % (x) |
| 17 |
* coccilib.org.print_safe_todo(p1[0], msg) |
| 18 |
* coccilib.org.print_link(p2[0], "") |
| 19 |
* |
| 20 |
* |
| 21 |
* @script:python depends on report@ |
| 22 |
* p1 << rulename.p1; |
| 23 |
* p2 << rulename.p2; |
| 24 |
* @@ |
| 25 |
* |
| 26 |
* msg="Error: This is a report message on line %s" % (p2[0].line) |
| 27 |
* coccilib.report.print_report(p1[0], msg) |
| 28 |
*) |
| 29 |
|
| 30 |
(* ------------------------------------------------------------------------- *) |
| 31 |
(* SCRIPT GENERATION FUNCTIONS *) |
| 32 |
|
| 33 |
type t |
| 34 |
|
| 35 |
(* generates org and report script for one rule. |
| 36 |
* metapos is the list of added metapositions that show where the match is. |
| 37 |
* user_rule contains the rule name, the rule messages and the metavars. |
| 38 |
* |
| 39 |
* INVARIANT: there MUST be at least one position in the metapos list!!! |
| 40 |
*) |
| 41 |
val generate : |
| 42 |
meta_pos:Meta_variable.t list -> |
| 43 |
user_rule:User_input.Rule.t -> |
| 44 |
t |
| 45 |
|
| 46 |
(* prints org rule *) |
| 47 |
val print_org : out_channel -> t -> unit |
| 48 |
|
| 49 |
(* prints report rule *) |
| 50 |
val print_report : out_channel -> t -> unit |