diff --git a/core/math/parser/parser-tests.factor b/core/math/parser/parser-tests.factor index 24ccd1aab8..017f208d79 100644 --- a/core/math/parser/parser-tests.factor +++ b/core/math/parser/parser-tests.factor @@ -318,6 +318,14 @@ unit-test { -8 } [ "-0o10" string>number ] unit-test { -2 } [ "-0b10" string>number ] unit-test +{ 16 } [ "0X10" string>number ] unit-test +{ 8 } [ "0O10" string>number ] unit-test +{ 2 } [ "0B10" string>number ] unit-test + +{ -16 } [ "-0X10" string>number ] unit-test +{ -8 } [ "-0O10" string>number ] unit-test +{ -2 } [ "-0B10" string>number ] unit-test + { f } [ "01a" string>number ] unit-test { f } [ "0x1g" string>number ] unit-test { f } [ "0o18" string>number ] unit-test diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index 5a683d921d..db8b42c2e4 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -306,11 +306,11 @@ DEFER: @neg-digit : with-radix-char ( i number-parse n radix-quot nonradix-quot -- n/f ) [ rot { - { CHAR: b [ drop 2 ->radix require-next-digit ] } - { CHAR: o [ drop 8 ->radix require-next-digit ] } - { CHAR: x [ drop 16 ->radix require-next-digit ] } + { [ dup "bB" member-eq? ] [ 2drop 2 ->radix require-next-digit ] } + { [ dup "oO" member-eq? ] [ 2drop 8 ->radix require-next-digit ] } + { [ dup "xX" member-eq? ] [ 2drop 16 ->radix require-next-digit ] } [ [ drop ] 2dip swap call ] - } case + } cond ] 2curry next-digit ; inline : @pos-first-digit ( i number-parse n char -- n/f )