File: ast_traverse.mli

package info (click to toggle)
ppxlib 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,284 kB
  • sloc: ml: 17,184; sh: 149; makefile: 36; python: 36
file content (69 lines) | stat: -rw-r--r-- 1,739 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(** AST traversal classes *)

open! Import

(** To use these classes, inherit from them and override the methods corresponding to the
    types from [Parsetree] you want to process. For instance to collect all the string
    constants in a structure:

    {[
      let string_constants_of = object
        inherit [string list] Ast_traverse.fold as super

        method! expression e acc =
          let acc = super#expression e acc in
          match e.pexp_desc with
          | Pexp_constant (Const_string (s, _)) -> s :: acc
          | _ -> acc

        method! pattern p acc =
          let acc = super#pattern p acc in
          match p.ppat_desc with
          | Ppat_constant (Const_string (s, _)) -> s :: acc
          | _ -> acc
      end

      let string_constants_of_structure = string_constants_of#structure
    ]}
*)

class map : object
  inherit Ppxlib_traverse_builtins.map
  inherit Ast.map
end

class iter : object
  inherit Ppxlib_traverse_builtins.iter
  inherit Ast.iter
end

class ['acc] fold : object
  inherit ['acc] Ppxlib_traverse_builtins.fold
  inherit ['acc] Ast.fold
end

class ['acc] fold_map : object
  inherit ['acc] Ppxlib_traverse_builtins.fold_map
  inherit ['acc] Ast.fold_map
end

class ['ctx] map_with_context : object
  inherit ['ctx] Ppxlib_traverse_builtins.map_with_context
  inherit ['ctx] Ast.map_with_context
end

class map_with_path : [string] map_with_context

class map_with_expansion_context : [Expansion_context.Base.t] map_with_context

class virtual ['res] lift : object
  inherit ['res] Ppxlib_traverse_builtins.lift
  inherit ['res] Ast.lift
end

class sexp_of : object
  inherit [Sexp.t] Ppxlib_traverse_builtins.std_lifters
  inherit [Sexp.t] Ast.lift
end

val sexp_of : sexp_of