From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 9EE1CBC28 for ; Wed, 3 Nov 2004 14:06:59 +0100 (CET) Received: from francois.mpi-sb.mpg.de (francois.mpi-sb.mpg.de [139.19.1.2]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iA3D6xip023133 for ; Wed, 3 Nov 2004 14:06:59 +0100 Received: from amavis by francois.mpi-sb.mpg.de with scanned-ok (Exim 3.36 #1 (Debian)) id 1CPKqp-0004Qr-00 for ; Wed, 03 Nov 2004 14:06:59 +0100 Received: from maildist ([139.19.90.238] helo=mpi-sb.mpg.de) by francois.mpi-sb.mpg.de with esmtp (Exim 3.36 #1 (Debian)) id 1CPKql-0004QO-00 for ; Wed, 03 Nov 2004 14:06:55 +0100 Received: from mpiat2314 (Debian-exim@mpiat2314 [139.19.20.103]) by mpi-sb.mpg.de (8.12.9+Sun/8.12.9) with ESMTP id iA3D6tf7000041 for ; Wed, 3 Nov 2004 14:06:55 +0100 (MET) Received: from localhost.mpi-sb.mpg.de ([127.0.0.1] helo=mpiat2314 ident=prevosto) by mpiat2314 with smtp (Exim 4.34) id 1CPKqk-0000ac-Tj for caml-list@yquem.inria.fr; Wed, 03 Nov 2004 14:06:54 +0100 Date: Wed, 3 Nov 2004 14:06:54 +0100 From: Virgile Prevosto To: Caml list Subject: types of ocamlyacc's entry points Message-ID: <20041103140654.1098ccf1@mpiat2314> X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS perl-11 X-Miltered: at nez-perce with ID 4188D7F3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; parser:01 parsing:01 token:01 parser:01 ocamlyacc:01 bug:01 functor:01 parsing:01 foo:01 sig:01 val:01 functor:01 foo:01 struct:01 token:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Hello list, I just ran into a problem while trying to parameterize an ocamlyacc-generated parser by a custom parsing function. The .mly file looked like: ----------------------------- %token SPECIAL %start main %type <(string -> 'a) -> 'a> main %% main: SPECIAL { fun specialized_parser -> specialized_parser $1 } %% ------------------------------ ocamlyacc complains: "e - the start symbol main has a polymorphic type". It seems to me that this in contradiction with the manual, which says that "The type part [of a %type directive] is an arbitrary Caml type expression, except that all type constructor names must be fully qualified". So, my first question is: Who is right, the documentation or the implementation? I suspect that this behavior is due to the bug #1583, which showed that such types may lead to unsafe code, but I think that one or two line(s) in the manual would be useful. As a workaround, I've tried to wrap the parser in a functor (this was my first intention in fact, as the custom parsing function should come from a module): ----------------------------- %{ module type Foo = sig type t val from_string: string -> t end module ParseFormula = functor (A: Foo) -> struct %} %token SPECIAL %start main %type main %% main: SPECIAL { A.from_string $1 } %% end ------------------------------ While looking like an ugly hack, this seems to work, except that the generated .mli file is not correct (see feature wish #1703 and not a bug #1886). I can ask make to remove it, but is there a cleaner way to proceed (apart from using camlp4 or Stream) ? Many thanks in advance, -- E tutto per oggi, a la prossima volta Virgile