1+ (*
12open Migrate_parsetree
23open Ast_408
34
45open Asttypes
56open Parsetree
67open Ast_helper
8+ *)
9+ open Ppxlib
10+ open Ppxlib.Ast_builder.Default
711
812type binding_site = Binder of int | Context of int
913
@@ -30,7 +34,7 @@ and analyse_exp_desc env loc = function
3034 | PStr [ {pstr_desc= Pstr_eval (e, _); _} ] ->
3135 e
3236 | _ ->
33- raise (Location. (Error (error ~loc (" [%e] expects an expression" )))) in
37+ raise (Location. (Error (Error. make ~sub: [] ~loc (" [%e] expects an expression" )))) in
3438 let h = env.fresh_hole () in
3539 Hashtbl. add env.hole_table h (env.bindings, code);
3640 Pexp_ident { txt = Lident (" ," ^ string_of_int h); loc }
@@ -95,9 +99,8 @@ and analyse_exp_desc env loc = function
9599 let env' = analyse_pat env pat in
96100 Pexp_for (pat, analyse_exp env e1, analyse_exp env e2, dir, analyse_exp env' body)
97101 (* several missing... *)
98-
99102
100- | _ -> raise (Location. (Error (error ~loc (" expression not supported in staged code" ))))
103+ | _ -> raise (Location. (Error (Error. make ~sub: [] ~loc (" expression not supported in staged code" ))))
101104
102105and analyse_exp_opt env = function
103106 | None -> None
@@ -109,16 +112,16 @@ and analyse_pat env pat =
109112
110113and analyse_pat_desc env loc = function
111114 | Ppat_any -> env
112- | Ppat_var v -> analyse_pat_desc env loc (Ppat_alias (Pat. any () , v))
115+ | Ppat_var v -> analyse_pat_desc env loc (Ppat_alias (ppat_any ~loc , v))
113116 | Ppat_alias (pat , v ) ->
114117 let env = analyse_pat env pat in
115118 { env with bindings = IdentMap. add v.txt (env.fresh_binder () ) env.bindings }
116119 | Ppat_constant _ -> env
117120 | Ppat_interval _ -> env
118121 | Ppat_tuple pats -> List. fold_left analyse_pat env pats
119122 | Ppat_construct (_loc , None) -> env
120- | Ppat_construct (_loc , Some pat ) -> analyse_pat env pat
121- | _ -> raise (Location. (Error (error ~loc (" pattern not supported in staged code" ))))
123+ | Ppat_construct (_loc , Some ( _locs , pat ) ) -> analyse_pat env pat
124+ | _ -> raise (Location. (Error (Error. make ~sub: [] ~loc (" pattern not supported in staged code" ))))
122125
123126and analyse_case env {pc_lhs; pc_guard; pc_rhs} =
124127 let env' = analyse_pat env pc_lhs in
@@ -131,7 +134,7 @@ and analyse_attributes = function
131134| {attr_payload =PStr [] ; _} :: rest ->
132135 analyse_attributes rest
133136| {attr_name ={loc;txt} ; _} :: _ ->
134- raise (Location. (Error (error ~loc (" attribute " ^ txt ^ " not supported in staged code" ))))
137+ raise (Location. (Error (Error. make ~sub: [] ~loc (" attribute " ^ txt ^ " not supported in staged code" ))))
135138
136139
137140let analyse_binders (context : int IdentMap.t ) (e : expression ) :
@@ -150,8 +153,8 @@ let analyse_binders (context : int IdentMap.t) (e : expression) :
150153 e', hole_table
151154
152155
153-
154- open Ast_mapper
156+ (* CR OlivierNicole: copy-paste from runtime/internal.ml? *)
157+ (*
155158type substitutable =
156159| SubstContext of int
157160| SubstHole of int
@@ -241,3 +244,5 @@ let module_remapper f =
241244 { pmod with pmod_desc }
242245 in
243246 { default_mapper with expr; typ; pat; module_type; open_description; module_expr }
247+ *)
248+ let module_remapper = Ppx_stage.Internal. module_remapper
0 commit comments