Skip to content

Commit e512110

Browse files
committed
Simplify the parsing rules
1 parent 6dcf0b5 commit e512110

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

vendor/parser-extended/parser.mly

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,13 +1284,14 @@ functor_arg:
12841284
{ (Named (x, mty)) }
12851285
;
12861286

1287-
(* functor_parameters_type: *)
1288-
(* FUNCTOR attrs = attributes args = nonempty_functor_args *)
1289-
(* { Pfunctorty_keyword (attrs, args) } *)
1290-
(* | args = nonempty_functor_args *)
1291-
(* { Pfunctorty_short args } *)
1292-
(* | arg = mkmty(module_type) *)
1293-
(* { Pfunctorty_unnamed arg } *)
1287+
functor_parameters_type_arrow:
1288+
FUNCTOR attrs = attributes args = nonempty_functor_args MINUSGREATER
1289+
{ Pfunctorty_keyword (attrs, args) }
1290+
| args = nonempty_functor_args MINUSGREATER
1291+
{ Pfunctorty_short args }
1292+
| arg = module_type MINUSGREATER
1293+
{ Pfunctorty_unnamed arg }
1294+
;
12941295

12951296
module_name:
12961297
(* A named argument. *)
@@ -1619,14 +1620,6 @@ module_type:
16191620
{ unclosed "sig" $loc($1) "end" $loc($4) }
16201621
| STRUCT error
16211622
{ expecting $loc($1) "sig" }
1622-
| FUNCTOR attrs = attributes args = nonempty_functor_args
1623-
MINUSGREATER mty = module_type
1624-
%prec below_WITH
1625-
{ mkmty ~loc:$sloc (Pmty_functor (Pfunctorty_keyword (attrs, args), mty)) }
1626-
| args = nonempty_functor_args
1627-
MINUSGREATER mty = module_type
1628-
%prec below_WITH
1629-
{ mkmty ~loc:$sloc (Pmty_functor (Pfunctorty_short args, mty)) }
16301623
| MODULE TYPE OF attributes module_expr %prec below_LBRACKETAT
16311624
{ mkmty ~loc:$sloc ~attrs:$4 (Pmty_typeof $5) }
16321625
| LPAREN module_type RPAREN
@@ -1638,9 +1631,9 @@ module_type:
16381631
| mkmty(
16391632
mkrhs(mty_longident)
16401633
{ Pmty_ident $1 }
1641-
| arg = module_type MINUSGREATER mty = module_type
1634+
| params = functor_parameters_type_arrow mty = module_type
16421635
%prec below_WITH
1643-
{ Pmty_functor (Pfunctorty_unnamed arg, mty) }
1636+
{ (Pmty_functor (params, mty)) }
16441637
| module_type WITH separated_nonempty_llist(AND, with_constraint)
16451638
{ Pmty_with($1, $3) }
16461639
/* | LPAREN MODULE mkrhs(mod_longident) RPAREN
@@ -1650,6 +1643,7 @@ module_type:
16501643
)
16511644
{ $1 }
16521645
;
1646+
16531647
(* A signature, which appears between SIG and END (among other places),
16541648
is a list of signature elements. *)
16551649
signature:

0 commit comments

Comments
 (0)