diff options
-rw-r--r-- | camlp4/meta/pa_r.ml | 4 | ||||
-rw-r--r-- | camlp4/meta/q_MLast.ml | 7 | ||||
-rw-r--r-- | camlp4/ocaml_src/meta/pa_r.ml | 24 | ||||
-rw-r--r-- | camlp4/ocaml_src/meta/q_MLast.ml | 41 | ||||
-rw-r--r-- | camlp4/top/rprint.ml | 4 |
5 files changed, 76 insertions, 4 deletions
diff --git a/camlp4/meta/pa_r.ml b/camlp4/meta/pa_r.ml index c70d93380..14954cdde 100644 --- a/camlp4/meta/pa_r.ml +++ b/camlp4/meta/pa_r.ml @@ -768,6 +768,10 @@ EXTEND | "["; "<"; rfl = row_field_list; "]" -> <:ctyp< [ < $list:rfl$ ] >> | "["; "<"; rfl = row_field_list; ">"; ntl = LIST1 name_tag; "]" -> + <:ctyp< [ < $list:rfl$ > $list:ntl$ ] >> + | "[<"; rfl = row_field_list; "]" -> + <:ctyp< [ < $list:rfl$ ] >> + | "[<"; rfl = row_field_list; ">"; ntl = LIST1 name_tag; "]" -> <:ctyp< [ < $list:rfl$ > $list:ntl$ ] >> ] ] ; row_field_list: diff --git a/camlp4/meta/q_MLast.ml b/camlp4/meta/q_MLast.ml index 06f5aabe9..2c79b43d2 100644 --- a/camlp4/meta/q_MLast.ml +++ b/camlp4/meta/q_MLast.ml @@ -1042,6 +1042,13 @@ EXTEND Qast.Option (Some (Qast.Option (Some (Qast.List []))))] | "["; "<"; rfl = row_field_list; ">"; ntl = SLIST1 name_tag; "]" -> Qast.Node "TyVrn" + [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))] + | "[<"; rfl = row_field_list; "]" -> + Qast.Node "TyVrn" + [Qast.Loc; rfl; + Qast.Option (Some (Qast.Option (Some (Qast.List []))))] + | "[<"; rfl = row_field_list; ">"; ntl = SLIST1 name_tag; "]" -> + Qast.Node "TyVrn" [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))] ] ] ; row_field_list: diff --git a/camlp4/ocaml_src/meta/pa_r.ml b/camlp4/ocaml_src/meta/pa_r.ml index d3af135fa..b380dbcef 100644 --- a/camlp4/ocaml_src/meta/pa_r.ml +++ b/camlp4/ocaml_src/meta/pa_r.ml @@ -2531,7 +2531,29 @@ Grammar.extend Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); + [[Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", ">"); + Gramext.Slist1 + (Gramext.Snterm + (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e))); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (ntl : 'name_tag list) _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.TyVrn (loc, rfl, Some (Some ntl)) : 'ctyp)); + [Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (MLast.TyVrn (loc, rfl, Some (Some [])) : 'ctyp)); + [Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); Gramext.Snterm (Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e)); diff --git a/camlp4/ocaml_src/meta/q_MLast.ml b/camlp4/ocaml_src/meta/q_MLast.ml index 2fcc3448c..dac10349d 100644 --- a/camlp4/ocaml_src/meta/q_MLast.ml +++ b/camlp4/ocaml_src/meta/q_MLast.ml @@ -3771,7 +3771,46 @@ Grammar.extend Grammar.Entry.obj (ctyp : 'ctyp Grammar.Entry.e), Some (Gramext.Level "simple"), [None, None, - [[Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); + [[Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", ">"); + Gramext.srules + [[Gramext.Slist1 + (Gramext.Snterm + (Grammar.Entry.obj (name_tag : 'name_tag Grammar.Entry.e)))], + Gramext.action + (fun (a : 'name_tag list) + (loc : Lexing.position * Lexing.position) -> + (Qast.List a : 'a_list)); + [Gramext.Snterm + (Grammar.Entry.obj (a_list : 'a_list Grammar.Entry.e))], + Gramext.action + (fun (a : 'a_list) (loc : Lexing.position * Lexing.position) -> + (a : 'a_list))]; + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (ntl : 'a_list) _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (Qast.Node + ("TyVrn", + [Qast.Loc; rfl; Qast.Option (Some (Qast.Option (Some ntl)))]) : + 'ctyp)); + [Gramext.Stoken ("", "[<"); + Gramext.Snterm + (Grammar.Entry.obj + (row_field_list : 'row_field_list Grammar.Entry.e)); + Gramext.Stoken ("", "]")], + Gramext.action + (fun _ (rfl : 'row_field_list) _ + (loc : Lexing.position * Lexing.position) -> + (Qast.Node + ("TyVrn", + [Qast.Loc; rfl; + Qast.Option (Some (Qast.Option (Some (Qast.List []))))]) : + 'ctyp)); + [Gramext.Stoken ("", "["); Gramext.Stoken ("", "<"); Gramext.Snterm (Grammar.Entry.obj (row_field_list : 'row_field_list Grammar.Entry.e)); diff --git a/camlp4/top/rprint.ml b/camlp4/top/rprint.ml index 76f19fe11..ecc90cd58 100644 --- a/camlp4/top/rprint.ml +++ b/camlp4/top/rprint.ml @@ -167,8 +167,8 @@ and print_simple_out_type ppf = | Ovar_name id tyl -> fprintf ppf "@[%a%a@]" print_typargs tyl print_ident id ] in - fprintf ppf "%s[|%s@[<hv>@[<hv>%a@]%a|]@]" (if non_gen then "_" else "") - (if closed then if tags = None then " " else "< " + fprintf ppf "%s[%s@[<hv>@[<hv>%a@]%a ]@]" (if non_gen then "_" else "") + (if closed then if tags = None then "= " else "< " else if tags = None then "> " else "? ") print_fields row_fields |