Commit | Line | Data |
---|---|---|
5636bb2c C |
1 | (* |
2 | * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen | |
3 | * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix | |
4 | * This file is part of Coccinelle. | |
5 | * | |
6 | * Coccinelle is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, according to version 2 of the License. | |
9 | * | |
10 | * Coccinelle is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>. | |
17 | * | |
18 | * The authors reserve the right to distribute this or future versions of | |
19 | * Coccinelle under other licenses. | |
20 | *) | |
21 | ||
22 | ||
9f8e26f4 | 23 | (* |
ae4735db | 24 | * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen |
9f8e26f4 C |
25 | * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix |
26 | * This file is part of Coccinelle. | |
27 | * | |
28 | * Coccinelle is free software: you can redistribute it and/or modify | |
29 | * it under the terms of the GNU General Public License as published by | |
30 | * the Free Software Foundation, according to version 2 of the License. | |
31 | * | |
32 | * Coccinelle is distributed in the hope that it will be useful, | |
33 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
34 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
35 | * GNU General Public License for more details. | |
36 | * | |
37 | * You should have received a copy of the GNU General Public License | |
38 | * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>. | |
39 | * | |
40 | * The authors reserve the right to distribute this or future versions of | |
41 | * Coccinelle under other licenses. | |
42 | *) | |
43 | ||
44 | ||
34e49164 C |
45 | (* types that clutter the .mly file *) |
46 | (* for iso metavariables, true if they can only match nonmodified, unitary | |
47 | metavariables *) | |
48 | type fresh = bool | |
49 | ||
951c7801 C |
50 | type incl_iso = |
51 | Include of string | Iso of (string,string) Common.either | |
52 | | Virt of string list (* virtual rules *) | |
978fd7e5 | 53 | |
34e49164 C |
54 | type clt = |
55 | line_type * int * int * int * int (* starting spaces *) * | |
c3e37e97 C |
56 | (Ast_cocci.added_string * Ast0_cocci.position_info) list (*code before*) * |
57 | (Ast_cocci.added_string * Ast0_cocci.position_info) list (*code after *) * | |
34e49164 C |
58 | Ast0_cocci.meta_pos (* position variable, minus only *) |
59 | ||
60 | (* ---------------------------------------------------------------------- *) | |
61 | ||
62 | and line_type = | |
63 | MINUS | OPTMINUS | UNIQUEMINUS | |
951c7801 | 64 | | PLUS | PLUSPLUS |
34e49164 C |
65 | | CONTEXT | UNIQUE | OPT |
66 | ||
951c7801 C |
67 | type iconstraints = Ast_cocci.idconstraint |
68 | type econstraints = Ast0_cocci.constraints | |
34e49164 C |
69 | type pconstraints = Ast_cocci.meta_name list |
70 | ||
71 | val in_rule_name : bool ref (* true if parsing the rule name *) | |
72 | val in_meta : bool ref (* true if parsing the metavariable decls *) | |
73 | val in_iso : bool ref (* true if parsing the isomorphisms *) | |
faf9a90c | 74 | val in_generating : bool ref(* true if generating a rule *) |
7f004419 | 75 | val ignore_patch_or_match : bool ref (* skip rules not satisfying virt *) |
34e49164 | 76 | val in_prolog : bool ref (* true if parsing the beginning of an SP *) |
978fd7e5 | 77 | val saw_struct : bool ref (* true if saw struct/union *) |
34e49164 C |
78 | val inheritable_positions : string list ref |
79 | ||
978fd7e5 C |
80 | val call_in_meta : (unit -> 'a) -> 'a |
81 | ||
34e49164 C |
82 | val all_metadecls : (string, Ast_cocci.metavar list) Hashtbl.t |
83 | ||
84 | val clear_meta: (unit -> unit) ref | |
85 | ||
86 | val add_id_meta: | |
87 | (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref | |
88 | ||
ae4735db C |
89 | val add_virt_id_meta_found: (string -> string -> unit) ref |
90 | ||
91 | val add_virt_id_meta_not_found: | |
92 | (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref | |
93 | ||
b1b2de81 C |
94 | val add_fresh_id_meta: (Ast_cocci.meta_name -> unit) ref |
95 | ||
34e49164 C |
96 | val add_type_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref |
97 | ||
113803cf C |
98 | val add_init_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref |
99 | ||
34e49164 C |
100 | val add_param_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref |
101 | ||
102 | val add_paramlist_meta: | |
103 | (Ast_cocci.meta_name -> Ast_cocci.meta_name option -> Ast0_cocci.pure -> | |
104 | unit) ref | |
105 | ||
106 | val add_const_meta: | |
107 | (Type_cocci.typeC list option -> Ast_cocci.meta_name -> econstraints -> | |
108 | Ast0_cocci.pure -> unit) ref | |
109 | ||
110 | val add_err_meta: | |
111 | (Ast_cocci.meta_name -> econstraints -> Ast0_cocci.pure -> unit) ref | |
112 | ||
113 | val add_exp_meta: | |
114 | (Type_cocci.typeC list option -> Ast_cocci.meta_name -> econstraints -> | |
115 | Ast0_cocci.pure -> unit) ref | |
116 | ||
117 | val add_idexp_meta: | |
118 | (Type_cocci.typeC list option -> Ast_cocci.meta_name -> | |
119 | econstraints -> Ast0_cocci.pure -> unit) ref | |
120 | ||
121 | val add_local_idexp_meta: | |
122 | (Type_cocci.typeC list option -> Ast_cocci.meta_name -> | |
123 | econstraints -> Ast0_cocci.pure -> unit) ref | |
124 | ||
125 | val add_explist_meta: | |
126 | (Ast_cocci.meta_name -> Ast_cocci.meta_name option -> Ast0_cocci.pure -> | |
127 | unit) ref | |
128 | ||
129 | val add_stm_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref | |
130 | ||
131 | val add_stmlist_meta: (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref | |
132 | ||
133 | val add_func_meta: | |
134 | (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref | |
135 | ||
136 | val add_local_func_meta: | |
137 | (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref | |
138 | ||
139 | val add_declarer_meta: | |
140 | (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref | |
141 | ||
142 | val add_iterator_meta: | |
143 | (Ast_cocci.meta_name -> iconstraints -> Ast0_cocci.pure -> unit) ref | |
144 | ||
145 | val add_pos_meta: | |
146 | (Ast_cocci.meta_name -> pconstraints -> Ast_cocci.meta_collect -> unit) ref | |
147 | ||
148 | val add_type_name: (string -> unit) ref | |
149 | ||
150 | val add_declarer_name: (string -> unit) ref | |
151 | ||
152 | val add_iterator_name: (string -> unit) ref | |
153 | ||
154 | val init_rule: (unit -> unit) ref | |
155 | ||
156 | val install_bindings: (string -> unit) ref |