Fixed bug PR#2612, which had been introduced while fixing PR#2027 (ctyp parsing)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6324 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Michel Mauny 2004-05-25 11:38:32 +00:00
parent 357f43ef44
commit bf170a7a3e
3 changed files with 19 additions and 15 deletions

View File

@ -145,16 +145,18 @@ value rec ctyp_fa al =
value rec ctyp_long_id_prefix t =
match t with
[ TyAcc _ m (TyLid _ s) ->
error (loc_of_ctyp t) "invalid path element in type name"
error (loc_of_ctyp t) "invalid module expression"
| TyAcc _ m (TyUid _ s) ->
let (is_cls, li) = ctyp_long_id_prefix m in
(is_cls, ldot li s)
| TyApp _ m1 m2 ->
error (loc_of_ctyp t) "invalid path element in type name"
let (is_cls, li1) = ctyp_long_id_prefix m1 in
let (_, li2) = ctyp_long_id_prefix m2 in
(is_cls, Lapply li1 li2)
| TyUid _ s -> (False, lident s)
| TyLid _ s ->
error (loc_of_ctyp t) "invalid path element in type name"
| t -> error (loc_of_ctyp t) "invalid type" ]
error (loc_of_ctyp t) "invalid module expression"
| t -> error (loc_of_ctyp t) "invalid module expression" ]
;
value ctyp_long_id t =
@ -163,11 +165,11 @@ value ctyp_long_id t =
let (is_cls, li) = ctyp_long_id_prefix m in
(is_cls, ldot li s)
| TyAcc _ m (TyUid _ s as t) ->
error (loc_of_ctyp t) "type names cannot be capitalized"
error (loc_of_ctyp t) "invalid type name"
| TyApp _ m1 m2 ->
error (loc_of_ctyp t) "expecting a type name"
error (loc_of_ctyp t) "invalid type name"
| TyUid _ s ->
error (loc_of_ctyp t) "type names cannot be capitalized"
error (loc_of_ctyp t) "invalid type name"
| TyLid _ s -> (False, lident s)
| TyCls loc sl -> (True, long_id_of_string_list loc sl)
| t -> error (loc_of_ctyp t) "invalid type" ]

View File

@ -929,7 +929,8 @@ EXTEND
| "ctyp1"
[ t1 = SELF; t2 = SELF -> <:ctyp< $t2$ $t1$ >> ]
| "ctyp2"
[ t1 = SELF; "."; t2 = SELF -> <:ctyp< $t1$ . $t2$ >> ]
[ t1 = SELF; "."; t2 = SELF -> <:ctyp< $t1$ . $t2$ >>
| t1 = SELF; "("; t2 = SELF; ")" -> <:ctyp< $t1$ $t2$ >> ]
| "simple"
[ "'"; i = ident -> <:ctyp< '$i$ >>
| "_" -> <:ctyp< _ >>

View File

@ -134,14 +134,15 @@ let rec ctyp_fa al =
let rec ctyp_long_id_prefix t =
match t with
TyAcc (_, m, TyLid (_, s)) ->
error (loc_of_ctyp t) "invalid path element in type name"
error (loc_of_ctyp t) "invalid module expression"
| TyAcc (_, m, TyUid (_, s)) ->
let (is_cls, li) = ctyp_long_id_prefix m in is_cls, ldot li s
| TyApp (_, m1, m2) ->
error (loc_of_ctyp t) "invalid path element in type name"
let (is_cls, li1) = ctyp_long_id_prefix m1 in
let (_, li2) = ctyp_long_id_prefix m2 in is_cls, Lapply (li1, li2)
| TyUid (_, s) -> false, lident s
| TyLid (_, s) -> error (loc_of_ctyp t) "invalid path element in type name"
| t -> error (loc_of_ctyp t) "invalid type"
| TyLid (_, s) -> error (loc_of_ctyp t) "invalid module expression"
| t -> error (loc_of_ctyp t) "invalid module expression"
;;
let ctyp_long_id t =
@ -149,9 +150,9 @@ let ctyp_long_id t =
TyAcc (_, m, TyLid (_, s)) ->
let (is_cls, li) = ctyp_long_id_prefix m in is_cls, ldot li s
| TyAcc (_, m, (TyUid (_, s) as t)) ->
error (loc_of_ctyp t) "type names cannot be capitalized"
| TyApp (_, m1, m2) -> error (loc_of_ctyp t) "expecting a type name"
| TyUid (_, s) -> error (loc_of_ctyp t) "type names cannot be capitalized"
error (loc_of_ctyp t) "invalid type name"
| TyApp (_, m1, m2) -> error (loc_of_ctyp t) "invalid type name"
| TyUid (_, s) -> error (loc_of_ctyp t) "invalid type name"
| TyLid (_, s) -> false, lident s
| TyCls (loc, sl) -> true, long_id_of_string_list loc sl
| t -> error (loc_of_ctyp t) "invalid type"