Commit | Line | Data |
---|---|---|
34e49164 C |
1 | module Ast0 = Ast0_cocci |
2 | module Ast = Ast_cocci | |
3 | ||
4 | (* types that clutter the .mly file *) | |
5 | (* for iso metavariables, true if they can only match nonmodified, unitary | |
6 | metavariables *) | |
7 | type fresh = bool | |
8 | ||
951c7801 C |
9 | type incl_iso = |
10 | Include of string | Iso of (string,string) Common.either | |
11 | | Virt of string list (* virtual rules *) | |
978fd7e5 | 12 | |
34e49164 C |
13 | type clt = |
14 | line_type * int * int * int * int (* starting spaces *) * | |
c3e37e97 C |
15 | (Ast_cocci.added_string * Ast0.position_info) list (* code before *) * |
16 | (Ast_cocci.added_string * Ast0.position_info) list (* code after *) * | |
34e49164 C |
17 | Ast0.meta_pos (* position variable, minus only *) |
18 | ||
19 | (* ---------------------------------------------------------------------- *) | |
20 | ||
21 | (* Things that need to be seen by the lexer and parser. *) | |
22 | ||
23 | and line_type = | |
24 | MINUS | OPTMINUS | UNIQUEMINUS | |
951c7801 | 25 | | PLUS | PLUSPLUS |
34e49164 C |
26 | | CONTEXT | UNIQUE | OPT |
27 | ||
951c7801 C |
28 | type iconstraints = Ast.idconstraint |
29 | type econstraints = Ast0.constraints | |
34e49164 C |
30 | type pconstraints = Ast.meta_name list |
31 | ||
32 | let in_rule_name = ref false | |
33 | let in_meta = ref false | |
34 | let in_iso = ref false | |
faf9a90c | 35 | let in_generating = ref false |
7f004419 | 36 | let ignore_patch_or_match = ref false |
34e49164 | 37 | let in_prolog = ref false |
978fd7e5 C |
38 | (* state machine for lexer..., allows smpl keywords as type names *) |
39 | let saw_struct = ref false | |
34e49164 C |
40 | let inheritable_positions = |
41 | ref ([] : string list) (* rules from which posns can be inherited *) | |
42 | ||
978fd7e5 C |
43 | let call_in_meta f = |
44 | in_meta := true; saw_struct := false; | |
45 | let res = f() in | |
46 | in_meta := false; | |
47 | res | |
48 | ||
34e49164 C |
49 | let all_metadecls = |
50 | (Hashtbl.create(100) : (string, Ast.metavar list) Hashtbl.t) | |
51 | ||
faf9a90c C |
52 | let clear_meta: (unit -> unit) ref = |
53 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
54 | |
55 | let add_id_meta: | |
faf9a90c C |
56 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = |
57 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 58 | |
ae4735db C |
59 | let add_virt_id_meta_found: (string -> string -> unit) ref = |
60 | ref (fun _ -> failwith "uninitialized add_meta") | |
61 | ||
62 | let add_virt_id_meta_not_found: | |
63 | (Ast_cocci.meta_name -> Ast0_cocci.pure -> unit) ref = | |
64 | ref (fun _ -> failwith "uninitialized add_meta") | |
65 | ||
b1b2de81 C |
66 | let add_fresh_id_meta: (Ast.meta_name -> unit) ref = |
67 | ref (fun _ -> failwith "uninitialized add_meta") | |
68 | ||
faf9a90c C |
69 | let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
70 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 71 | |
113803cf C |
72 | let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
73 | ref (fun _ -> failwith "uninitialized add_meta") | |
74 | ||
faf9a90c C |
75 | let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
76 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
77 | |
78 | let add_paramlist_meta: | |
88e71198 | 79 | (Ast.meta_name -> Ast.list_len -> Ast0.pure -> unit) ref = |
faf9a90c | 80 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
81 | |
82 | let add_const_meta: | |
83 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
84 | Ast0.pure -> unit) | |
85 | ref = | |
faf9a90c | 86 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
87 | |
88 | let add_err_meta: | |
89 | (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 90 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
91 | |
92 | let add_exp_meta: | |
93 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
94 | Ast0.pure -> unit) | |
95 | ref = | |
faf9a90c | 96 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
97 | |
98 | let add_idexp_meta: | |
99 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
100 | Ast0.pure -> unit) | |
101 | ref = | |
faf9a90c | 102 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
103 | |
104 | let add_local_idexp_meta: | |
105 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
106 | Ast0.pure -> unit) | |
107 | ref = | |
faf9a90c | 108 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
109 | |
110 | let add_explist_meta: | |
88e71198 | 111 | (Ast.meta_name -> Ast.list_len -> Ast0.pure -> unit) ref = |
faf9a90c | 112 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 | 113 | |
413ffc02 C |
114 | let add_decl_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
115 | ref (fun _ -> failwith "uninitialized add_meta") | |
116 | ||
117 | let add_field_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = | |
118 | ref (fun _ -> failwith "uninitialized add_meta") | |
119 | ||
faf9a90c C |
120 | let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
121 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 122 | |
faf9a90c C |
123 | let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
124 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
125 | |
126 | let add_func_meta: | |
faf9a90c C |
127 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = |
128 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
129 | |
130 | let add_local_func_meta: | |
faf9a90c C |
131 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = |
132 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
133 | |
134 | let add_declarer_meta: | |
135 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 136 | ref (fun _ -> failwith "uninitialized add_decl") |
34e49164 C |
137 | |
138 | let add_iterator_meta: | |
139 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 140 | ref (fun _ -> failwith "uninitialized add_iter") |
34e49164 C |
141 | |
142 | let add_pos_meta: | |
faf9a90c C |
143 | (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref = |
144 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 145 | |
faf9a90c C |
146 | let add_type_name: (string -> unit) ref = |
147 | ref (fun _ -> failwith "uninitialized add_type") | |
34e49164 | 148 | |
faf9a90c C |
149 | let add_declarer_name: (string -> unit) ref = |
150 | ref (fun _ -> failwith "uninitialized add_decl") | |
34e49164 | 151 | |
faf9a90c C |
152 | let add_iterator_name: (string -> unit) ref = |
153 | ref (fun _ -> failwith "uninitialized add_iter") | |
34e49164 C |
154 | |
155 | let init_rule: (unit -> unit) ref = | |
faf9a90c | 156 | ref (fun _ -> failwith "uninitialized install_bindings") |
34e49164 C |
157 | |
158 | let install_bindings: (string -> unit) ref = | |
faf9a90c | 159 | ref (fun _ -> failwith "uninitialized install_bindings") |