1 From 98e094a7c3c01c6375c63e7b944d83142ea3166e Mon Sep 17 00:00:00 2001
2 From: ygrek <ygrek@autistici.org>
3 Date: Wed, 25 Mar 2020 16:04:36 -0400
4 Subject: [PATCH 1/2] compile with 4.10 AST
7 camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml | 20 ++++++++++----------
8 camlp4/Camlp4Top/Rprint.ml | 8 ++++----
9 camlp4/boot/Camlp4.ml | 22 ++++++++++------------
12 5 files changed, 27 insertions(+), 29 deletions(-)
14 diff --git a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
15 index c0bdf54e3..6ba906f4e 100644
16 --- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
17 +++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
18 @@ -713,7 +713,7 @@ and row_field =
19 | PaTyp loc i -> mkpat loc (Ppat_type (long_type_ident i))
20 | PaVrn loc s -> mkpat loc (Ppat_variant (conv_con s) None)
21 | PaLaz loc p -> mkpat loc (Ppat_lazy (patt p))
22 - | PaMod loc m -> mkpat loc (Ppat_unpack (with_loc m loc))
23 + | PaMod loc m -> mkpat loc (Ppat_unpack (with_loc (Some m) loc))
24 | PaExc loc p -> mkpat loc (Ppat_exception (patt p))
25 | PaAtt loc s str e ->
27 @@ -931,7 +931,7 @@ value varify_constructors var_names =
28 match binding bi [] with
30 | bi -> mkexp loc (Pexp_let (mkrf rf) bi e) ]
31 - | ExLmd loc i me e -> mkexp loc (Pexp_letmodule (with_loc i loc) (module_expr me) (expr e))
32 + | ExLmd loc i me e -> mkexp loc (Pexp_letmodule (with_loc (Some i) loc) (module_expr me) (expr e))
33 | ExMat loc e a -> mkexp loc (Pexp_match (expr e) (match_case a []))
34 | ExNew loc id -> mkexp loc (Pexp_new (long_type_ident id))
36 @@ -1132,9 +1132,9 @@ value varify_constructors var_names =
37 [ <:module_type@loc<>> -> error loc "abstract/nil module type not allowed here"
38 | <:module_type@loc< $id:i$ >> -> mkmty loc (Pmty_ident (long_uident i))
39 | Ast.MtFun(loc, "*", Ast.MtNil _, mt) ->
40 - mkmty loc (Pmty_functor (with_loc "*" loc) None (module_type mt))
41 + mkmty loc (Pmty_functor Unit (module_type mt))
42 | <:module_type@loc< functor ($n$ : $nt$) -> $mt$ >> ->
43 - mkmty loc (Pmty_functor (with_loc n loc) (Some (module_type nt)) (module_type mt))
44 + mkmty loc (Pmty_functor (Named (with_loc (Some n) loc) (module_type nt)) (module_type mt))
45 | <:module_type@loc< '$_$ >> -> error loc "module type variable not allowed here"
46 | <:module_type@loc< sig $sl$ end >> ->
47 mkmty loc (Pmty_signature (sig_item sl []))
48 @@ -1185,7 +1185,7 @@ value varify_constructors var_names =
49 | SgInc loc mt -> [mksig loc (Psig_include {pincl_mod=module_type mt;
51 pincl_loc = mkloc loc}) :: l]
52 - | SgMod loc n mt -> [mksig loc (Psig_module {pmd_loc=mkloc loc; pmd_name=with_loc n loc; pmd_type=module_type mt; pmd_attributes=[]}) :: l]
53 + | SgMod loc n mt -> [mksig loc (Psig_module {pmd_loc=mkloc loc; pmd_name=with_loc (Some n) loc; pmd_type=module_type mt; pmd_attributes=[]}) :: l]
55 [mksig loc (Psig_recmodule (module_sig_binding mb [])) :: l]
57 @@ -1215,7 +1215,7 @@ value varify_constructors var_names =
58 [ <:module_binding< $x$ and $y$ >> ->
59 module_sig_binding x (module_sig_binding y acc)
60 | <:module_binding@loc< $s$ : $mt$ >> ->
61 - [{pmd_loc=mkloc loc; pmd_name=with_loc s loc; pmd_type=module_type mt; pmd_attributes=[]} :: acc]
62 + [{pmd_loc=mkloc loc; pmd_name=with_loc (Some s) loc; pmd_type=module_type mt; pmd_attributes=[]} :: acc]
64 and module_str_binding x acc =
66 @@ -1223,7 +1223,7 @@ value varify_constructors var_names =
67 module_str_binding x (module_str_binding y acc)
68 | <:module_binding@loc< $s$ : $mt$ = $me$ >> ->
70 - pmb_name=with_loc s loc;
71 + pmb_name=with_loc (Some s) loc;
73 {pmod_loc=Location.none;
74 pmod_desc=Pmod_constraint(module_expr me,module_type mt);
75 @@ -1238,9 +1238,9 @@ value varify_constructors var_names =
76 | <:module_expr@loc< $me1$ $me2$ >> ->
77 mkmod loc (Pmod_apply (module_expr me1) (module_expr me2))
78 | Ast.MeFun(loc, "*", Ast.MtNil _, me) ->
79 - mkmod loc (Pmod_functor (with_loc "*" loc) None (module_expr me))
80 + mkmod loc (Pmod_functor Unit (module_expr me))
81 | <:module_expr@loc< functor ($n$ : $mt$) -> $me$ >> ->
82 - mkmod loc (Pmod_functor (with_loc n loc) (Some (module_type mt)) (module_expr me))
83 + mkmod loc (Pmod_functor (Named (with_loc (Some n) loc) (module_type mt)) (module_expr me))
84 | <:module_expr@loc< struct $sl$ end >> ->
85 mkmod loc (Pmod_structure (str_item sl []))
86 | <:module_expr@loc< ($me$ : $mt$) >> ->
87 @@ -1299,7 +1299,7 @@ value varify_constructors var_names =
88 | StInc loc me -> [mkstr loc (Pstr_include {pincl_mod=module_expr me;
90 pincl_loc=mkloc loc}) :: l]
91 - | StMod loc n me -> [mkstr loc (Pstr_module {pmb_loc=mkloc loc; pmb_name=with_loc n loc;pmb_expr=module_expr me;pmb_attributes=[]}) :: l]
92 + | StMod loc n me -> [mkstr loc (Pstr_module {pmb_loc=mkloc loc; pmb_name=with_loc (Some n) loc;pmb_expr=module_expr me;pmb_attributes=[]}) :: l]
94 [mkstr loc (Pstr_recmodule (module_str_binding mb [])) :: l]
96 diff --git a/camlp4/Camlp4Top/Rprint.ml b/camlp4/Camlp4Top/Rprint.ml
97 index c785b1d68..8961bc8b7 100644
98 --- a/camlp4/Camlp4Top/Rprint.ml
99 +++ b/camlp4/Camlp4Top/Rprint.ml
100 @@ -366,11 +366,11 @@ value rec print_out_module_type ppf =
101 | Omty_signature sg ->
102 fprintf ppf "@[<hv 2>sig@ %a@;<1 -2>end@]"
103 Toploop.print_out_signature.val sg
104 - | Omty_functor name None mty_res ->
105 - fprintf ppf "@[<2>functor@ (%s) ->@ %a@]" name
106 + | Omty_functor None mty_res ->
107 + fprintf ppf "@[<2>functor@ () ->@ %a@]"
108 print_out_module_type mty_res
109 - | Omty_functor name (Some mty_arg) mty_res ->
110 - fprintf ppf "@[<2>functor@ (%s : %a) ->@ %a@]" name
111 + | Omty_functor (Some name mty_arg) mty_res ->
112 + fprintf ppf "@[<2>functor@ (%s : %a) ->@ %a@]" (match name with [ None -> "_" | Some n -> n ])
113 print_out_module_type mty_arg print_out_module_type mty_res
114 | Omty_abstract -> () ]
116 diff --git a/camlp4/boot/Camlp4.ml b/camlp4/boot/Camlp4.ml
117 index dcb6a996b..32b8a8865 100644
118 --- a/camlp4/boot/Camlp4.ml
119 +++ b/camlp4/boot/Camlp4.ml
120 @@ -16216,7 +16216,7 @@ module Struct =
122 mkpat loc (Ppat_variant ((conv_con s), None))
123 | PaLaz (loc, p) -> mkpat loc (Ppat_lazy (patt p))
124 - | PaMod (loc, m) -> mkpat loc (Ppat_unpack (with_loc m loc))
125 + | PaMod (loc, m) -> mkpat loc (Ppat_unpack (with_loc (Some m) loc))
126 | PaExc (loc, p) -> mkpat loc (Ppat_exception (patt p))
127 | PaAtt (loc, s, str, e) ->
129 @@ -16483,7 +16483,7 @@ module Struct =
130 | bi -> mkexp loc (Pexp_let ((mkrf rf), bi, e)))
131 | ExLmd (loc, i, me, e) ->
133 - (Pexp_letmodule ((with_loc i loc), (module_expr me),
134 + (Pexp_letmodule ((with_loc (Some i) loc), (module_expr me),
136 | ExMat (loc, e, a) ->
137 mkexp loc (Pexp_match ((expr e), (match_case a [])))
138 @@ -16735,11 +16735,10 @@ module Struct =
139 | Ast.MtId (loc, i) -> mkmty loc (Pmty_ident (long_uident i))
140 | Ast.MtFun ((loc, "*", Ast.MtNil _, mt)) ->
142 - (Pmty_functor ((with_loc "*" loc), None,
144 + (Pmty_functor (Unit, (module_type mt)))
145 | Ast.MtFun (loc, n, nt, mt) ->
147 - (Pmty_functor ((with_loc n loc), (Some (module_type nt)),
148 + (Pmty_functor (Named ((with_loc (Some n) loc), (module_type nt)),
150 | Ast.MtQuo (loc, _) ->
151 error loc "module type variable not allowed here"
152 @@ -16835,7 +16834,7 @@ module Struct =
156 - pmd_name = with_loc n loc;
157 + pmd_name = with_loc (Some n) loc;
158 pmd_type = module_type mt;
161 @@ -16890,7 +16889,7 @@ module Struct =
162 | Ast.MbCol (loc, s, mt) ->
165 - pmd_name = with_loc s loc;
166 + pmd_name = with_loc (Some s) loc;
167 pmd_type = module_type mt;
170 @@ -16902,7 +16901,7 @@ module Struct =
171 | Ast.MbColEq (loc, s, mt, me) ->
174 - pmb_name = with_loc s loc;
175 + pmb_name = with_loc (Some s) loc;
178 pmod_loc = Location.none;
179 @@ -16923,11 +16922,10 @@ module Struct =
180 (Pmod_apply ((module_expr me1), (module_expr me2)))
181 | Ast.MeFun ((loc, "*", Ast.MtNil _, me)) ->
183 - (Pmod_functor ((with_loc "*" loc), None,
185 + (Pmod_functor (Unit, (module_expr me)))
186 | Ast.MeFun (loc, n, mt, me) ->
188 - (Pmod_functor ((with_loc n loc), (Some (module_type mt)),
189 + (Pmod_functor (Named ((with_loc (Some n) loc), (module_type mt)),
191 | Ast.MeStr (loc, sl) ->
192 mkmod loc (Pmod_structure (str_item sl []))
193 @@ -17050,7 +17048,7 @@ module Struct =
197 - pmb_name = with_loc n loc;
198 + pmb_name = with_loc (Some n) loc;
199 pmb_expr = module_expr me;
202 diff --git a/configure b/configure
203 index 277556b63..7bb18bb6c 100755
206 @@ -39,8 +39,8 @@ if [ $major -lt 4 -o \( $major -eq 4 -a $minor -lt 2 \) ]; then
207 echo "The standalone Camlp4 requires OCaml >= 4.02."
208 echo "For previous versions of OCaml use the Camlp4 distributed with OCaml."
210 -elif [ $major -ne 4 -o $minor -ne 9 ]; then
211 - echo "This version of Camlp4 is for OCaml 4.09 but you are using OCaml $ocaml_version."
212 +elif [ $major -ne 4 -o $minor -ne 10 ]; then
213 + echo "This version of Camlp4 is for OCaml 4.10 but you are using OCaml $ocaml_version."
214 if [ -d .git ] ; then
215 if [ $PINNED -eq 1 ] ; then
216 echo "You've used the wrong opam pin URL for this switch.">&2
217 diff --git a/opam b/opam
218 index 273e79aab..402d2d0f9 100644
225 authors: ["Daniel de Rauglaudre" "Nicolas Pouillard"]
226 maintainer: "ygrek@autistici.org"
227 homepage: "https://github.com/ocaml/camlp4"