Skip to content

Commit 17910ec

Browse files
authored
flambda-backend: Improve interaction between Jane_syntax and modes (#2325)
1 parent 137e416 commit 17910ec

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

parsing/ast_iterator.ml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,17 @@ module T = struct
158158
let iter sub ({ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs}
159159
as typ) =
160160
sub.location sub loc;
161-
match Jane_syntax.Core_type.of_ast typ with
162-
| Some (jtyp, attrs) ->
163-
sub.attributes sub attrs;
164-
sub.typ_jane_syntax sub jtyp
165-
| None ->
166161
let modes, ptyp_attributes = Jane_syntax.Mode_expr.maybe_of_attrs attrs in
167162
match modes with
168163
| Some modes ->
169164
let typ = {typ with ptyp_attributes} in
170165
sub.typ_mode_syntax sub modes typ
171166
| None ->
167+
match Jane_syntax.Core_type.of_ast typ with
168+
| Some (jtyp, attrs) ->
169+
sub.attributes sub attrs;
170+
sub.typ_jane_syntax sub jtyp
171+
| None ->
172172
sub.attributes sub attrs;
173173
match desc with
174174
| Ptyp_any
@@ -557,11 +557,6 @@ module E = struct
557557
let iter sub
558558
({pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} as expr)=
559559
sub.location sub loc;
560-
match Jane_syntax.Expression.of_ast expr with
561-
| Some (jexp, attrs) ->
562-
sub.attributes sub attrs;
563-
sub.expr_jane_syntax sub jexp
564-
| None ->
565560
match desc with
566561
| Pexp_apply
567562
({ pexp_desc = Pexp_extension(
@@ -570,6 +565,11 @@ module E = struct
570565
let modes = Jane_syntax.Mode_expr.of_payload ~loc:pexp_loc payload in
571566
sub.expr_mode_syntax sub modes e
572567
| _ ->
568+
match Jane_syntax.Expression.of_ast expr with
569+
| Some (jexp, attrs) ->
570+
sub.attributes sub attrs;
571+
sub.expr_jane_syntax sub jexp
572+
| None ->
573573
sub.attributes sub attrs;
574574
match desc with
575575
| Pexp_ident x -> iter_loc sub x
@@ -678,17 +678,17 @@ module P = struct
678678
let iter sub
679679
({ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} as pat) =
680680
sub.location sub loc;
681-
match Jane_syntax.Pattern.of_ast pat with
682-
| Some (jpat, attrs) ->
683-
sub.attributes sub attrs;
684-
sub.pat_jane_syntax sub jpat
685-
| None ->
686681
let modes, ppat_attributes = Jane_syntax.Mode_expr.maybe_of_attrs attrs in
687682
match modes with
688683
| Some modes ->
689684
let pat = {pat with ppat_attributes} in
690685
sub.pat_mode_syntax sub modes pat
691686
| None ->
687+
match Jane_syntax.Pattern.of_ast pat with
688+
| Some (jpat, attrs) ->
689+
sub.attributes sub attrs;
690+
sub.pat_jane_syntax sub jpat
691+
| None ->
692692
sub.attributes sub attrs;
693693
match desc with
694694
| Ppat_any -> ()

0 commit comments

Comments
 (0)