Release coccinelle-0.2.4rc2
[bpt/coccinelle.git] / parsing_cocci / data.ml
CommitLineData
34e49164
C
1module Ast0 = Ast0_cocci
2module 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 *)
7type fresh = bool
8
951c7801
C
9type incl_iso =
10 Include of string | Iso of (string,string) Common.either
11 | Virt of string list (* virtual rules *)
978fd7e5 12
34e49164
C
13type 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
23and line_type =
24 MINUS | OPTMINUS | UNIQUEMINUS
951c7801 25 | PLUS | PLUSPLUS
34e49164
C
26 | CONTEXT | UNIQUE | OPT
27
951c7801
C
28type iconstraints = Ast.idconstraint
29type econstraints = Ast0.constraints
34e49164
C
30type pconstraints = Ast.meta_name list
31
32let in_rule_name = ref false
33let in_meta = ref false
34let in_iso = ref false
faf9a90c 35let in_generating = ref false
7f004419 36let ignore_patch_or_match = ref false
34e49164 37let in_prolog = ref false
978fd7e5
C
38(* state machine for lexer..., allows smpl keywords as type names *)
39let saw_struct = ref false
34e49164
C
40let inheritable_positions =
41 ref ([] : string list) (* rules from which posns can be inherited *)
42
978fd7e5
C
43let 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
49let all_metadecls =
50 (Hashtbl.create(100) : (string, Ast.metavar list) Hashtbl.t)
51
faf9a90c
C
52let clear_meta: (unit -> unit) ref =
53 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
54
55let 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
59let add_virt_id_meta_found: (string -> string -> unit) ref =
60 ref (fun _ -> failwith "uninitialized add_meta")
61
62let 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
66let add_fresh_id_meta: (Ast.meta_name -> unit) ref =
67 ref (fun _ -> failwith "uninitialized add_meta")
68
faf9a90c
C
69let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
70 ref (fun _ -> failwith "uninitialized add_meta")
34e49164 71
113803cf
C
72let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
73 ref (fun _ -> failwith "uninitialized add_meta")
74
faf9a90c
C
75let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
76 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
77
78let 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
82let 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
88let add_err_meta:
89 (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref =
faf9a90c 90 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
91
92let 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
98let 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
104let 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
110let 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
114let add_decl_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
115 ref (fun _ -> failwith "uninitialized add_meta")
116
117let add_field_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
118 ref (fun _ -> failwith "uninitialized add_meta")
119
faf9a90c
C
120let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
121 ref (fun _ -> failwith "uninitialized add_meta")
34e49164 122
faf9a90c
C
123let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
124 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
125
126let add_func_meta:
faf9a90c
C
127 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
128 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
129
130let 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
134let add_declarer_meta:
135 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
faf9a90c 136 ref (fun _ -> failwith "uninitialized add_decl")
34e49164
C
137
138let add_iterator_meta:
139 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
faf9a90c 140 ref (fun _ -> failwith "uninitialized add_iter")
34e49164
C
141
142let 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
146let add_type_name: (string -> unit) ref =
147 ref (fun _ -> failwith "uninitialized add_type")
34e49164 148
faf9a90c
C
149let add_declarer_name: (string -> unit) ref =
150 ref (fun _ -> failwith "uninitialized add_decl")
34e49164 151
faf9a90c
C
152let add_iterator_name: (string -> unit) ref =
153 ref (fun _ -> failwith "uninitialized add_iter")
34e49164
C
154
155let init_rule: (unit -> unit) ref =
faf9a90c 156 ref (fun _ -> failwith "uninitialized install_bindings")
34e49164
C
157
158let install_bindings: (string -> unit) ref =
faf9a90c 159 ref (fun _ -> failwith "uninitialized install_bindings")