From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA31201 for caml-red; Sun, 19 Nov 2000 15:55:47 +0100 (MET) 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 SAA02383 for ; Fri, 17 Nov 2000 18:11:48 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id eAHHBlj23600; Fri, 17 Nov 2000 18:11:47 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA12347; Fri, 17 Nov 2000 18:11:47 +0100 (MET) Message-ID: <20001117181147.25121@pauillac.inria.fr> Date: Fri, 17 Nov 2000 18:11:47 +0100 From: Xavier Leroy To: Michel Levy , caml-list@inria.fr Subject: Re: analysis of expression References: <3A10230E.F4EFBBEE@imag.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <3A10230E.F4EFBBEE@imag.fr>; from Michel Levy on Mon, Nov 13, 2000 at 06:21:18PM +0100 Sender: weis@pauillac.inria.fr > In definition of expr I read : > expr := expr expr > | expr infix-op expr > with that syntax its possible to have two analysis of the sentence "let > x = 1 in x-1" ? > 1) The correct analysis (the Ocaml anlysis) : - is an operation between > x et 1 > 2) x is applied to -1 and we find a type error > Where it's possible to find in the Ocaml reference the choosen solution ? It's not very explicit, I agree, but the table of operator precedences for expressions says that function application has higher precedence than unary minus. So, "x-1" cannot be parsed as "x applied to -1" since this would violate the precedences. And of course "x-1" cannot be parsed as "(x applied to -) applied to 1" because "-" in itself is not a valid expression. This leaves "x binary minus 1" as the only legal parsing. - Xavier Leroy