[MLton] Bug in LargeInt.scan

Stephen Weeks MLton@mlton.org
Mon, 15 Aug 2005 08:20:00 -0700


> I would argue that the ? case should return NONE.  The logic is that
> there were no digits.  Consider the analgous case: Int.fromString
> "~", or even "".  No number was seen.

I think you misread my code.  In the ? case, an "0x" had been seen.
Here's the code I just committed -- it fixes a separate bug that I had
introduced.

	 fun toHexR (cread: (char, 'a) reader, uread: (bigInt, 'a) reader) 
	    s =
            case cread s of
               NONE => NONE
             | SOME (c1, s1) =>
                  if c1 = #"0" then
                     case cread s1 of
                        NONE => SOME (zero, s1)
                      | SOME (c2, s2) =>
                           if c2 = #"x" orelse c2 = #"X" then
                              case uread s2 of 
                                 NONE => SOME (zero, s1)
                               | SOME x => SOME x
                           else uread s
                  else uread s