From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3CAF6D461 for ; Wed, 9 Nov 2005 13:26:15 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jA9CQEAj001080 for ; Wed, 9 Nov 2005 13:26:14 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA11217 for ; Wed, 9 Nov 2005 13:26:14 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jA9CQCYh001073 for ; Wed, 9 Nov 2005 13:26:13 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id jA9CQ5O2029133; Wed, 9 Nov 2005 21:26:05 +0900 (JST) Date: Wed, 09 Nov 2005 21:26:03 +0900 (JST) Message-Id: <20051109.212603.63126983.garrigue@math.nagoya-u.ac.jp> To: jon@ffconsultancy.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] ocamlyacc: e - the start symbol expr has a polymorphic type From: Jacques Garrigue In-Reply-To: <200511081324.32311.jon@ffconsultancy.com> References: <200511081324.32311.jon@ffconsultancy.com> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4371EAE6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4371EAE4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlyacc:01 expr:01 parser:01 ocamlyacc:01 minor:01 grammar:01 expr:01 grammar:01 ocaml:01 polymorphic:01 polymorphic:01 define:01 jacques:01 jacques:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: Jon Harrop > I'm just trying to write an example parser using ocamlyacc and have come > across a minor irritation. > > The example is a calculator and, in the interests of brevity, I'd like to > return the AST as a polymorphic variant. However, if I define the return type > from the grammar rule as: > > %type <[`Num of float | `Op2 of [`Plus|`Times] * 'a * 'a] as 'a> expr > > I get the error: > > ocamlyacc: e - the start symbol expr has a polymorphic type > > This type certainly contains the type variable 'a but I'm not sure > I'd call it polymorphic. Indeed, it is not. But if you look at ocamlyacc's source, you will realize this is a C program, which was derived from old BSD yacc (I believe.) Difficult to expect it to understand the whole grammar of types, and it is better to be on the safe side. Note that a pure ocaml yacc replacement is in preparation, which might be able to solve such problems. Jacques Garrigue