.TH "Ast_iterator" 3 2024-05-31 OCamldoc "OCaml library" .SH NAME Ast_iterator \- Ast_iterator.iterator enables AST inspection using open recursion. .SH Module Module Ast_iterator .SH Documentation .sp Module .BI "Ast_iterator" : .B sig end .sp .ft B Ast_iterator\&.iterator .ft R enables AST inspection using open recursion\&. A typical mapper would be based on .ft B Ast_iterator\&.default_iterator .ft R , a trivial iterator, and will fall back on it for handling the syntax it does not modify\&. .sp Warning: this module is unstable and part of .ft B Compiler_libs .ft R \&. .sp .sp .sp .PP .SS A generic Parsetree iterator .PP .I type iterator = { attribute : .B iterator -> Parsetree.attribute -> unit ; attributes : .B iterator -> Parsetree.attribute list -> unit ; binding_op : .B iterator -> Parsetree.binding_op -> unit ; case : .B iterator -> Parsetree.case -> unit ; cases : .B iterator -> Parsetree.case list -> unit ; class_declaration : .B iterator -> Parsetree.class_declaration -> unit ; class_description : .B iterator -> Parsetree.class_description -> unit ; class_expr : .B iterator -> Parsetree.class_expr -> unit ; class_field : .B iterator -> Parsetree.class_field -> unit ; class_signature : .B iterator -> Parsetree.class_signature -> unit ; class_structure : .B iterator -> Parsetree.class_structure -> unit ; class_type : .B iterator -> Parsetree.class_type -> unit ; class_type_declaration : .B iterator -> Parsetree.class_type_declaration -> unit ; class_type_field : .B iterator -> Parsetree.class_type_field -> unit ; constructor_declaration : .B iterator -> Parsetree.constructor_declaration -> unit ; directive_argument : .B iterator -> Parsetree.directive_argument -> unit ; expr : .B iterator -> Parsetree.expression -> unit ; extension : .B iterator -> Parsetree.extension -> unit ; extension_constructor : .B iterator -> Parsetree.extension_constructor -> unit ; include_declaration : .B iterator -> Parsetree.include_declaration -> unit ; include_description : .B iterator -> Parsetree.include_description -> unit ; label_declaration : .B iterator -> Parsetree.label_declaration -> unit ; location : .B iterator -> Location.t -> unit ; module_binding : .B iterator -> Parsetree.module_binding -> unit ; module_declaration : .B iterator -> Parsetree.module_declaration -> unit ; module_substitution : .B iterator -> Parsetree.module_substitution -> unit ; module_expr : .B iterator -> Parsetree.module_expr -> unit ; module_type : .B iterator -> Parsetree.module_type -> unit ; module_type_declaration : .B iterator -> Parsetree.module_type_declaration -> unit ; open_declaration : .B iterator -> Parsetree.open_declaration -> unit ; open_description : .B iterator -> Parsetree.open_description -> unit ; pat : .B iterator -> Parsetree.pattern -> unit ; payload : .B iterator -> Parsetree.payload -> unit ; signature : .B iterator -> Parsetree.signature -> unit ; signature_item : .B iterator -> Parsetree.signature_item -> unit ; structure : .B iterator -> Parsetree.structure -> unit ; structure_item : .B iterator -> Parsetree.structure_item -> unit ; toplevel_directive : .B iterator -> Parsetree.toplevel_directive -> unit ; toplevel_phrase : .B iterator -> Parsetree.toplevel_phrase -> unit ; typ : .B iterator -> Parsetree.core_type -> unit ; row_field : .B iterator -> Parsetree.row_field -> unit ; object_field : .B iterator -> Parsetree.object_field -> unit ; type_declaration : .B iterator -> Parsetree.type_declaration -> unit ; type_extension : .B iterator -> Parsetree.type_extension -> unit ; type_exception : .B iterator -> Parsetree.type_exception -> unit ; type_kind : .B iterator -> Parsetree.type_kind -> unit ; value_binding : .B iterator -> Parsetree.value_binding -> unit ; value_description : .B iterator -> Parsetree.value_description -> unit ; with_constraint : .B iterator -> Parsetree.with_constraint -> unit ; } .sp A .ft B iterator .ft R record implements one "method" per syntactic category, using an open recursion style: each method takes as its first argument the iterator to be applied to children in the syntax tree\&. .sp .I val default_iterator : .B iterator .sp A default iterator, which implements a "do not do anything" mapping\&. .sp