archrelease: copy trunk to community-any
[ArchLinux/community.git] / camlp4 / trunk / 0001-compile-with-4.10-AST.patch
blob5fc62d62cc6f64ec7a8f47e8bfd0e062ac5aee55
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
6 ---
7 camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml | 20 ++++++++++----------
8 camlp4/Camlp4Top/Rprint.ml | 8 ++++----
9 camlp4/boot/Camlp4.ml | 22 ++++++++++------------
10 configure | 4 ++--
11 opam | 2 +-
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 ->
26 let e = patt e in
27 @@ -931,7 +931,7 @@ value varify_constructors var_names =
28 match binding bi [] with
29 [ [] -> e
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))
35 | ExObj loc po cfl ->
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;
50 pincl_attributes=[];
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]
54 | SgRecMod loc mb ->
55 [mksig loc (Psig_recmodule (module_sig_binding mb [])) :: l]
56 | SgMty loc n mt ->
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]
63 | _ -> assert False ]
64 and module_str_binding x acc =
65 match x with
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$ >> ->
69 [{pmb_loc=mkloc loc;
70 - pmb_name=with_loc s loc;
71 + pmb_name=with_loc (Some s) loc;
72 pmb_expr=
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;
89 pincl_attributes=[];
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]
93 | StRecMod loc mb ->
94 [mkstr loc (Pstr_recmodule (module_str_binding mb [])) :: l]
95 | StMty loc n mt ->
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 -> () ]
115 and needs_semi =
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 =
121 | PaVrn (loc, s) ->
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) ->
128 let e = patt e
129 @@ -16483,7 +16483,7 @@ module Struct =
130 | bi -> mkexp loc (Pexp_let ((mkrf rf), bi, e)))
131 | ExLmd (loc, i, me, e) ->
132 mkexp loc
133 - (Pexp_letmodule ((with_loc i loc), (module_expr me),
134 + (Pexp_letmodule ((with_loc (Some i) loc), (module_expr me),
135 (expr e)))
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)) ->
141 mkmty loc
142 - (Pmty_functor ((with_loc "*" loc), None,
143 - (module_type mt)))
144 + (Pmty_functor (Unit, (module_type mt)))
145 | Ast.MtFun (loc, n, nt, mt) ->
146 mkmty loc
147 - (Pmty_functor ((with_loc n loc), (Some (module_type nt)),
148 + (Pmty_functor (Named ((with_loc (Some n) loc), (module_type nt)),
149 (module_type mt)))
150 | Ast.MtQuo (loc, _) ->
151 error loc "module type variable not allowed here"
152 @@ -16835,7 +16834,7 @@ module Struct =
153 (Psig_module
155 pmd_loc = mkloc loc;
156 - pmd_name = with_loc n loc;
157 + pmd_name = with_loc (Some n) loc;
158 pmd_type = module_type mt;
159 pmd_attributes = [];
160 })) ::
161 @@ -16890,7 +16889,7 @@ module Struct =
162 | Ast.MbCol (loc, s, mt) ->
164 pmd_loc = mkloc loc;
165 - pmd_name = with_loc s loc;
166 + pmd_name = with_loc (Some s) loc;
167 pmd_type = module_type mt;
168 pmd_attributes = [];
169 } :: acc
170 @@ -16902,7 +16901,7 @@ module Struct =
171 | Ast.MbColEq (loc, s, mt, me) ->
173 pmb_loc = mkloc loc;
174 - pmb_name = with_loc s loc;
175 + pmb_name = with_loc (Some s) loc;
176 pmb_expr =
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)) ->
182 mkmod loc
183 - (Pmod_functor ((with_loc "*" loc), None,
184 - (module_expr me)))
185 + (Pmod_functor (Unit, (module_expr me)))
186 | Ast.MeFun (loc, n, mt, me) ->
187 mkmod loc
188 - (Pmod_functor ((with_loc n loc), (Some (module_type mt)),
189 + (Pmod_functor (Named ((with_loc (Some n) loc), (module_type mt)),
190 (module_expr me)))
191 | Ast.MeStr (loc, sl) ->
192 mkmod loc (Pmod_structure (str_item sl []))
193 @@ -17050,7 +17048,7 @@ module Struct =
194 (Pstr_module
196 pmb_loc = mkloc loc;
197 - pmb_name = with_loc n loc;
198 + pmb_name = with_loc (Some n) loc;
199 pmb_expr = module_expr me;
200 pmb_attributes = [];
201 })) ::
202 diff --git a/configure b/configure
203 index 277556b63..7bb18bb6c 100755
204 --- a/configure
205 +++ b/configure
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."
209 exit 2
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
219 --- a/opam
220 +++ b/opam
221 @@ -1,5 +1,5 @@
222 opam-version: "1.2"
223 -version: "4.09"
224 +version: "4.10"
225 authors: ["Daniel de Rauglaudre" "Nicolas Pouillard"]
226 maintainer: "ygrek@autistici.org"
227 homepage: "https://github.com/ocaml/camlp4"
229 2.26.2