1Ast_iterator(3) OCaml library Ast_iterator(3)
2
3
4
6 Ast_iterator - Ast_iterator.iterator allows to implement AST inspection
7 using open recursion.
8
10 Module Ast_iterator
11
13 Module Ast_iterator
14 : sig end
15
16
17
18 Ast_iterator.iterator allows to implement AST inspection using open
19 recursion. A typical mapper would be based on Ast_itera‐
20 tor.default_iterator , a trivial iterator, and will fall back on it for
21 handling the syntax it does not modify.
22
23
24
25
26
27
28
29 === A generic Parsetree iterator ===
30
31
32 type iterator = {
33 attribute : iterator -> Parsetree.attribute -> unit ;
34 attributes : iterator -> Parsetree.attribute list -> unit ;
35 case : iterator -> Parsetree.case -> unit ;
36 cases : iterator -> Parsetree.case list -> unit ;
37 class_declaration : iterator -> Parsetree.class_declaration -> unit ;
38 class_description : iterator -> Parsetree.class_description -> unit ;
39 class_expr : iterator -> Parsetree.class_expr -> unit ;
40 class_field : iterator -> Parsetree.class_field -> unit ;
41 class_signature : iterator -> Parsetree.class_signature -> unit ;
42 class_structure : iterator -> Parsetree.class_structure -> unit ;
43 class_type : iterator -> Parsetree.class_type -> unit ;
44 class_type_declaration : iterator -> Parsetree.class_type_declaration
45 -> unit ;
46 class_type_field : iterator -> Parsetree.class_type_field -> unit ;
47 constructor_declaration : iterator -> Parsetree.constructor_declara‐
48 tion -> unit ;
49 expr : iterator -> Parsetree.expression -> unit ;
50 extension : iterator -> Parsetree.extension -> unit ;
51 extension_constructor : iterator -> Parsetree.extension_constructor ->
52 unit ;
53 include_declaration : iterator -> Parsetree.include_declaration ->
54 unit ;
55 include_description : iterator -> Parsetree.include_description ->
56 unit ;
57 label_declaration : iterator -> Parsetree.label_declaration -> unit ;
58 location : iterator -> Location.t -> unit ;
59 module_binding : iterator -> Parsetree.module_binding -> unit ;
60 module_declaration : iterator -> Parsetree.module_declaration -> unit
61 ;
62 module_expr : iterator -> Parsetree.module_expr -> unit ;
63 module_type : iterator -> Parsetree.module_type -> unit ;
64 module_type_declaration : iterator -> Parsetree.module_type_declara‐
65 tion -> unit ;
66 open_description : iterator -> Parsetree.open_description -> unit ;
67 pat : iterator -> Parsetree.pattern -> unit ;
68 payload : iterator -> Parsetree.payload -> unit ;
69 signature : iterator -> Parsetree.signature -> unit ;
70 signature_item : iterator -> Parsetree.signature_item -> unit ;
71 structure : iterator -> Parsetree.structure -> unit ;
72 structure_item : iterator -> Parsetree.structure_item -> unit ;
73 typ : iterator -> Parsetree.core_type -> unit ;
74 type_declaration : iterator -> Parsetree.type_declaration -> unit ;
75 type_extension : iterator -> Parsetree.type_extension -> unit ;
76 type_kind : iterator -> Parsetree.type_kind -> unit ;
77 value_binding : iterator -> Parsetree.value_binding -> unit ;
78 value_description : iterator -> Parsetree.value_description -> unit ;
79 with_constraint : iterator -> Parsetree.with_constraint -> unit ;
80 }
81
82
83 A iterator record implements one "method" per syntactic category, using
84 an open recursion style: each method takes as its first argument the
85 iterator to be applied to children in the syntax tree.
86
87
88
89 val default_iterator : iterator
90
91 A default iterator, which implements a "do not do anything" mapping.
92
93
94
95
96
97OCamldoc 2018-07-14 Ast_iterator(3)