Thread overview
[Issue 2734] New: Ambiguity in tokenizing: _._ as a float literal
Mar 15, 2009
d-bugmail
Mar 30, 2009
d-bugmail
Nov 10, 2010
Walter Bright
March 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2734

           Summary: Ambiguity in tokenizing: _._ as a float literal
           Product: D
           Version: 2.025
          Platform: PC
               URL: http://www.digitalmars.com/d/1.0/lex.html
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: dhasenan@gmail.com


http://www.digitalmars.com/d/1.0/lex.html http://www.digitalmars.com/d/2.0/lex.html

Under "Floating Literals", the spec says:
DecimalFloat -> DecimalDigits
DecimalFloat -> DecimalDigits . DecimalDigits
DecimalFloat -> . DecimalDigits
etc

DecimalDigits is defined as:
DecimalDigits -> DecimalDigit
DecimalDigits -> DecimalDigit DecimalDigits
DecimalDigit -> [0123456789_]

From this, we can derive:
DecimalFloat -> DecimalDigits . DecimalDigits
-> DecimalDigit . DecimalDigit
-> _ . _

To resolve the ambiguity, _ cannot be allowed as the first character in a float, and it cannot be allowed as the first character after the decimal point.


-- 

March 30, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2734


unknown@simplemachines.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unknown@simplemachines.org




------- Comment #1 from unknown@simplemachines.org  2009-03-29 22:20 -------
It appears DMD 2.026 already works as you suggest; _1.0 is not recognized as a valid float.

However, 1_._1 is, which doesn't seem ambiguous to me.  Once you're after the . and in a FloatLiteral, any characters in [_0-9] should be eaten to finish the float literal.

The spec just needs to be corrected with a new rule that defines 0, NonZeroDigit, and then a repeating of those with DecimalDigits (Decimal is almost fine except its handling of octals.)

-[Unknown]


-- 

November 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2734


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-11-09 20:12:47 PST ---
http://www.dsource.org/projects/phobos/changeset/2150

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------