[Issue 949] New: Wrong spec/compiler behaviour for DecimalFloat and HexFloat
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 11 17:34:02 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=949
Summary: Wrong spec/compiler behaviour for DecimalFloat and
HexFloat
Product: D
Version: 1.006
Platform: PC
URL: http://digitalmars.com/d/lex.html
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: www.digitalmars.com
AssignedTo: bugzilla at digitalmars.com
ReportedBy: hennrich.bloebaum at gmx.de
Decimal:
0
NonZeroDigit
NonZeroDigit DecimalDigits
DecimalFloat:
DecimalDigits .
DecimalDigits . DecimalDigits
DecimalDigits . DecimalDigits DecimalExponent
. Decimal
. Decimal DecimalExponent
DecimalDigits DecimalExponent
Current DecimalFloat spec does allow floats like:
writefln(.0); // 0
writefln(.10); // NonZeroDigit DecimalDigits
but not:
writefln(.01); // 0 DecimalDigits (Zero followed by digits)
There's no rule in the spec for this, but it's lexed by the compiler.
Underscores in exponents aren't handled correct, too. Change DecimalFloat to
somthing similar:
DecimalFloat:
DecimalDigits2 .
DecimalDigits2 DecimalDigits .
DecimalDigits2 . DecimalDigits
DecimalDigits2 DecimalDigits . DecimalDigits
DecimalDigits2 . DecimalDigits DecimalExponent
DecimalDigits2 DecimalDigits . DecimalDigits DecimalExponent
. DecimalDigits2
. DecimalDigits2 DecimalDigits
. DecimalDigits2 DecimalExponent
. DecimalDigits2 DecimalDigits DecimalExponent
DecimalDigits2 DecimalExponent
DecimalDigits2 DecimalDigits DecimalExponent
DecimalDigits2
0
NonZeroDigits
DecimalExponentStart
e
E
e+
E+
e-
E-
DecimalExponent
DecimalExponentStart DecimalDigits2
DecimalExponentStart DecimalDigits2 DecimalDigits
DecimalExponentStart DecimalDigits DecimalDigits2
Not sure if it's correct, but the above shouldn't allow:
writefln(._);
writefln(_.);
but:
writefln(.01);
HexFloat:
HexPrefix HexDigits . HexDigits HexExponent
HexPrefix . HexDigits HexExponent
HexPrefix HexDigits HexExponent
Against the spec, this generates no errors by the compiler:
writefln(0x.p1); // HexPrefix . HexExponent
writefln(0x1.p1); // HexPrefix HexDigits . HexExponent
The first rule should give an error, while the second should be added to the
spec.
--
More information about the Digitalmars-d-bugs
mailing list