Browse thread
[Caml-list] petty complaints
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | John Max Skaller <skaller@o...> |
| Subject: | Re: [Caml-list] petty complaints |
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