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