Skip to content

Commit d564447

Browse files
committed
format
1 parent a2feefb commit d564447

File tree

1 file changed

+53
-38
lines changed

1 file changed

+53
-38
lines changed

compiler/syntax/src/res_core.ml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5167,7 +5167,7 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
51675167
match p.Parser.token with
51685168
| Bar | Uident _ | DocComment _ ->
51695169
Parsetree.Ptype_variant (parse_type_constructor_declarations p)
5170-
| At ->
5170+
| At -> (
51715171
(* Attributes can prefix either a variant (constructor list), a record, or an
51725172
open/extensible variant marker (`..`). Peek past attributes and any doc
51735173
comments to decide which kind it is. *)
@@ -5176,39 +5176,47 @@ and parse_type_representation ?current_type_name_path ?inline_types_context p =
51765176
ignore (parse_attributes state);
51775177
let rec skip_docs () =
51785178
match state.Parser.token with
5179-
| DocComment _ -> Parser.next state; skip_docs ()
5179+
| DocComment _ ->
5180+
Parser.next state;
5181+
skip_docs ()
51805182
| _ -> ()
51815183
in
51825184
skip_docs ();
51835185
state.Parser.token)
51845186
in
5185-
(match after_attrs with
5187+
match after_attrs with
51865188
| Lbrace ->
5187-
(* consume the attributes and any doc comments before the record *)
5188-
ignore (parse_attributes p);
5189-
let rec skip_docs () =
5190-
match p.Parser.token with
5191-
| DocComment _ -> Parser.next p; skip_docs ()
5192-
| _ -> ()
5193-
in
5194-
skip_docs ();
5195-
Parsetree.Ptype_record
5196-
(parse_record_declaration ?current_type_name_path ?inline_types_context p)
5189+
(* consume the attributes and any doc comments before the record *)
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 ();
5199+
Parsetree.Ptype_record
5200+
(parse_record_declaration ?current_type_name_path
5201+
?inline_types_context p)
51975202
| DotDot ->
5198-
(* attributes before an open variant marker; consume attrs/docs then handle `..` *)
5199-
ignore (parse_attributes p);
5200-
let rec skip_docs () =
5201-
match p.Parser.token with
5202-
| DocComment _ -> Parser.next p; skip_docs ()
5203-
| _ -> ()
5204-
in
5205-
skip_docs ();
5206-
Parser.next p; (* consume DotDot *)
5207-
Ptype_open
5203+
(* attributes before an open variant marker; consume attrs/docs then handle `..` *)
5204+
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 ();
5213+
Parser.next p;
5214+
(* consume DotDot *)
5215+
Ptype_open
52085216
| _ ->
5209-
(* fall back to variant constructor declarations; leave attributes for the
5217+
(* fall back to variant constructor declarations; leave attributes for the
52105218
constructor parsing so they attach to the first constructor. *)
5211-
Parsetree.Ptype_variant (parse_type_constructor_declarations p))
5219+
Parsetree.Ptype_variant (parse_type_constructor_declarations p))
52125220
| Lbrace ->
52135221
Parsetree.Ptype_record
52145222
(parse_record_declaration ?current_type_name_path ?inline_types_context
@@ -5778,30 +5786,37 @@ and parse_type_equation_and_representation ?current_type_name_path
57785786
(* optionally skip a run of doc comments before deciding *)
57795787
let rec skip_docs () =
57805788
match state.Parser.token with
5781-
| DocComment _ -> Parser.next state; skip_docs ()
5789+
| DocComment _ ->
5790+
Parser.next state;
5791+
skip_docs ()
57825792
| _ -> ()
57835793
in
57845794
skip_docs ();
57855795
match state.Parser.token with
5786-
| Lbrace ->
5796+
| Lbrace -> (
57875797
(* Disambiguate record declaration vs object type.
57885798
Peek inside the braces; if it looks like an object (String/Dot/DotDot/DotDotDot),
57895799
then this is a manifest type expression, not a representation. If it looks like
57905800
a record field (e.g. Lident or attributes before one), treat as representation. *)
5791-
Parser.next state; (* consume Lbrace *)
5801+
Parser.next state;
5802+
(* consume Lbrace *)
57925803
ignore (parse_attributes state);
57935804
skip_docs ();
5794-
(match state.Parser.token with
5795-
| String _ | Dot | DotDot | DotDotDot -> false (* object type => manifest *)
5796-
| _ -> true) (* record decl => representation *)
5797-
| Bar -> true (* variant constructor list *)
5798-
| DotDot -> true (* extensible/open variant ".." *)
5799-
| Uident _ -> (* constructor vs module-qualified manifest *)
5805+
match state.Parser.token with
5806+
| String _ | Dot | DotDot | DotDotDot ->
5807+
false (* object type => manifest *)
5808+
| _ -> true
5809+
(* record decl => representation *))
5810+
| Bar -> true (* variant constructor list *)
5811+
| DotDot -> true (* extensible/open variant ".." *)
5812+
| Uident _ -> (
5813+
(* constructor vs module-qualified manifest *)
58005814
Parser.next state;
5801-
(match state.Parser.token with
5802-
| Dot -> false (* M.t => manifest *)
5803-
| _ -> true) (* Uident starting a constructor *)
5804-
| DocComment _ -> true (* doc before constructor list *)
5815+
match state.Parser.token with
5816+
| Dot -> false (* M.t => manifest *)
5817+
| _ -> true
5818+
(* Uident starting a constructor *))
5819+
| DocComment _ -> true (* doc before constructor list *)
58055820
| _ -> false)
58065821
in
58075822
if is_representation_after_attrs then

0 commit comments

Comments
 (0)