@@ -376,7 +376,7 @@ let printLongident = function
376
376
| Longident. Lident txt -> Doc. text txt
377
377
| lid -> Doc. join ~sep: Doc. dot (printLongidentAux [] lid)
378
378
379
- type identifierStyle = ExoticIdent | NormalIdent
379
+ type identifierStyle = UppercaseExoticIdent | ExoticIdent | NormalIdent
380
380
381
381
let classifyIdentContent ?(allowUident = false ) ?(allowHyphen = false ) txt =
382
382
if Token. isKeywordTxt txt then ExoticIdent
@@ -386,9 +386,9 @@ let classifyIdentContent ?(allowUident = false) ?(allowHyphen = false) txt =
386
386
if i == len then NormalIdent
387
387
else if i == 0 then
388
388
match String. unsafe_get txt i with
389
+ | '\\' -> UppercaseExoticIdent
389
390
| 'A' .. 'Z' when allowUident -> loop (i + 1 )
390
391
| 'a' .. 'z' | '_' -> loop (i + 1 )
391
- | '-' when allowHyphen -> loop (i + 1 )
392
392
| _ -> ExoticIdent
393
393
else
394
394
match String. unsafe_get txt i with
@@ -402,7 +402,7 @@ let printIdentLike ?allowUident ?allowHyphen txt =
402
402
let txt = Ext_ident. unwrap_uppercase_exotic txt in
403
403
match classifyIdentContent ?allowUident ?allowHyphen txt with
404
404
| ExoticIdent -> Doc. concat [Doc. text " \\\" " ; Doc. text txt; Doc. text " \" " ]
405
- | NormalIdent -> Doc. text txt
405
+ | UppercaseExoticIdent | NormalIdent -> Doc. text txt
406
406
407
407
let rec unsafe_for_all_range s ~start ~finish p =
408
408
start > finish
@@ -433,8 +433,14 @@ let printPolyVarIdent txt =
433
433
(* numeric poly-vars don't need quotes: #644 *)
434
434
if isValidNumericPolyvarNumber txt then Doc. text txt
435
435
else
436
- let txt = Ext_ident. unwrap_uppercase_exotic txt in
437
436
match classifyIdentContent ~allow Uident:true txt with
437
+ | UppercaseExoticIdent ->
438
+ Doc. concat
439
+ [
440
+ Doc. text " \" " ;
441
+ Doc. text (Ext_ident. unwrap_uppercase_exotic txt);
442
+ Doc. text " \" " ;
443
+ ]
438
444
| ExoticIdent -> Doc. concat [Doc. text " \" " ; Doc. text txt; Doc. text " \" " ]
439
445
| NormalIdent -> (
440
446
match txt with
0 commit comments