@@ -160,6 +160,12 @@ let emitRecordLabel ~(label : Longident.t Location.loc) ~debug emitter =
160
160
~pos: (Utils. tupleOfLexing label.loc.loc_start)
161
161
~lid: label.txt ~debug
162
162
163
+ let emitVariant ~(name : Longident.t Location.loc ) ~debug emitter =
164
+ emitter
165
+ |> emitLongident ~upper CaseToken:Token. EnumMember
166
+ ~pos: (Utils. tupleOfLexing name.loc.loc_start)
167
+ ~lid: name.txt ~debug
168
+
163
169
let parser ~debug ~emitter ~path =
164
170
let processTypeArg (coreType : Parsetree.core_type ) =
165
171
if debug then Printf. printf " TypeArg: %s\n " (locToString coreType.ptyp_loc)
@@ -189,6 +195,9 @@ let parser ~debug ~emitter ~path =
189
195
cases
190
196
|> List. iter (fun (label , _ ) -> emitter |> emitRecordLabel ~label ~debug );
191
197
Ast_mapper. default_mapper.pat mapper p
198
+ | Ppat_construct (name , _ ) ->
199
+ emitter |> emitVariant ~name ~debug ;
200
+ Ast_mapper. default_mapper.pat mapper p
192
201
| _ -> Ast_mapper. default_mapper.pat mapper p
193
202
in
194
203
let expr (mapper : Ast_mapper.mapper ) (e : Parsetree.expression ) =
@@ -241,6 +250,9 @@ let parser ~debug ~emitter ~path =
241
250
| Pexp_field (_ , label ) | Pexp_setfield (_ , label , _ ) ->
242
251
emitter |> emitRecordLabel ~label ~debug ;
243
252
Ast_mapper. default_mapper.expr mapper e
253
+ | Pexp_construct (name , _ ) ->
254
+ emitter |> emitVariant ~name ~debug ;
255
+ Ast_mapper. default_mapper.expr mapper e
244
256
| _ -> Ast_mapper. default_mapper.expr mapper e
245
257
in
246
258
let module_expr (mapper : Ast_mapper.mapper ) (me : Parsetree.module_expr ) =
@@ -301,10 +313,19 @@ let parser ~debug ~emitter ~path =
301
313
~debug ;
302
314
Ast_mapper. default_mapper.label_declaration mapper ld
303
315
in
316
+ let constructor_declaration (mapper : Ast_mapper.mapper )
317
+ (cd : Parsetree.constructor_declaration ) =
318
+ emitter
319
+ |> emitVariant
320
+ ~name: {loc = cd.pcd_name.loc; txt = Longident. Lident cd.pcd_name.txt}
321
+ ~debug ;
322
+ Ast_mapper. default_mapper.constructor_declaration mapper cd
323
+ in
304
324
305
325
let mapper =
306
326
{
307
327
Ast_mapper. default_mapper with
328
+ constructor_declaration;
308
329
expr;
309
330
label_declaration;
310
331
module_declaration;
0 commit comments