Release coccinelle-0.2.0rc1
[bpt/coccinelle.git] / parsing_cocci / data.ml
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
9 type incl_iso =
10 Include of string | Iso of (string,string) Common.either
11 | Virt of string list (* virtual rules *)
12
13 type clt =
14 line_type * int * int * int * int (* starting spaces *) *
15 (string * Ast0.position_info) list (* code before *) *
16 (string * Ast0.position_info) list (* code after *) *
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
25 | PLUS | PLUSPLUS
26 | CONTEXT | UNIQUE | OPT
27
28 type iconstraints = Ast.idconstraint
29 type econstraints = Ast0.constraints
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
35 let in_generating = ref false
36 let ignore_patch_or_match = ref false
37 let in_prolog = ref false
38 (* state machine for lexer..., allows smpl keywords as type names *)
39 let saw_struct = ref false
40 let inheritable_positions =
41 ref ([] : string list) (* rules from which posns can be inherited *)
42
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
49 let all_metadecls =
50 (Hashtbl.create(100) : (string, Ast.metavar list) Hashtbl.t)
51
52 let clear_meta: (unit -> unit) ref =
53 ref (fun _ -> failwith "uninitialized add_meta")
54
55 let add_id_meta:
56 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
57 ref (fun _ -> failwith "uninitialized add_meta")
58
59 let add_fresh_id_meta: (Ast.meta_name -> unit) ref =
60 ref (fun _ -> failwith "uninitialized add_meta")
61
62 let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
63 ref (fun _ -> failwith "uninitialized add_meta")
64
65 let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
66 ref (fun _ -> failwith "uninitialized add_meta")
67
68 let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
69 ref (fun _ -> failwith "uninitialized add_meta")
70
71 let add_paramlist_meta:
72 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
73 ref (fun _ -> failwith "uninitialized add_meta")
74
75 let add_const_meta:
76 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
77 Ast0.pure -> unit)
78 ref =
79 ref (fun _ -> failwith "uninitialized add_meta")
80
81 let add_err_meta:
82 (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref =
83 ref (fun _ -> failwith "uninitialized add_meta")
84
85 let add_exp_meta:
86 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
87 Ast0.pure -> unit)
88 ref =
89 ref (fun _ -> failwith "uninitialized add_meta")
90
91 let add_idexp_meta:
92 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
93 Ast0.pure -> unit)
94 ref =
95 ref (fun _ -> failwith "uninitialized add_meta")
96
97 let add_local_idexp_meta:
98 (Type_cocci.typeC list option -> Ast.meta_name -> econstraints ->
99 Ast0.pure -> unit)
100 ref =
101 ref (fun _ -> failwith "uninitialized add_meta")
102
103 let add_explist_meta:
104 (Ast.meta_name -> Ast.meta_name option -> Ast0.pure -> unit) ref =
105 ref (fun _ -> failwith "uninitialized add_meta")
106
107 let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
108 ref (fun _ -> failwith "uninitialized add_meta")
109
110 let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
111 ref (fun _ -> failwith "uninitialized add_meta")
112
113 let add_func_meta:
114 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
115 ref (fun _ -> failwith "uninitialized add_meta")
116
117 let add_local_func_meta:
118 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
119 ref (fun _ -> failwith "uninitialized add_meta")
120
121 let add_declarer_meta:
122 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
123 ref (fun _ -> failwith "uninitialized add_decl")
124
125 let add_iterator_meta:
126 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
127 ref (fun _ -> failwith "uninitialized add_iter")
128
129 let add_pos_meta:
130 (Ast.meta_name -> pconstraints -> Ast.meta_collect -> unit) ref =
131 ref (fun _ -> failwith "uninitialized add_meta")
132
133 let add_type_name: (string -> unit) ref =
134 ref (fun _ -> failwith "uninitialized add_type")
135
136 let add_declarer_name: (string -> unit) ref =
137 ref (fun _ -> failwith "uninitialized add_decl")
138
139 let add_iterator_name: (string -> unit) ref =
140 ref (fun _ -> failwith "uninitialized add_iter")
141
142 let init_rule: (unit -> unit) ref =
143 ref (fun _ -> failwith "uninitialized install_bindings")
144
145 let install_bindings: (string -> unit) ref =
146 ref (fun _ -> failwith "uninitialized install_bindings")