Skip to content

Commit c2d5c41

Browse files
authored
5.5 support: Backport Format changes (#2777)
An minimal unsafe version of Domain.DLS is used to implement Format_. This shim module just needs to be removed if OCamlformat ever use parallelism. * Disable scan_push bug fix This bug fix breaks OCamlformat and will be fixed in a separate PR.
1 parent 01ec999 commit c2d5c41

5 files changed

Lines changed: 964 additions & 396 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ profile. This started with version 0.26.0.
88

99
### Highlight
1010

11-
- Support OCaml 5.5 syntax (#2772, #2774, #2775, @Julow)
11+
- Support OCaml 5.5 syntax (#2772, #2774, #2775, #2777, @Julow)
1212

1313
- \* Update Odoc's parser to 3.0 (#2757, @Julow)
1414
The indentation of code-blocks containing OCaml code is reduced by 2 to avoid
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
include CamlinternalFormatBasics
2+
3+
type neutral_concat =
4+
{ f:
5+
'a 'b 'c 'd 'e 'f. [`String of string | `Char of char ] ->
6+
('a,'b,'c,'d,'e,'f) fmt -> ('a,'b,'c,'d,'e,'f) fmt
7+
}
8+
9+
let rec string_concat_map: type a b c d e f.
10+
neutral_concat -> (a,b,c,d,e,f) fmt -> (a,b,c,d,e,f) fmt =
11+
fun f -> function
12+
| String (pad, rest) -> String (pad, string_concat_map f rest)
13+
| Caml_string (pad, rest) -> Caml_string (pad, string_concat_map f rest)
14+
15+
| Int (iconv, pad, prec, rest) ->
16+
Int (iconv, pad, prec, string_concat_map f rest)
17+
| Int32 (iconv, pad, prec, rest) ->
18+
Int32 (iconv, pad, prec, string_concat_map f rest)
19+
| Nativeint (iconv, pad, prec, rest) ->
20+
Nativeint (iconv, pad, prec, string_concat_map f rest)
21+
| Int64 (iconv, pad, prec, rest) ->
22+
Int64 (iconv, pad, prec, string_concat_map f rest)
23+
| Float (fconv, pad, prec, rest) ->
24+
Float (fconv, pad, prec, string_concat_map f rest)
25+
26+
| Char (rest) -> Char (string_concat_map f rest)
27+
| Caml_char rest ->
28+
Caml_char ( string_concat_map f rest)
29+
| Bool (pad, rest) -> Bool (pad, string_concat_map f rest)
30+
| Alpha rest -> Alpha (string_concat_map f rest)
31+
| Theta rest -> Theta (string_concat_map f rest)
32+
| Custom (arity, fc, rest) ->
33+
Custom (arity, fc, string_concat_map f rest)
34+
| Reader rest -> Reader (string_concat_map f rest)
35+
| Flush rest -> Flush (string_concat_map f rest)
36+
37+
| String_literal (str, rest) -> f.f (`String str) (string_concat_map f rest)
38+
| Char_literal (chr, rest) ->
39+
f.f (`Char chr) (string_concat_map f rest)
40+
| Format_arg (pad, fmtty, rest) ->
41+
Format_arg (pad, fmtty, string_concat_map f rest)
42+
| Format_subst (pad, fmtty, rest) ->
43+
Format_subst (pad, fmtty, string_concat_map f rest)
44+
45+
| Scan_char_set (width_opt, char_set, rest) ->
46+
Scan_char_set (width_opt, char_set, string_concat_map f rest)
47+
| Scan_get_counter (counter, rest) ->
48+
Scan_get_counter (counter,string_concat_map f rest)
49+
| Scan_next_char (rest) ->
50+
Scan_next_char (string_concat_map f rest)
51+
| Ignored_param (ign, rest) ->
52+
Ignored_param (ign, string_concat_map f rest)
53+
54+
| Formatting_lit (fmting_lit, rest) ->
55+
Formatting_lit (fmting_lit, string_concat_map f rest)
56+
| Formatting_gen (fmting_gen, rest) ->
57+
Formatting_gen (fmting_gen, string_concat_map f rest)
58+
59+
| End_of_format -> End_of_format

0 commit comments

Comments
 (0)