From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA01550; Mon, 9 Apr 2001 17:15:43 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA01545 for caml-list@pauillac.inria.fr; Mon, 9 Apr 2001 17:15:43 +0200 (MET DST) 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 HAA18894 for ; Mon, 9 Apr 2001 07:23:25 +0200 (MET DST) Received: from localhost.localdomain (ppp41.dyn147.pacific.net.au [210.23.147.41]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f395NMf06590 for ; Mon, 9 Apr 2001 07:23:23 +0200 (MET DST) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id PAA01123; Mon, 9 Apr 2001 15:23:11 +1000 Message-ID: <3AD1473F.F485C3A9@ozemail.com.au> Date: Mon, 09 Apr 2001 15:23:11 +1000 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: Brian Rogoff CC: caml-list@inria.fr Subject: Re: [Caml-list] petty complaints References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Rogoff wrote: > Another unrelated trifling question concerns the syntax of numerical > literals. Would it be possible to allow a la Ada the insertion of _s in > a numerical literal so instead of 1000000,10000000,and 100000000 we could > write 1_000_000, 10_000_000, 100_000_000? Of course, as in Ada, you could > allow wrongly positioned or superfluous _s (1_00_00_______0) but I think > this trivial change can make reading numbers a bit nicer. I use the following lexer rules: note that the special handling of 0 prefixed decimal numbers is to allow warnings to be given for C heads that think 077 is octal :-) (* integers *) let bin_lit = '0' ('b' | 'B') (underscore? bindigit) + let oct_lit = '0' ('o' | 'O') (underscore? octdigit) + let dec_lit = '0' ('d' | 'D') (underscore? digit) + let nz_dec_lit = nzdigit (underscore? digit) * let z_dec_lit = '0' (underscore? digit) * let hex_lit = '0' ('x' | 'X') (underscore? hexdigit) + (* floats *) let decimal_string = digit (underscore? digit) * let fixed_literal = decimal_string ? '.' decimal_string | decimal_string '.' decimal_string? let exponent = 'E' ('+'|'-')? decimal_string let floating_literal = fixed_literal exponent? | decimal_string exponent -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr