math.parser: fix ``"-.5" dec>``.

db4
John Benediktsson 2015-07-14 20:16:34 -07:00
parent 866b40271d
commit 94bb834eae
2 changed files with 31 additions and 3 deletions

View File

@ -361,5 +361,9 @@ unit-test
{ f } [ "0o0" bin> ] unit-test
{ f } [ "0x0" bin> ] unit-test
! #1229, float parsing bug
{ -0.5 } [ "-.5" dec> ] unit-test
{ t } [ most-positive-fixnum number>string string>number fixnum? ] unit-test
{ t } [ most-negative-fixnum number>string string>number fixnum? ] unit-test

View File

@ -279,11 +279,35 @@ DEFER: @neg-digit
[ @pos-first-digit ]
} case ; inline
: with-no-radix ( i number-parse n quot -- n/f )
[
swap {
{ CHAR: b [ pick radix>> 16 = [ CHAR: b swap call ] [ @abort ] if ] }
{ CHAR: o [ @abort ] }
{ CHAR: x [ @abort ] }
[ swap call ]
} case
] curry require-next-digit ; inline
: @neg-first-digit-no-radix ( i number-parse n char -- n/f )
{
{ CHAR: . [ ->required-mantissa ] }
{ CHAR: 0 [ [ @neg-digit ] with-no-radix ] }
[ @neg-digit ]
} case ; inline
: @pos-first-digit-no-radix ( i number-parse n char -- n/f )
{
{ CHAR: . [ ->required-mantissa ] }
{ CHAR: 0 [ [ @pos-digit ] with-no-radix ] }
[ @pos-digit ]
} case ; inline
: @first-char-no-radix ( i number-parse n char -- n/f )
{
{ CHAR: - [ [ @neg-digit ] require-next-digit ?neg ] }
{ CHAR: + [ [ @pos-digit ] require-next-digit ] }
[ @pos-digit ]
{ CHAR: - [ [ @neg-first-digit-no-radix ] require-next-digit ?neg ] }
{ CHAR: + [ [ @pos-first-digit-no-radix ] require-next-digit ] }
[ @pos-first-digit-no-radix ]
} case ; inline
PRIVATE>