Skip to content

Commit 4329600

Browse files
committed
unify
1 parent bf61d77 commit 4329600

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

compiler/syntax/src/res_core.ml

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ module Parser = Res_parser
1010
let mk_loc start_loc end_loc =
1111
Location.{loc_start = start_loc; loc_end = end_loc; loc_ghost = false}
1212

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+
1320
type inline_types_context = {
1421
mutable found_inline_types:
1522
(string * Warnings.loc * Parsetree.type_kind) list;
@@ -5174,42 +5181,21 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
51745181
let after_attrs =
51755182
Parser.lookahead p (fun state ->
51765183
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;
51855185
state.Parser.token)
51865186
in
51875187
match after_attrs with
51885188
| Lbrace ->
51895189
(* consume the attributes and any doc comments before the record *)
51905190
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;
51995192
Parsetree.Ptype_record
52005193
(parse_record_declaration ?current_type_name_path
52015194
?inline_types_context p)
52025195
| DotDot ->
52035196
(* attributes before an open variant marker; consume attrs/docs then handle `..` *)
52045197
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;
52135199
Parser.next p;
52145200
(* consume DotDot *)
52155201
Ptype_open
@@ -5784,14 +5770,7 @@ and parse_type_equation_and_representation ?current_type_name_path
57845770
Parser.lookahead p (fun state ->
57855771
ignore (parse_attributes state);
57865772
(* 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;
57955774
match state.Parser.token with
57965775
| Lbrace -> (
57975776
(* Disambiguate record declaration vs object type.
@@ -5801,7 +5780,7 @@ and parse_type_equation_and_representation ?current_type_name_path
58015780
Parser.next state;
58025781
(* consume Lbrace *)
58035782
ignore (parse_attributes state);
5804-
skip_docs ();
5783+
skip_doc_comments state;
58055784
match state.Parser.token with
58065785
| String _ | Dot | DotDot | DotDotDot ->
58075786
false (* object type => manifest *)

0 commit comments

Comments
 (0)