Release coccinelle-0.2.0rc1
[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 *) *
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
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
b1b2de81
C
59let add_fresh_id_meta: (Ast.meta_name -> unit) ref =
60 ref (fun _ -> failwith "uninitialized add_meta")
61
faf9a90c
C
62let add_type_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
63 ref (fun _ -> failwith "uninitialized add_meta")
34e49164 64
113803cf
C
65let add_init_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
66 ref (fun _ -> failwith "uninitialized add_meta")
67
faf9a90c
C
68let add_param_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
69 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
70
71let 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
75let 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
81let add_err_meta:
82 (Ast.meta_name -> econstraints -> Ast0.pure -> unit) ref =
faf9a90c 83 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
84
85let 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
91let 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
97let 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
103let 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
107let add_stm_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
108 ref (fun _ -> failwith "uninitialized add_meta")
34e49164 109
faf9a90c
C
110let add_stmlist_meta: (Ast.meta_name -> Ast0.pure -> unit) ref =
111 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
112
113let add_func_meta:
faf9a90c
C
114 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
115 ref (fun _ -> failwith "uninitialized add_meta")
34e49164
C
116
117let 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
121let add_declarer_meta:
122 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
faf9a90c 123 ref (fun _ -> failwith "uninitialized add_decl")
34e49164
C
124
125let add_iterator_meta:
126 (Ast.meta_name -> iconstraints -> Ast0.pure -> unit) ref =
faf9a90c 127 ref (fun _ -> failwith "uninitialized add_iter")
34e49164
C
128
129let 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
133let add_type_name: (string -> unit) ref =
134 ref (fun _ -> failwith "uninitialized add_type")
34e49164 135
faf9a90c
C
136let add_declarer_name: (string -> unit) ref =
137 ref (fun _ -> failwith "uninitialized add_decl")
34e49164 138
faf9a90c
C
139let add_iterator_name: (string -> unit) ref =
140 ref (fun _ -> failwith "uninitialized add_iter")
34e49164
C
141
142let init_rule: (unit -> unit) ref =
faf9a90c 143 ref (fun _ -> failwith "uninitialized install_bindings")
34e49164
C
144
145let install_bindings: (string -> unit) ref =
faf9a90c 146 ref (fun _ -> failwith "uninitialized install_bindings")