summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pouillard <np@nicolaspouillard.fr>2010-06-16 09:49:10 +0000
committerNicolas Pouillard <np@nicolaspouillard.fr>2010-06-16 09:49:10 +0000
commit6bedd2b5e433ba353ca92b1fc0c5587784ded6cc (patch)
tree5ea76c1855af876dadc5aaf3a2c53fc1a565cf8f
parentd80fe8a07076ebaee514b4e4550516f4a66f830a (diff)
downloadocaml-6bedd2b5e433ba353ca92b1fc0c5587784ded6cc.tar.gz
Camlp4: use TRY to get rid of a hack and fix PR#4966
git-svn-id: http://caml.inria.fr/svn/ocaml/version/3.12@10578 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--camlp4/Camlp4Parsers/Camlp4OCamlParser.ml38
1 files changed, 2 insertions, 36 deletions
diff --git a/camlp4/Camlp4Parsers/Camlp4OCamlParser.ml b/camlp4/Camlp4Parsers/Camlp4OCamlParser.ml
index 9deae8b8ef..c7a510a52a 100644
--- a/camlp4/Camlp4Parsers/Camlp4OCamlParser.ml
+++ b/camlp4/Camlp4Parsers/Camlp4OCamlParser.ml
@@ -73,40 +73,6 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
[ Some (KEYWORD ("."|"("),_) -> raise Stream.Failure
| _ -> () ]);
- (* horrible hacks to be able to parse class_types *)
-
- value test_ctyp_minusgreater =
- Gram.Entry.of_parser "test_ctyp_minusgreater"
- (fun strm ->
- let rec skip_simple_ctyp n =
- match stream_peek_nth n strm with
- [ Some (KEYWORD "->") -> n
- | Some (KEYWORD ("[" | "[<")) ->
- skip_simple_ctyp (ignore_upto "]" (n + 1) + 1)
- | Some (KEYWORD "(") -> skip_simple_ctyp (ignore_upto ")" (n + 1) + 1)
- | Some
- (KEYWORD
- ("as" | "'" | ":" | "*" | "." | "#" | "<" | ">" | ".." | ";" |
- "_" | "?")) ->
- skip_simple_ctyp (n + 1)
- | Some (LIDENT _ | UIDENT _) ->
- skip_simple_ctyp (n + 1)
- | Some _ | None -> raise Stream.Failure ]
- and ignore_upto end_kwd n =
- match stream_peek_nth n strm with
- [ Some (KEYWORD prm) when prm = end_kwd -> n
- | Some (KEYWORD ("[" | "[<")) ->
- ignore_upto end_kwd (ignore_upto "]" (n + 1) + 1)
- | Some (KEYWORD "(") -> ignore_upto end_kwd (ignore_upto ")" (n + 1) + 1)
- | Some _ -> ignore_upto end_kwd (n + 1)
- | None -> raise Stream.Failure ]
- in
- match Stream.peek strm with
- [ Some ((KEYWORD "[" | LIDENT _ | UIDENT _), _) -> skip_simple_ctyp 1
- | Some (KEYWORD "object", _) -> raise Stream.Failure
- | _ -> 1 ])
- ;
-
value rec is_ident_constr_call =
fun
[ <:ident< $uid:_$ >> -> True
@@ -439,9 +405,9 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
<:class_type< [ ? $i$ : $t$ ] -> $ct$ >>
| i = OPTLABEL (* FIXME inline a_OPTLABEL *); t = ctyp LEVEL "star"; "->"; ct = SELF ->
<:class_type< [ ? $i$ : $t$ ] -> $ct$ >>
- | test_ctyp_minusgreater; t = ctyp LEVEL "star"; "->"; ct = SELF ->
+ | t = TRY [t = ctyp LEVEL "star"; "->" -> t]; ct = SELF ->
<:class_type< [ $t$ ] -> $ct$ >>
- | ct = class_type -> ct ] ]
+ | ct = TRY class_type -> ct ] ]
;
class_type_longident_and_param:
[ [ "["; t = comma_ctyp; "]"; i = class_type_longident ->