package melange

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file melange_ppxlib_ast.ml

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
(* Copyright (C) 2023 Antonio Nuno Monteiro
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * In addition to the permissions granted to you by the LGPL, you may combine
 * or link a "work that uses the Library" with a publicly distributed version
 * of this file to produce a combined library or application, then distribute
 * that combined work under the terms of your choosing, with no requirement
 * to comply with the obligations normally placed on you by section 4 of the
 * LGPL version 3 (or the corresponding section of a later version of the LGPL
 * should you choose to use a later version).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

module Convert = Ppxlib_ast.Select_ast (Ppxlib_ast__.Versions.OCaml_414)

module Of_ppxlib = struct
  include Convert.To_ocaml

  let copy_structure ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.structure =
      copy_structure ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.structure)

  let copy_signature ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.signature =
      copy_signature ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.signature)

  let copy_toplevel_phrase ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.toplevel_phrase
        =
      copy_toplevel_phrase ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.toplevel_phrase)

  let copy_core_type ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.core_type =
      copy_core_type ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.core_type)

  let copy_expression ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.expression =
      copy_expression ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.expression)

  let copy_pattern ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.pattern =
      copy_pattern ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.pattern)

  let copy_case ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.case =
      copy_case ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.case)

  let copy_type_declaration ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.type_declaration
        =
      copy_type_declaration ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.type_declaration)

  let copy_type_extension ast =
    let ast_414 : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.type_extension =
      copy_type_extension ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.type_extension)

  let copy_extension_constructor ast =
    let ast_414 :
        Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.extension_constructor =
      copy_extension_constructor ast
    in
    (Obj.magic ast_414 : Melange_compiler_libs.Parsetree.extension_constructor)

  let copy_payload (payload : Ppxlib.Parsetree.payload) :
      Melange_compiler_libs.Parsetree.payload =
    match payload with
    | PStr structure -> PStr (copy_structure structure)
    | PSig signature -> PSig (copy_signature signature)
    | PTyp core_type -> PTyp (copy_core_type core_type)
    | PPat (pattern, expression) ->
        PPat (copy_pattern pattern, Option.map copy_expression expression)
end

module To_ppxlib = struct
  include Convert.Of_ocaml

  let copy_structure (ast : Melange_compiler_libs.Parsetree.structure) =
    let ast_414 =
      copy_structure
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.structure)
    in
    (ast_414 : Ppxlib.structure)

  let copy_signature (ast : Melange_compiler_libs.Parsetree.signature) =
    let ast_414 =
      copy_signature
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.signature)
    in
    ast_414

  let copy_toplevel_phrase
      (ast : Melange_compiler_libs.Parsetree.toplevel_phrase) =
    let ast_414 =
      copy_toplevel_phrase
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.toplevel_phrase)
    in
    ast_414

  let copy_core_type (ast : Melange_compiler_libs.Parsetree.core_type) =
    let ast_414 =
      copy_core_type
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.core_type)
    in
    ast_414

  let copy_expression (ast : Melange_compiler_libs.Parsetree.expression) =
    let ast_414 =
      copy_expression
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.expression)
    in
    ast_414

  let copy_pattern (ast : Melange_compiler_libs.Parsetree.pattern) =
    let ast_414 =
      copy_pattern
        (Obj.magic ast : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.pattern)
    in
    ast_414

  let copy_case (ast : Melange_compiler_libs.Parsetree.case) =
    let ast_414 =
      copy_case
        (Obj.magic ast : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.case)
    in
    ast_414

  let copy_type_declaration
      (ast : Melange_compiler_libs.Parsetree.type_declaration) =
    let ast_414 =
      copy_type_declaration
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.type_declaration)
    in
    ast_414

  let copy_type_extension (ast : Melange_compiler_libs.Parsetree.type_extension)
      =
    let ast_414 =
      copy_type_extension
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.type_extension)
    in
    ast_414

  let copy_extension_constructor
      (ast : Melange_compiler_libs.Parsetree.extension_constructor) =
    let ast_414 =
      copy_extension_constructor
        (Obj.magic ast
          : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.extension_constructor)
    in
    ast_414

  let copy_payload (payload : Melange_compiler_libs.Parsetree.payload) :
      Ppxlib.Parsetree.payload =
    match payload with
    | PStr structure -> PStr (copy_structure structure)
    | PSig signature -> PSig (copy_signature signature)
    | PTyp core_type -> PTyp (copy_core_type core_type)
    | PPat (pattern, expression) ->
        PPat (copy_pattern pattern, Option.map copy_expression expression)
end
OCaml

Innovation. Community. Security.