From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 9094DBC6C for ; Tue, 26 Jun 2007 22:06:28 +0200 (CEST) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.226]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5QK6Rei028952 for ; Tue, 26 Jun 2007 22:06:28 +0200 Received: by wx-out-0506.google.com with SMTP id t13so1680214wxc for ; Tue, 26 Jun 2007 13:06:27 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=YjuMZxJaukDBbDpw2QthMhe5R0T43i762AF8GsnmwT/2QX3V7+LKOY7Cc8XBHUt4WjM2QZvXVBQWkH59QgHQlGaAWgyI/1WbYFuqLqi0kzWGOP54iJoj+mQT0+v7iVVBDHZ7b2MA/ymXXCi118SCasJwk3H3+lx/oj7ugHB3taI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=YyUTINcXD/6ZQcnZviHyTEYD2zI/e+PldbxlzGPhp+Q768bDEFFEz2r9kNS+4ceTwkOK7EtAU6aFZdtd3Ve62zi13FJLRkMeElkcpm08u7pktjX2WaP4EeDi3sbP02FbD/fajxUA90hRRI+ca2wQskEMnaxN/MqwoQI4kJNSOzA= Received: by 10.70.42.16 with SMTP id p16mr11771936wxp.1182888387191; Tue, 26 Jun 2007 13:06:27 -0700 (PDT) Received: from ?192.168.1.73? ( [70.130.235.154]) by mx.google.com with ESMTP id i12sm8102688wxd.2007.06.26.13.06.25 (version=SSLv3 cipher=RC4-MD5); Tue, 26 Jun 2007 13:06:26 -0700 (PDT) Message-ID: <46817245.4020305@gmail.com> Date: Tue, 26 Jun 2007 15:08:37 -0500 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.4 (X11/20070604) MIME-Version: 1.0 To: caml-list Subject: Float literals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-j-chkmail-Score: MSGID : 468171C3.005 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 468171C3.005 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; literals:01 syntax:01 ocaml:01 literals:01 notation:01 lexing:01 edgar:98 parsed:01 precedence:01 integer:01 integer:01 functions:01 match:02 blank:97 float:03 In writing a syntax highlighter for Ocaml, I've dug into the code for float literals: let float_literal = ['0'-'9'] ['0'-'9' '_']* ('.' ['0'-'9' '_']* )? (['e' 'E'] ['+' '-']? ['0'-'9'] ['0'-'9' '_']*)? This matches what the reference manual says about float literals: float-literal ::= [-] (0…9) { 0…9∣ _ } [. { 0…9∣ _ }] [(e∣ E) [+∣ -] (0…9) { 0…9∣ _ }] But it doesn't match some expectations I have about float literals. The following are all float literals: 3.14 (* no problem here *) 6.022E23 (* no problem here *) 9.109e-31 (* still no problem *) 2. (* a float - blank decimal part *) 1e6 (* an integer? no, a float without a . Problem.*) 13 (* valid as a float, according to the above definition *) Does anyone else find the last two cases kind of odd? Maybe it's not a big deal because the 1e6 is scientific notation, which is float-y, and the last one is always parsed as an integer, I assume because of precedence in the lexing functions. E.