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