mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 00:18:05 +11:00
3d908cef3a
This allows us to get rid of the (parse*) indirection.
15 lines
319 B
Plaintext
15 lines
319 B
Plaintext
( returns negative value on error )
|
|
: _ ( c -- n )
|
|
( '0' is ASCII 48 )
|
|
48 -
|
|
DUP 0< ( bad ) OVER 10 < ( good ) OR IF EXIT THEN
|
|
( 'a' is ASCII 97. 59 = 97 - 48 )
|
|
49 -
|
|
DUP 0< IF EXIT THEN ( bad )
|
|
DUP 6 < IF 10 + EXIT THEN ( good )
|
|
( bad )
|
|
255 -
|
|
;
|
|
|
|
|