From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 64E6EBB91 for ; Fri, 28 Jan 2005 05:30:36 +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 j0S4UZ2j005423 for ; Fri, 28 Jan 2005 05:30:36 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id FAA19779 for ; Fri, 28 Jan 2005 05:30:35 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0S4UXBZ029436 for ; Fri, 28 Jan 2005 05:30:34 +0100 Received: from [192.168.1.200] (ppp205-248.lns1.syd3.internode.on.net [203.122.205.248]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j0S4UUiQ097434; Fri, 28 Jan 2005 15:00:31 +1030 (CST) Subject: Re: [Caml-list] yacc style From: skaller Reply-To: skaller@users.sourceforge.net To: Erik de Castro Lopo Cc: caml-list In-Reply-To: <20050128132812.7001512c.ocaml-erikd@mega-nerd.com> References: <875c7e0705012712177a9e852@mail.gmail.com> <20050128083956.7dc72787.ocaml-erikd@mega-nerd.com> <1106874879.12114.145.camel@pelican.wigram> <20050128132812.7001512c.ocaml-erikd@mega-nerd.com> Content-Type: text/plain Message-Id: <1106886629.12114.246.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 28 Jan 2005 15:30:30 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41F9BFEB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41F9BFE9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 sourceforge:01 wrote:01 parser:01 casts:01 casts:01 token:01 parser:01 glebe:01 ...:98 061:98 expression:01 expression: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: On Fri, 2005-01-28 at 13:28, Erik de Castro Lopo wrote: > On 28 Jan 2005 12:14:39 +1100 > skaller wrote: > > > On Fri, 2005-01-28 at 08:39, Erik de Castro Lopo wrote: > > > > > > Yes, normally the parser generates a parse tree which is then > > > passed to the semantic analyser for semantic checking. > > > > Unfortunately this is useless in the common case > > of needing to parse C. > > I'm happy to take your word for it John, but I'd like to know > why. Sure: there are several contexts, but one is that: (X)(Y)(Z) could mean either ((X)(Y))(Z) or (X)((Y)(Z)) depending on whether Y is a type, in which case (Y)(Z) is a cast, or an expression, in which case (Y)(Z) is a function application. The precedences of casts and function applications in C are different. Function calls bind more tightly than casts, so (int)(f)(x) means cast the result of f(x) to an int, whereas (g)(a)(b) means apply g(a) to b .. assuming g,a,b are not typenames .. :) Smly (f)(x,y,z) comma is a separator if f is a function, if f is a typename its a cast, and (x,y,z) is an expression value 'z'... :) I guess there is more, and C++ is worse, but this is enough to be as confused as a one token lookahead context free parser would be .. :) -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net