[nem-en] integer literals grammar

NoiseEHC NoiseEHC at freemail.hu
Fri Feb 23 20:25:15 CET 2007


Can you fix the compiler to generate a warning if you use the l suffix 
in lowercase?
(You know it was the lowercase L character...)
C# already does this.

Kamil Skalski wrote:
> 2007/2/23, Dmitry Ivankov <divanorama at gmail.com>:
>> I have some questions about grammar:
>> - Everything in integer and float literals is case insensitive?
>
> Yes
>
>> What is the grammar for integer literals?
>> - what are valid type suffixes? (ub, u, l, lu) each in any order?
>
> u, ul, lu, s, sb, bs, m
>
>> - can underscore be used in non-decimal literals? like 0xa_1, or 0x1_a
>> (first compiles, second - not)
>
> Looks like _ expects always digit after it, otherwise it terminates
> the literal. I guess it would be resonable to forbid _ in non-decimal
> literals.
>
>> - can type suffixes be used in non-decimal literals? what about 0xbb, 
>> is it
>> 0xbb or (0xb)b? ;)
>
> In hex mode b is eagerly parsed as part of number. But in general yes,
> type suffixes can be used in non-decimals.
>
>> And about floating point literals:
>> - underscore can be used between digits, but not in exponent, right? :)
>
> Yes
>
>>
>> My suggestions:
>> - add type suffix 's' (so we can write 0xbsb)
>
> It already works.
>
>> - allow underscore in any integer literal (i.e. fix parsing of 0x1_a)
>
> I'm not sure if _ inside hex values makes any sense... but on the
> other hand, why not.
>
>> - allow underscore only before dot in floats (the only use of 
>> underscore in
>> floats i can image is to change 1_000 to 1_000.0 quickly, or someone 
>> would
>> like to use it like that: 0.12345_67890 ? )
>
> I think using _ after . makes more sense than using it in  hex numbers.
>
>>
>>
>> I think that after figuring out exact grammar i'll add it
>> to wiki ;)
>
> Please do so:
> http://nemerle.org/Lexical_structure_%28ref%29#Literals
>
>



More information about the devel-en mailing list