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 *) * | |
0708f913 C |
15 | (string * Ast0.position_info) list (* code before *) * |
16 | (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 | |
b1b2de81 C |
59 | let add_fresh_id_meta: (Ast.meta_name -> unit) ref = |
60 | ref (fun _ -> failwith "uninitialized add_meta") | |
61 | ||
faf9a90c C |
62 | let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
63 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 64 | |
113803cf C |
65 | let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
66 | ref (fun _ -> failwith "uninitialized add_meta") | |
67 | ||
faf9a90c C |
68 | let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
69 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
70 | |
71 | let add_paramlist_meta: | |
faf9a90c C |
72 | (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref = |
73 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
74 | |
75 | let add_const_meta: | |
76 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
77 | Ast0.pure -> unit) | |
78 | ref = | |
faf9a90c | 79 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
80 | |
81 | let add_err_meta: | |
82 | (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 83 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
84 | |
85 | let add_exp_meta: | |
86 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
87 | Ast0.pure -> unit) | |
88 | ref = | |
faf9a90c | 89 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
90 | |
91 | let add_idexp_meta: | |
92 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
93 | Ast0.pure -> unit) | |
94 | ref = | |
faf9a90c | 95 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
96 | |
97 | let add_local_idexp_meta: | |
98 | (Type_cocci.typeC list option -> Ast.meta_name -> econstraints -> | |
99 | Ast0.pure -> unit) | |
100 | ref = | |
faf9a90c | 101 | ref (fun _ -> failwith "uninitialized add_meta") |
34e49164 C |
102 | |
103 | let add_explist_meta: | |
faf9a90c C |
104 | (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref = |
105 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 106 | |
faf9a90c C |
107 | let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
108 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 109 | |
faf9a90c C |
110 | let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref = |
111 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
112 | |
113 | let add_func_meta: | |
faf9a90c C |
114 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = |
115 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
116 | |
117 | let add_local_func_meta: | |
faf9a90c C |
118 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = |
119 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 C |
120 | |
121 | let add_declarer_meta: | |
122 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 123 | ref (fun _ -> failwith "uninitialized add_decl") |
34e49164 C |
124 | |
125 | let add_iterator_meta: | |
126 | (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref = | |
faf9a90c | 127 | ref (fun _ -> failwith "uninitialized add_iter") |
34e49164 C |
128 | |
129 | let add_pos_meta: | |
faf9a90c C |
130 | (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref = |
131 | ref (fun _ -> failwith "uninitialized add_meta") | |
34e49164 | 132 | |
faf9a90c C |
133 | let add_type_name: (string -> unit) ref = |
134 | ref (fun _ -> failwith "uninitialized add_type") | |
34e49164 | 135 | |
faf9a90c C |
136 | let add_declarer_name: (string -> unit) ref = |
137 | ref (fun _ -> failwith "uninitialized add_decl") | |
34e49164 | 138 | |
faf9a90c C |
139 | let add_iterator_name: (string -> unit) ref = |
140 | ref (fun _ -> failwith "uninitialized add_iter") | |
34e49164 C |
141 | |
142 | let init_rule: (unit -> unit) ref = | |
faf9a90c | 143 | ref (fun _ -> failwith "uninitialized install_bindings") |
34e49164 C |
144 | |
145 | let install_bindings: (string -> unit) ref = | |
faf9a90c | 146 | ref (fun _ -> failwith "uninitialized install_bindings") |