@@ -378,7 +378,7 @@ let print_longident = function
378
378
| Longident. Lident txt -> Doc. text txt
379
379
| lid -> Doc. join ~sep: Doc. dot (print_longident_aux [] lid)
380
380
381
- type identifier_style = ExoticIdent | NormalIdent
381
+ type identifier_style = UppercaseExoticIdent | ExoticIdent | NormalIdent
382
382
383
383
let classify_ident_content ?(allow_uident = false ) ?(allow_hyphen = false ) txt =
384
384
if Token. is_keyword_txt txt then ExoticIdent
@@ -388,9 +388,9 @@ let classify_ident_content ?(allow_uident = false) ?(allow_hyphen = false) txt =
388
388
if i == len then NormalIdent
389
389
else if i == 0 then
390
390
match String. unsafe_get txt i with
391
+ | '\\' -> UppercaseExoticIdent
391
392
| 'A' .. 'Z' when allow_uident -> loop (i + 1 )
392
393
| 'a' .. 'z' | '_' -> loop (i + 1 )
393
- | '-' when allow_hyphen -> loop (i + 1 )
394
394
| _ -> ExoticIdent
395
395
else
396
396
match String. unsafe_get txt i with
@@ -404,7 +404,7 @@ let print_ident_like ?allow_uident ?allow_hyphen txt =
404
404
let txt = Ext_ident. unwrap_uppercase_exotic txt in
405
405
match classify_ident_content ?allow_uident ?allow_hyphen txt with
406
406
| ExoticIdent -> Doc. concat [Doc. text " \\\" " ; Doc. text txt; Doc. text " \" " ]
407
- | NormalIdent -> Doc. text txt
407
+ | UppercaseExoticIdent | NormalIdent -> Doc. text txt
408
408
409
409
let rec unsafe_for_all_range s ~start ~finish p =
410
410
start > finish
@@ -435,8 +435,14 @@ let print_poly_var_ident txt =
435
435
(* numeric poly-vars don't need quotes: #644 *)
436
436
if is_valid_numeric_polyvar_number txt then Doc. text txt
437
437
else
438
- let txt = Ext_ident. unwrap_uppercase_exotic txt in
439
438
match classify_ident_content ~allow_uident: true txt with
439
+ | UppercaseExoticIdent ->
440
+ Doc. concat
441
+ [
442
+ Doc. text " \" " ;
443
+ Doc. text (Ext_ident. unwrap_uppercase_exotic txt);
444
+ Doc. text " \" " ;
445
+ ]
440
446
| ExoticIdent -> Doc. concat [Doc. text " \" " ; Doc. text txt; Doc. text " \" " ]
441
447
| NormalIdent -> (
442
448
match txt with
0 commit comments