summaryrefslogtreecommitdiff
path: root/parsing
diff options
context:
space:
mode:
authoroctachron <octa@polychoron.fr>2021-01-13 10:24:40 +0100
committeroctachron <octa@polychoron.fr>2021-02-17 16:46:32 +0100
commit4b3fb5d6f29cc14434fa0a58c59cd38adc27ac1b (patch)
tree8002572c90bc2860acb021b08e8cbecf74e0b7e2 /parsing
parent2c3bf12ec373702263c66166e2a983e9f7b17262 (diff)
downloadocaml-4b3fb5d6f29cc14434fa0a58c59cd38adc27ac1b.tar.gz
module type S := ...: core
Diffstat (limited to 'parsing')
-rw-r--r--parsing/ast_helper.ml1
-rw-r--r--parsing/ast_helper.mli1
-rw-r--r--parsing/ast_iterator.ml2
-rw-r--r--parsing/ast_mapper.ml2
-rw-r--r--parsing/depend.ml2
-rw-r--r--parsing/parsetree.mli2
-rw-r--r--parsing/pprintast.ml12
-rw-r--r--parsing/printast.ml4
8 files changed, 20 insertions, 6 deletions
diff --git a/parsing/ast_helper.ml b/parsing/ast_helper.ml
index 2d51dda743..41f5fb9b8d 100644
--- a/parsing/ast_helper.ml
+++ b/parsing/ast_helper.ml
@@ -271,6 +271,7 @@ module Sig = struct
let mod_subst ?loc a = mk ?loc (Psig_modsubst a)
let rec_module ?loc a = mk ?loc (Psig_recmodule a)
let modtype ?loc a = mk ?loc (Psig_modtype a)
+ let modtype_subst ?loc a = mk ?loc (Psig_modtypesubst a)
let open_ ?loc a = mk ?loc (Psig_open a)
let include_ ?loc a = mk ?loc (Psig_include a)
let class_ ?loc a = mk ?loc (Psig_class a)
diff --git a/parsing/ast_helper.mli b/parsing/ast_helper.mli
index a498ece07d..42ce9e2e98 100644
--- a/parsing/ast_helper.mli
+++ b/parsing/ast_helper.mli
@@ -288,6 +288,7 @@ module Sig:
val mod_subst: ?loc:loc -> module_substitution -> signature_item
val rec_module: ?loc:loc -> module_declaration list -> signature_item
val modtype: ?loc:loc -> module_type_declaration -> signature_item
+ val modtype_subst: ?loc:loc -> module_type_declaration -> signature_item
val open_: ?loc:loc -> open_description -> signature_item
val include_: ?loc:loc -> include_description -> signature_item
val class_: ?loc:loc -> class_description list -> signature_item
diff --git a/parsing/ast_iterator.ml b/parsing/ast_iterator.ml
index 1cdb95310a..d1efda9782 100644
--- a/parsing/ast_iterator.ml
+++ b/parsing/ast_iterator.ml
@@ -285,7 +285,7 @@ module MT = struct
| Psig_modsubst x -> sub.module_substitution sub x
| Psig_recmodule l ->
List.iter (sub.module_declaration sub) l
- | Psig_modtype x -> sub.module_type_declaration sub x
+ | Psig_modtype x | Psig_modtypesubst x -> sub.module_type_declaration sub x
| Psig_open x -> sub.open_description sub x
| Psig_include x -> sub.include_description sub x
| Psig_class l -> List.iter (sub.class_description sub) l
diff --git a/parsing/ast_mapper.ml b/parsing/ast_mapper.ml
index 720c16af34..7575f47b0b 100644
--- a/parsing/ast_mapper.ml
+++ b/parsing/ast_mapper.ml
@@ -318,6 +318,8 @@ module MT = struct
| Psig_recmodule l ->
rec_module ~loc (List.map (sub.module_declaration sub) l)
| Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x)
+ | Psig_modtypesubst x ->
+ modtype_subst ~loc (sub.module_type_declaration sub x)
| Psig_open x -> open_ ~loc (sub.open_description sub x)
| Psig_include x -> include_ ~loc (sub.include_description sub x)
| Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l)
diff --git a/parsing/depend.ml b/parsing/depend.ml
index f1a155c1ba..d202ad3faf 100644
--- a/parsing/depend.ml
+++ b/parsing/depend.ml
@@ -382,7 +382,7 @@ and add_sig_item (bv, m) item =
let bv' = add bv and m' = add m in
List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls;
(bv', m')
- | Psig_modtype x ->
+ | Psig_modtype x | Psig_modtypesubst x->
begin match x.pmtd_type with
None -> ()
| Some mty -> add_modtype bv mty
diff --git a/parsing/parsetree.mli b/parsing/parsetree.mli
index 8337c289b3..8137de7470 100644
--- a/parsing/parsetree.mli
+++ b/parsing/parsetree.mli
@@ -769,6 +769,8 @@ and signature_item_desc =
| Psig_modtype of module_type_declaration
(* module type S = MT
module type S *)
+ | Psig_modtypesubst of module_type_declaration
+ (* module type S := ... *)
| Psig_open of open_description
(* open X *)
| Psig_include of include_description
diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml
index 29351cc02a..d20ad646d4 100644
--- a/parsing/pprintast.ml
+++ b/parsing/pprintast.ml
@@ -1159,14 +1159,18 @@ and signature_item ctxt f x : unit =
pp f "@[<hov2>include@ %a@]%a"
(module_type ctxt) incl.pincl_mod
(item_attributes ctxt) incl.pincl_attributes
- | Psig_modtype {pmtd_name=s; pmtd_type=md; pmtd_attributes=attrs} ->
+ | Psig_modtype {pmtd_name=s; pmtd_type=md; pmtd_attributes=attrs}
+ | Psig_modtypesubst {pmtd_name=s; pmtd_type=md; pmtd_attributes=attrs} as p ->
pp f "@[<hov2>module@ type@ %s%a@]%a"
s.txt
- (fun f md -> match md with
- | None -> ()
- | Some mt ->
+ (fun f md -> match md, p with
+ | None, _ -> ()
+ | Some mt, Psig_modtype _ ->
pp_print_space f () ;
pp f "@ =@ %a" (module_type ctxt) mt
+ | Some mt, _ ->
+ pp_print_space f () ;
+ pp f "@ :=@ %a" (module_type ctxt) mt
) md
(item_attributes ctxt) attrs
| Psig_class_type (l) -> class_type_declaration_list ctxt f l
diff --git a/parsing/printast.ml b/parsing/printast.ml
index c196256ecd..9469bf1720 100644
--- a/parsing/printast.ml
+++ b/parsing/printast.ml
@@ -730,6 +730,10 @@ and signature_item i ppf x =
line i ppf "Psig_modtype %a\n" fmt_string_loc x.pmtd_name;
attributes i ppf x.pmtd_attributes;
modtype_declaration i ppf x.pmtd_type
+ | Psig_modtypesubst x ->
+ line i ppf "Psig_modtypesubst %a\n" fmt_string_loc x.pmtd_name;
+ attributes i ppf x.pmtd_attributes;
+ modtype_declaration i ppf x.pmtd_type
| Psig_open od ->
line i ppf "Psig_open %a %a\n" fmt_override_flag od.popen_override
fmt_longident_loc od.popen_expr;