| 1 | open Base |
| 2 | open Ppxlib |
| 3 | open Ast_builder.Default |
| 4 | module Attrs = Attrs |
| 5 | module Record_field_attrs = Record_field_attrs |
| 6 | open Expand_sexp_of |
| 7 | open Expand_of_sexp |
| 8 | |
| 9 | module Sexp_of = struct |
| 10 | let type_extension ty = |
| 11 | Sig_generate_sexp_of.type_of_sexp_of ~loc:{ ty.ptyp_loc with loc_ghost = true } ty |
| 12 | ;; |
| 13 | |
| 14 | let core_type ty = Str_generate_sexp_of.sexp_of_core_type ty |
| 15 | let sig_type_decl = Sig_generate_sexp_of.mk_sig |
| 16 | let sig_exception = Sig_generate_sexp_of.mk_sig_exn |
| 17 | let str_type_decl = Str_generate_sexp_of.sexp_of_tds |
| 18 | let str_exception = Str_generate_sexp_of.sexp_of_exn |
| 19 | end |
| 20 | |
| 21 | module Sexp_grammar = Ppx_sexp_conv_grammar |
| 22 | |
| 23 | module Of_sexp = struct |
| 24 | let type_extension ty = Sig_generate_of_sexp.type_of_of_sexp ~loc:ty.ptyp_loc ty |
| 25 | let core_type = Str_generate_of_sexp.core_type_of_sexp |
| 26 | |
| 27 | let sig_type_decl ~poly ~loc ~path tds = |
| 28 | Sig_generate_of_sexp.mk_sig ~poly ~loc ~path tds |
| 29 | ;; |
| 30 | |
| 31 | let str_type_decl ~loc ~poly ~path tds = |
| 32 | Str_generate_of_sexp.tds_of_sexp ~loc ~poly ~path tds |
| 33 | ;; |
| 34 | end |
| 35 | |
| 36 | module Sig_sexp = struct |
| 37 | let mk_sig ~loc ~path decls = |
| 38 | List.concat |
| 39 | [ Sig_generate_sexp_of.mk_sig ~loc ~path decls |
| 40 | ; Sig_generate_of_sexp.mk_sig ~poly:false ~loc ~path decls |
| 41 | ] |
| 42 | ;; |
| 43 | |
| 44 | let sig_type_decl ~loc ~path ((_rf, tds) as decls) = |
| 45 | match |
| 46 | mk_named_sig |
| 47 | ~loc |
| 48 | ~sg_name:"Sexplib0.Sexpable.S" |
| 49 | ~handle_polymorphic_variant:false |
| 50 | tds |
| 51 | with |
| 52 | | Some include_infos -> [ psig_include ~loc include_infos ] |
| 53 | | None -> mk_sig ~loc ~path decls |
| 54 | ;; |
| 55 | end |