Alternate if syntax support
[hiphop-php.git] / hphp / hack / src / parser / ast_visitor.ml
blob8f611b6de9822434c4cbab7d30e1e113884ccbc8
1 (**
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
9 *)
11 (*****************************************************************************)
12 (* This module defines a visitor class on the Ast data structure.
13 * To use it you must inherit the generic object and redefine the appropriate
14 * methods.
16 (*****************************************************************************)
18 open Ast
20 (*****************************************************************************)
21 (* The signature of the visitor. *)
22 (*****************************************************************************)
24 class type ['a] ast_visitor_type = object
25 method on_afield: 'a -> afield -> 'a
26 method on_array : 'a -> afield list -> 'a
27 method on_array_get : 'a -> expr -> expr option -> 'a
28 method on_as_expr : 'a -> as_expr -> 'a
29 method on_await : 'a -> expr -> 'a
30 method on_binop : 'a -> bop -> expr -> expr -> 'a
31 method on_pipe : 'a -> expr -> expr -> 'a
32 method on_block : 'a -> block -> 'a
33 method on_break : 'a -> expr option -> 'a
34 method on_call : 'a -> expr -> hint list -> expr list -> expr list -> 'a
35 method on_callconv : 'a -> param_kind -> expr -> 'a
36 method on_case : 'a -> case -> 'a
37 method on_cast : 'a -> hint -> expr -> 'a
38 method on_catch : 'a -> catch -> 'a
39 method on_markup: 'a -> pstring -> expr option -> 'a
40 method on_class_const : 'a -> expr -> pstring -> 'a
41 method on_class_get : 'a -> expr -> expr -> 'a
42 method on_clone : 'a -> expr -> 'a
43 method on_collection: 'a -> id -> afield list -> 'a
44 method on_continue : 'a -> expr option -> 'a
45 method on_darray : 'a -> (expr * expr) list -> 'a
46 method on_def_inline : 'a -> def -> 'a
47 method on_do : 'a -> block -> expr -> 'a
48 method on_dollar : 'a -> expr -> 'a
49 method on_efun : 'a -> fun_ -> (id * bool) list -> 'a
50 method on_eif : 'a -> expr -> expr option -> expr -> 'a
51 method on_nullCoalesce : 'a -> expr -> expr -> 'a
52 method on_expr : 'a -> expr -> 'a
53 method on_omitted: 'a -> 'a
54 method on_execution_operator : 'a -> expr list -> 'a
55 method on_expr_ : 'a -> expr_ -> 'a
56 method on_expr_list : 'a -> expr list -> 'a
57 method on_fallthrough : 'a -> 'a
58 method on_false : 'a -> 'a
59 method on_field: 'a -> field -> 'a
60 method on_float : 'a -> pstring -> 'a
61 method on_for : 'a -> expr -> expr -> expr -> block -> 'a
62 method on_foreach : 'a -> expr -> Pos.t option -> as_expr -> block -> 'a
63 method on_goto_label : 'a -> pstring -> 'a
64 method on_goto : 'a -> pstring -> 'a
65 method on_hint: 'a -> hint -> 'a
66 method on_id : 'a -> id -> 'a
67 method on_id_type_arguments : 'a -> id -> hint list -> 'a
68 method on_if : 'a -> expr -> block -> block -> 'a
69 method on_import: 'a -> import_flavor -> expr -> 'a
70 method on_import_flavor: 'a -> import_flavor -> 'a
71 method on_include: 'a -> 'a
72 method on_includeOnce: 'a -> 'a
73 method on_instanceOf : 'a -> expr -> expr -> 'a
74 method on_int : 'a -> pstring -> 'a
75 method on_is : 'a -> expr -> hint -> 'a
76 method on_lfun: 'a -> fun_ -> 'a
77 method on_list : 'a -> expr list -> 'a
78 method on_lvar : 'a -> id -> 'a
79 method on_new : 'a -> expr -> expr list -> expr list -> 'a
80 method on_newanoncls : 'a -> expr list -> expr list -> class_ -> 'a
81 method on_noop : 'a -> 'a
82 method on_null : 'a -> 'a
83 method on_obj_get : 'a -> expr -> expr -> 'a
84 method on_param_kind : 'a -> param_kind -> 'a
85 method on_pstring : 'a -> pstring -> 'a
86 method on_require: 'a -> 'a
87 method on_requireOnce: 'a -> 'a
88 method on_return : 'a -> expr option -> 'a
89 method on_sfclass_const: 'a -> id -> pstring -> 'a
90 method on_sflit: 'a -> pstring -> 'a
91 method on_shape : 'a -> (shape_field_name * expr) list -> 'a
92 method on_shape_field_name: 'a -> shape_field_name -> 'a
93 method on_static_var : 'a -> expr list -> 'a
94 method on_global_var : 'a -> expr list -> 'a
95 method on_stmt : 'a -> stmt -> 'a
96 method on_stmt_ : 'a -> stmt_ -> 'a
97 method on_string2 : 'a -> expr list -> 'a
98 method on_string : 'a -> pstring -> 'a
99 method on_suspend: 'a -> expr -> 'a
100 method on_switch : 'a -> expr -> case list -> 'a
101 method on_throw : 'a -> expr -> 'a
102 method on_true : 'a -> 'a
103 method on_try : 'a -> block -> catch list -> block -> 'a
104 method on_unop : 'a -> uop -> expr -> 'a
105 method on_unsafe: 'a -> 'a
106 method on_using: 'a -> using_stmt -> 'a
107 method on_varray : 'a -> expr list -> 'a
108 method on_while : 'a -> expr -> block -> 'a
109 method on_declare : 'a -> bool -> expr -> block -> 'a
110 method on_xml : 'a -> id -> xhp_attribute list -> expr list -> 'a
111 method on_yield : 'a -> afield -> 'a
112 method on_yield_from : 'a -> expr -> 'a
113 method on_yield_break : 'a -> 'a
116 (* traversal for top-level parts of the AST *)
117 (* may not be exactly what you want for all implementations*)
118 method on_absConst: 'a -> hint option -> id -> 'a
119 method on_attributes: 'a -> class_attr list -> 'a
120 method on_class_: 'a -> class_ -> 'a
121 method on_class_elt: 'a -> class_elt -> 'a
122 method on_classTraitRequire: 'a -> trait_req_kind -> hint -> 'a
123 method on_classUse: 'a -> hint -> 'a
124 method on_classUseAlias: 'a ->
125 id option -> pstring ->
126 id option -> kind list -> 'a
127 method on_classUsePrecedence: 'a -> id -> pstring -> id list -> 'a
128 method on_classVars:
129 'a -> class_vars_ -> 'a
130 method on_const: 'a -> hint option -> (id * expr) list -> 'a
131 method on_constant: 'a -> gconst -> 'a
132 method on_def: 'a -> def -> 'a
133 method on_fun_: 'a -> fun_ -> 'a
134 method on_fun_param: 'a -> fun_param -> 'a
135 method on_gconst: 'a -> gconst -> 'a
136 method on_method_: 'a -> method_ -> 'a
137 method on_namespace: 'a -> id -> program -> 'a
138 method on_namespaceUse: 'a -> (Ast.ns_kind * id * id) list -> 'a
139 method on_program: 'a -> program -> 'a
140 method on_tparam: 'a -> tparam -> 'a
141 method on_typeConst: 'a -> typeconst -> 'a
142 method on_typedef: 'a -> typedef -> 'a
143 method on_user_attribute: 'a -> user_attribute -> 'a
144 method on_xhpAttr: 'a -> hint option -> class_var -> bool ->
145 ((Pos.t * bool * expr list) option) -> 'a
146 method on_xhpAttrUse: 'a -> hint -> 'a
147 method on_xhpCategory: 'a -> pstring list -> 'a
148 method on_xhp_child: 'a -> xhp_child -> 'a
152 (*****************************************************************************)
153 (* The generic visitor ('a is the type of the accumulator). *)
154 (*****************************************************************************)
156 class virtual ['a] ast_visitor: ['a] ast_visitor_type = object(this)
158 method on_break acc level_opt =
159 match level_opt with
160 | Some e -> this#on_expr acc e
161 | None -> acc
162 method on_continue acc _ = acc
163 method on_noop acc = acc
164 method on_fallthrough acc = acc
165 method on_unsafe acc = acc
166 method on_include acc = acc
167 method on_require acc = acc
168 method on_includeOnce acc = acc
169 method on_requireOnce acc = acc
171 method on_hint acc h =
172 match (snd h) with
173 | Hsoft h
174 | Hoption h ->
175 let acc = this#on_hint acc h in
177 | Hfun (_, hl, kl, _, h) ->
178 let acc = List.fold_left this#on_hint acc hl in
179 let acc = List.fold_left (fun acc k ->
180 match k with
181 | Some kind -> this#on_param_kind acc kind
182 | None -> acc
183 ) acc kl in
184 let acc = this#on_hint acc h in
186 | Htuple hl ->
187 let acc = List.fold_left this#on_hint acc hl in
189 | Happly (id, hl) ->
190 let acc = this#on_id acc id in
191 let acc = List.fold_left this#on_hint acc hl in
193 | Hshape shape_info ->
194 let {si_shape_field_list; _} = shape_info in
195 let acc = List.fold_left (fun acc sf ->
196 let acc = this#on_shape_field_name acc sf.sf_name in
197 let acc = this#on_hint acc sf.sf_hint in
199 ) acc si_shape_field_list in
201 | Haccess (id1, id2, idl) ->
202 let acc = this#on_id acc id1 in
203 let acc = this#on_id acc id2 in
204 let acc = List.fold_left this#on_id acc idl in
207 method on_throw acc e =
208 let acc = this#on_expr acc e in
211 method on_return acc eopt =
212 match eopt with
213 | None -> acc
214 | Some e -> this#on_expr acc e
216 method on_static_var acc el = List.fold_left this#on_expr acc el
218 method on_global_var acc el = List.fold_left this#on_expr acc el
220 method on_if acc e b1 b2 =
221 let acc = this#on_expr acc e in
222 let acc = this#on_block acc b1 in
223 let acc = this#on_block acc b2 in
226 method on_do acc b e =
227 let acc = this#on_block acc b in
228 let acc = this#on_expr acc e in
231 method on_while acc e b =
232 let acc = this#on_expr acc e in
233 let acc = this#on_block acc b in
236 method on_declare acc _ e b =
237 let acc = this#on_expr acc e in
238 let acc = this#on_block acc b in
241 method on_for acc e1 e2 e3 b =
242 let acc = this#on_expr acc e1 in
243 let acc = this#on_expr acc e2 in
244 let acc = this#on_expr acc e3 in
245 let acc = this#on_block acc b in
248 method on_using acc s =
249 let acc = this#on_expr acc s.us_expr in
250 let acc = this#on_block acc s.us_block in
253 method on_switch acc e cl =
254 let acc = this#on_expr acc e in
255 let acc = List.fold_left this#on_case acc cl in
258 method on_foreach acc e _ ae b =
259 let acc = this#on_expr acc e in
260 let acc = this#on_as_expr acc ae in
261 let acc = this#on_block acc b in
264 method on_try acc b cl fb =
265 let acc = this#on_block acc b in
266 let acc = List.fold_left this#on_catch acc cl in
267 let acc = this#on_block acc fb in
270 method on_block acc b =
271 List.fold_left this#on_stmt acc b
273 method on_case acc = function
274 | Default b ->
275 let acc = this#on_block acc b in
277 | Case (e, b) ->
278 let acc = this#on_expr acc e in
279 let acc = this#on_block acc b in
282 method on_as_expr acc = function
283 | As_v e ->
284 let acc = this#on_expr acc e in
286 | As_kv (e1, e2) ->
287 let acc = this#on_expr acc e1 in
288 let acc = this#on_expr acc e2 in
291 method on_catch acc (i1, i2, b) =
292 let acc = this#on_id acc i1 in
293 let acc = this#on_id acc i2 in
294 let acc = this#on_block acc b in
297 method on_markup acc pstr e =
298 let acc = this#on_pstring acc pstr in
299 match e with
300 | Some e -> this#on_expr acc e
301 | None -> acc
303 method on_stmt_ acc = function
304 | Unsafe -> this#on_unsafe acc
305 | Expr e -> this#on_expr acc e
306 | Break level_opt -> this#on_break acc level_opt
307 | Block b -> this#on_block acc b
308 | Continue level_opt -> this#on_continue acc level_opt
309 | Throw (e) -> this#on_throw acc e
310 | Return eopt -> this#on_return acc eopt
311 | GotoLabel label -> this#on_goto_label acc label
312 | Goto label -> this#on_goto acc label
313 | If (e, b1, b2) -> this#on_if acc e b1 b2
314 | Do (b, e) -> this#on_do acc b e
315 | While (e, b) -> this#on_while acc e b
316 | For (e1, e2, e3, b) -> this#on_for acc e1 e2 e3 b
317 | Switch (e, cl) -> this#on_switch acc e cl
318 | Foreach (e, popt, ae, b)-> this#on_foreach acc e popt ae b
319 | Try (b, cl, fb) -> this#on_try acc b cl fb
320 | Def_inline d ->
321 this#on_def_inline acc d
322 | Noop -> this#on_noop acc
323 | Fallthrough -> this#on_fallthrough acc
324 | Static_var el -> this#on_static_var acc el
325 | Global_var el -> this#on_global_var acc el
326 | Markup (s, e) -> this#on_markup acc s e
327 | Using s -> this#on_using acc s
328 | Declare (is_block, e, b) -> this#on_declare acc is_block e b
330 method on_def_inline acc d =
331 this#on_def acc d
333 method on_xhp_child acc e =
334 match e with
335 | ChildName id -> this#on_id acc id
336 | ChildList children -> List.fold_left this#on_xhp_child acc children
337 | ChildUnary (child, _) -> this#on_xhp_child acc child
338 | ChildBinary (c1, c2) ->
339 let acc = this#on_xhp_child acc c1 in
340 this#on_xhp_child acc c2
342 method on_expr acc (_, e) =
343 this#on_expr_ acc e
345 method on_stmt acc (_, s) =
346 this#on_stmt_ acc s
348 method on_omitted acc = acc
350 method on_expr_ acc e =
351 match e with
352 | Unsafeexpr e-> this#on_expr acc e
353 | Collection (i, afl) -> this#on_collection acc i afl
354 | Lfun f -> this#on_lfun acc f
355 | Import (ifv, e) -> this#on_import acc ifv e
356 | Array afl -> this#on_array acc afl
357 | Darray fl -> this#on_darray acc fl
358 | Varray el -> this#on_varray acc el
359 | Shape sh -> this#on_shape acc sh
360 | True -> this#on_true acc
361 | False -> this#on_false acc
362 | Int n -> this#on_int acc n
363 | Float n -> this#on_float acc n
364 | Null -> this#on_null acc
365 | String s -> this#on_string acc s
366 | Execution_operator s -> this#on_execution_operator acc s
367 | Id id -> this#on_id acc id
368 | Id_type_arguments (id, hl) -> this#on_id_type_arguments acc id hl
369 | Lvar id -> this#on_lvar acc id
370 | Yield_break -> this#on_yield_break acc
371 | Yield e -> this#on_yield acc e
372 | Yield_from e -> this#on_yield_from acc e
373 | Await e -> this#on_await acc e
374 | List el -> this#on_list acc el
375 | Clone e -> this#on_clone acc e
376 | Expr_list el -> this#on_expr_list acc el
377 | Obj_get (e1, e2, _) -> this#on_obj_get acc e1 e2
378 | Array_get (e1, e2) -> this#on_array_get acc e1 e2
379 | Class_get (e1, p) -> this#on_class_get acc e1 p
380 | Class_const (e1, pstr) -> this#on_class_const acc e1 pstr
381 | Call (e, hl, el, uel) -> this#on_call acc e hl el uel
382 | String2 el -> this#on_string2 acc el
383 | Cast (hint, e) -> this#on_cast acc hint e
384 | Unop (uop, e) -> this#on_unop acc uop e
385 | Binop (bop, e1, e2) -> this#on_binop acc bop e1 e2
386 | Pipe (e1, e2) -> this#on_pipe acc e1 e2
387 | Eif (e1, e2, e3) -> this#on_eif acc e1 e2 e3
388 | NullCoalesce (e1, e2) -> this#on_nullCoalesce acc e1 e2
389 | InstanceOf (e1, e2) -> this#on_instanceOf acc e1 e2
390 | Is (e, h) -> this#on_is acc e h
391 | BracedExpr e
392 | ParenthesizedExpr e -> this#on_expr acc e
393 | New (e, el, uel) -> this#on_new acc e el uel
394 | NewAnonClass (el, uel, cl) -> this#on_newanoncls acc el uel cl
395 | Efun (f, idl) -> this#on_efun acc f idl
396 | Xml (id, attrl, el) -> this#on_xml acc id attrl el
397 | Omitted -> this#on_omitted acc
398 | Suspend e -> this#on_suspend acc e
399 | Callconv (kind, e) -> this#on_callconv acc kind e
400 | Dollar e -> this#on_dollar acc e
402 method on_array acc afl =
403 List.fold_left this#on_afield acc afl
405 method on_darray acc fl =
406 let on_field acc (e1, e2) =
407 let acc = this#on_expr acc e1 in
408 this#on_expr acc e2 in
409 List.fold_left on_field acc fl
411 method on_varray acc el =
412 List.fold_left this#on_expr acc el
414 method on_shape acc sfnel =
415 List.fold_left begin fun acc (sfn, e) ->
416 let acc = this#on_shape_field_name acc sfn in
417 let acc = this#on_expr acc e in
419 end acc sfnel
421 method on_id acc _ = acc
422 method on_id_type_arguments acc _ hl =
423 let acc = List.fold_left this#on_hint acc hl in
426 method on_lvar acc _ = acc
428 method on_obj_get acc e1 e2 =
429 let acc = this#on_expr acc e1 in
430 let acc = this#on_expr acc e2 in
433 method on_array_get acc e e_opt =
434 let acc = this#on_expr acc e in
435 let acc =
436 match e_opt with
437 | None -> acc
438 | Some e -> this#on_expr acc e
442 method on_class_get acc e p =
443 let acc = this#on_expr acc e in
444 let acc = this#on_expr acc p in
447 method on_class_const acc e pstr =
448 let acc = this#on_expr acc e in
449 let acc = this#on_pstring acc pstr in
452 method on_call acc e hl el uel =
453 let acc = this#on_expr acc e in
454 let acc = List.fold_left this#on_hint acc hl in
455 let acc = List.fold_left this#on_expr acc el in
456 let acc = List.fold_left this#on_expr acc uel in
459 method on_true acc = acc
460 method on_false acc = acc
462 method on_int acc pstr =
463 let acc = this#on_pstring acc pstr in
466 method on_float acc pstr =
467 let acc = this#on_pstring acc pstr in
470 method on_null acc = acc
471 method on_string acc pstr =
472 let acc = this#on_pstring acc pstr in
475 method on_string2 acc el =
476 let acc = List.fold_left this#on_expr acc el in
479 method on_execution_operator acc el =
480 let acc = List.fold_left this#on_expr acc el in
483 method on_yield_break acc = acc
484 method on_yield acc e = this#on_afield acc e
485 method on_yield_from acc e = this#on_expr acc e
486 method on_await acc e = this#on_expr acc e
487 method on_suspend acc e = this#on_expr acc e
488 method on_list acc el = List.fold_left this#on_expr acc el
490 method on_dollar acc e = this#on_expr acc e
492 method on_expr_list acc el =
493 let acc = List.fold_left this#on_expr acc el in
496 method on_cast acc h e =
497 let acc = this#on_expr acc e in
498 let acc = this#on_hint acc h in
501 method on_unop acc _ e = this#on_expr acc e
503 method on_binop acc _ e1 e2 =
504 let acc = this#on_expr acc e1 in
505 let acc = this#on_expr acc e2 in
508 method on_pipe acc e1 e2 =
509 let acc = this#on_expr acc e1 in
510 let acc = this#on_expr acc e2 in
513 method on_eif acc e1 e2 e3 =
514 let acc = this#on_expr acc e1 in
515 let acc =
516 match e2 with
517 | None -> acc
518 | Some e -> this#on_expr acc e
520 let acc = this#on_expr acc e3 in
523 method on_nullCoalesce acc e1 e2 =
524 let acc = this#on_expr acc e1 in
525 let acc = this#on_expr acc e2 in
528 method on_instanceOf acc e1 e2 =
529 let acc = this#on_expr acc e1 in
530 let acc = this#on_expr acc e2 in
533 method on_is acc e h =
534 let acc = this#on_expr acc e in
535 let acc = this#on_hint acc h in
538 method on_new acc e el uel =
539 let acc = this#on_expr acc e in
540 let acc = List.fold_left this#on_expr acc el in
541 let acc = List.fold_left this#on_expr acc uel in
544 method on_newanoncls acc el uel cl =
545 let acc = List.fold_left this#on_expr acc el in
546 let acc = List.fold_left this#on_expr acc uel in
547 let acc = this#on_class_ acc cl in
550 method on_efun acc f _ = this#on_fun_ acc f
552 method on_xml acc pstr attrl el =
553 let acc = this#on_pstring acc pstr in
554 let acc = List.fold_left begin fun acc attr ->
555 match attr with
556 | Xhp_simple (_, e) -> this#on_expr acc e
557 | Xhp_spread e -> this#on_expr acc e
558 end acc attrl in
559 let acc = List.fold_left this#on_expr acc el in
562 method on_goto_label = this#on_pstring
564 method on_goto = this#on_pstring
566 method on_clone acc e = this#on_expr acc e
568 method on_field acc (e1, e2) =
569 let acc = this#on_expr acc e1 in
570 let acc = this#on_expr acc e2 in
573 method on_afield acc = function
574 | AFvalue e -> this#on_expr acc e
575 | AFkvalue (e1, e2) ->
576 let acc = this#on_expr acc e1 in
577 let acc = this#on_expr acc e2 in
580 method on_shape_field_name acc = function
581 | SFlit pstr -> this#on_sflit acc pstr
582 | SFclass_const (id, pstr) -> this#on_sfclass_const acc id pstr
584 method on_sflit acc pstr = this#on_pstring acc pstr
585 method on_sfclass_const acc (p, _ as id) c =
586 this#on_class_const acc (p, Id id) c
588 method on_collection acc i afl =
589 let acc = this#on_id acc i in
590 let acc = List.fold_left this#on_afield acc afl in
593 method on_import acc ifv e =
594 let acc = this#on_import_flavor acc ifv in
595 let acc = this#on_expr acc e in
598 method on_import_flavor acc = function
599 | Include -> this#on_include acc
600 | Require -> this#on_require acc
601 | IncludeOnce -> this#on_includeOnce acc
602 | RequireOnce -> this#on_requireOnce acc
604 method on_lfun acc l = this#on_fun_ acc l
606 method on_param_kind acc _ = acc
608 method on_callconv acc kind e =
609 let acc = this#on_param_kind acc kind in
610 let acc = this#on_expr acc e in
613 method on_fun_ acc f =
614 let acc = List.fold_left this#on_user_attribute acc f.f_user_attributes in
615 let acc = this#on_id acc f.f_name in
616 let acc = List.fold_left this#on_tparam acc f.f_tparams in
617 let acc = List.fold_left this#on_fun_param acc f.f_params in
618 let acc = this#on_block acc f.f_body in
619 let acc = match f.f_ret with
620 | Some h -> this#on_hint acc h
621 | None -> acc in
624 method on_program acc p =
625 let acc = List.fold_left begin fun acc d ->
626 this#on_def acc d end acc p in
629 method on_def acc = function
630 | Fun f -> this#on_fun_ acc f
631 | Class c -> this#on_class_ acc c
632 | Stmt s -> this#on_stmt acc s
633 | Typedef t -> this#on_typedef acc t
634 | Constant g -> this#on_constant acc g
635 | Namespace (i, p) -> this#on_namespace acc i p
636 | NamespaceUse idl -> this#on_namespaceUse acc idl
637 | SetNamespaceEnv e -> acc
639 method on_class_ acc c =
640 let acc = List.fold_left this#on_user_attribute acc c.c_user_attributes in
641 let acc = this#on_id acc c.c_name in
642 let acc = List.fold_left this#on_tparam acc c.c_tparams in
643 let acc = List.fold_left this#on_hint acc c.c_extends in
644 let acc = List.fold_left this#on_hint acc c.c_implements in
645 let acc = List.fold_left this#on_class_elt acc c.c_body in
648 method on_typedef acc t =
649 let acc = this#on_id acc t.t_id in
650 let acc = match t.t_kind with
651 | Alias h | NewType h -> this#on_hint acc h in
652 let acc = List.fold_left this#on_tparam acc t.t_tparams in
653 let acc = List.fold_left this#on_user_attribute acc t.t_user_attributes in
656 method on_constant acc g =
657 this#on_gconst acc g
659 method on_namespace acc i p =
660 let acc = this#on_id acc i in
661 let acc = this#on_program acc p in
664 method on_namespaceUse acc il =
665 List.fold_left begin fun acc (_, i1, i2) ->
666 let acc = this#on_id acc i1 in
667 let acc = this#on_id acc i2 in
668 acc end acc il
670 method on_tparam acc t =
671 let (_, i, c_h_list) = t in
672 let acc = this#on_id acc i in
673 let on_tparam_constraint acc (_, h) = this#on_hint acc h in
674 let acc = List.fold_left on_tparam_constraint acc c_h_list in
677 method on_fun_param acc f =
678 let acc = this#on_id acc f.param_id in
679 let acc = match f.param_expr with
680 | None -> acc
681 | Some expr -> this#on_expr acc expr in
682 let acc = match f.param_hint with
683 | Some h -> this#on_hint acc h
684 | None -> acc in
685 let acc = match f.param_callconv with
686 | Some kind -> this#on_param_kind acc kind
687 | None -> acc in
690 method on_user_attribute acc u =
691 let acc = this#on_id acc u.ua_name in
692 let acc = List.fold_left this#on_expr acc u.ua_params in
695 method on_gconst acc g =
696 let acc = this#on_id acc g.cst_name in
697 let acc = this#on_expr acc g.cst_value in
698 let acc = match g.cst_type with
699 | Some h -> this#on_hint acc h
700 | None -> acc in
703 method on_class_elt acc = function
704 | Const (hopt, iel) -> this#on_const acc hopt iel
705 | AbsConst (h, a) -> this#on_absConst acc h a
706 | Attributes cl -> this#on_attributes acc cl
707 | TypeConst t -> this#on_typeConst acc t
708 | ClassUse h -> this#on_classUse acc h
709 | ClassUseAlias (ido1, ps, ido2, ko) ->
710 this#on_classUseAlias acc ido1 ps ido2 ko
711 | ClassUsePrecedence (id, ps, ids) ->
712 this#on_classUsePrecedence acc id ps ids
713 | XhpAttrUse h -> this#on_xhpAttrUse acc h
714 | XhpCategory cs -> this#on_xhpCategory acc cs
715 | XhpChild c -> this#on_xhp_child acc c
716 | ClassTraitRequire (t, h) -> this#on_classTraitRequire acc t h
717 | ClassVars cv -> this#on_classVars acc cv
718 | XhpAttr (t,h,i,n) -> this#on_xhpAttr acc t h i n
719 | Method m -> this#on_method_ acc m
721 method on_const acc h_opt consts =
722 let acc = match h_opt with
723 | Some h -> this#on_hint acc h
724 | None -> acc in
725 let acc = List.fold_left (fun acc (id, expr) ->
726 let acc = this#on_id acc id in
727 let acc = this#on_expr acc expr in
729 ) acc consts in
731 method on_absConst acc h_opt id =
732 let acc = match h_opt with
733 | Some h -> this#on_hint acc h
734 | None -> acc in
735 let acc = this#on_id acc id in
737 method on_attributes acc _ = acc
738 method on_typeConst acc t =
739 let acc = this#on_id acc t.tconst_name in
740 let acc = match t.tconst_constraint with
741 | Some h -> this#on_hint acc h
742 | None -> acc in
743 let acc = match t.tconst_type with
744 | Some h -> this#on_hint acc h
745 | None -> acc in
747 method on_classUse acc h =
748 let acc = this#on_hint acc h in
750 method on_classUseAlias acc ido1 ps ido2 _ =
751 let acc = match ido1 with
752 | Some id -> this#on_id acc id
753 | None -> acc in
754 let acc = this#on_pstring acc ps in
755 let acc = match ido2 with
756 | Some id -> this#on_id acc id
757 | None -> acc in
759 method on_classUsePrecedence acc id ps ids =
760 let acc = this#on_id acc id in
761 let acc = this#on_pstring acc ps in
762 let acc = List.fold_left this#on_id acc ids in
764 method on_xhpAttrUse acc h =
765 let acc = this#on_hint acc h in
767 method on_classTraitRequire acc _ h =
768 let acc = this#on_hint acc h in
770 method on_classVars acc cv =
771 let acc = match cv.cv_hint with
772 | Some h -> this#on_hint acc h
773 | None -> acc in
774 let acc = List.fold_left (fun acc (_, id, opt_expr) ->
775 let acc = this#on_id acc id in
776 match opt_expr with
777 | Some expr -> this#on_expr acc expr
778 | None -> acc
779 ) acc cv.cv_names in
781 method on_xhpAttr acc h_opt _ _ _ =
782 let acc = match h_opt with
783 | Some h -> this#on_hint acc h
784 | None -> acc in
786 method on_xhpCategory acc cs =
787 let acc = List.fold_left this#on_pstring acc cs in
790 method on_method_ acc m =
791 let acc = this#on_id acc m.m_name in
792 let acc = List.fold_left this#on_tparam acc m.m_tparams in
793 let acc = List.fold_left this#on_fun_param acc m.m_params in
794 let acc = List.fold_left this#on_user_attribute acc m.m_user_attributes in
795 let acc = match m.m_ret with
796 | Some h -> this#on_hint acc h
797 | None -> acc in
798 let acc = this#on_block acc m.m_body in
801 method on_pstring acc _ = acc