jon.recoil.org

Module Ocaml_parsing.Ast_iterator

Ast_iterator.iterator enables AST inspection using open recursion. A typical mapper would be based on Ast_iterator.default_iterator, a trivial iterator, and will fall back on it for handling the syntax it does not modify.

Warning: this module is unstable and part of compiler-libs.

A generic Parsetree iterator

type iterator = {
  1. attribute : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.attribute -> unit;
  2. attributes : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.attribute list -> unit;
  3. modes : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.modes -> unit;
  4. modalities : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.modalities -> unit;
  5. binding_op : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.binding_op -> unit;
  6. case : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.case -> unit;
  7. cases : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.case list -> unit;
  8. class_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_declaration -> unit;
  9. class_description : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_description -> unit;
  10. class_expr : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_expr -> unit;
  11. class_field : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_field -> unit;
  12. class_signature : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_signature -> unit;
  13. class_structure : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_structure -> unit;
  14. class_type : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_type -> unit;
  15. class_type_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_type_declaration -> unit;
  16. class_type_field : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.class_type_field -> unit;
  17. constructor_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.constructor_declaration -> unit;
  18. directive_argument : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.directive_argument -> unit;
  19. expr : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.expression -> unit;
  20. extension : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.extension -> unit;
  21. extension_constructor : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.extension_constructor -> unit;
  22. include_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.include_declaration -> unit;
  23. include_description : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.include_description -> unit;
  24. jkind_annotation : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.jkind_annotation -> unit;
  25. label_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.label_declaration -> unit;
  26. location : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Location.t -> unit;
  27. module_binding : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_binding -> unit;
  28. module_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_declaration -> unit;
  29. module_substitution : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_substitution -> unit;
  30. module_expr : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_expr -> unit;
  31. module_type : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_type -> unit;
  32. module_type_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.module_type_declaration -> unit;
  33. open_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.open_declaration -> unit;
  34. open_description : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.open_description -> unit;
  35. pat : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.pattern -> unit;
  36. payload : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.payload -> unit;
  37. signature : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.signature -> unit;
  38. signature_item : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.signature_item -> unit;
  39. structure : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.structure -> unit;
  40. structure_item : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.structure_item -> unit;
  41. toplevel_directive : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.toplevel_directive -> unit;
  42. toplevel_phrase : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.toplevel_phrase -> unit;
  43. typ : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.core_type -> unit;
  44. row_field : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.row_field -> unit;
  45. object_field : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.object_field -> unit;
  46. type_declaration : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.type_declaration -> unit;
  47. type_extension : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.type_extension -> unit;
  48. type_exception : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.type_exception -> unit;
  49. type_kind : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.type_kind -> unit;
  50. value_binding : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.value_binding -> unit;
  51. value_description : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.value_description -> unit;
  52. with_constraint : Ocaml_parsing.Ast_iterator.iterator -> Ocaml_parsing.Parsetree.with_constraint -> unit;
}

A iterator 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.

A default iterator, which implements a "do not do anything" mapping.