@@ -10,6 +10,13 @@ module Parser = Res_parser
10
10
let mk_loc start_loc end_loc =
11
11
Location. {loc_start = start_loc; loc_end = end_loc; loc_ghost = false }
12
12
13
+ let rec skip_doc_comments p =
14
+ match p.Parser. token with
15
+ | DocComment _ ->
16
+ Parser. next p;
17
+ skip_doc_comments p
18
+ | _ -> ()
19
+
13
20
type inline_types_context = {
14
21
mutable found_inline_types :
15
22
(string * Warnings .loc * Parsetree .type_kind ) list ;
@@ -5174,42 +5181,21 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
5174
5181
let after_attrs =
5175
5182
Parser. lookahead p (fun state ->
5176
5183
ignore (parse_attributes state);
5177
- let rec skip_docs () =
5178
- match state.Parser. token with
5179
- | DocComment _ ->
5180
- Parser. next state;
5181
- skip_docs ()
5182
- | _ -> ()
5183
- in
5184
- skip_docs () ;
5184
+ skip_doc_comments state;
5185
5185
state.Parser. token)
5186
5186
in
5187
5187
match after_attrs with
5188
5188
| Lbrace ->
5189
5189
(* consume the attributes and any doc comments before the record *)
5190
5190
ignore (parse_attributes p);
5191
- let rec skip_docs () =
5192
- match p.Parser. token with
5193
- | DocComment _ ->
5194
- Parser. next p;
5195
- skip_docs ()
5196
- | _ -> ()
5197
- in
5198
- skip_docs () ;
5191
+ skip_doc_comments p;
5199
5192
Parsetree. Ptype_record
5200
5193
(parse_record_declaration ?current_type_name_path
5201
5194
?inline_types_context p)
5202
5195
| DotDot ->
5203
5196
(* attributes before an open variant marker; consume attrs/docs then handle `..` *)
5204
5197
ignore (parse_attributes p);
5205
- let rec skip_docs () =
5206
- match p.Parser. token with
5207
- | DocComment _ ->
5208
- Parser. next p;
5209
- skip_docs ()
5210
- | _ -> ()
5211
- in
5212
- skip_docs () ;
5198
+ skip_doc_comments p;
5213
5199
Parser. next p;
5214
5200
(* consume DotDot *)
5215
5201
Ptype_open
@@ -5784,14 +5770,7 @@ and parse_type_equation_and_representation ?current_type_name_path
5784
5770
Parser. lookahead p (fun state ->
5785
5771
ignore (parse_attributes state);
5786
5772
(* optionally skip a run of doc comments before deciding *)
5787
- let rec skip_docs () =
5788
- match state.Parser. token with
5789
- | DocComment _ ->
5790
- Parser. next state;
5791
- skip_docs ()
5792
- | _ -> ()
5793
- in
5794
- skip_docs () ;
5773
+ skip_doc_comments state;
5795
5774
match state.Parser. token with
5796
5775
| Lbrace -> (
5797
5776
(* Disambiguate record declaration vs object type.
@@ -5801,7 +5780,7 @@ and parse_type_equation_and_representation ?current_type_name_path
5801
5780
Parser. next state;
5802
5781
(* consume Lbrace *)
5803
5782
ignore (parse_attributes state);
5804
- skip_docs () ;
5783
+ skip_doc_comments state ;
5805
5784
match state.Parser. token with
5806
5785
| String _ | Dot | DotDot | DotDotDot ->
5807
5786
false (* object type => manifest *)
0 commit comments