Skip to content

Commit b3ae1e8

Browse files
committed
Start work on >NUMBER definition.
1 parent 35078d5 commit b3ae1e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

pkg/forth/builtin/02_core.f

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,37 @@
489489
LITERALIZE \ literalize the noname address
490490
SWAP ! \ store the literal noname address inside the dummy value
491491
; IMMEDIATE
492+
493+
: PARSECHARRAW
494+
DUP '0' U< IF
495+
DROP -1 EXIT
496+
THEN
497+
DUP ':' U< IF
498+
'0' - EXIT
499+
THEN
500+
DUP 'A' U< IF
501+
DROP -1 EXIT
502+
THEN
503+
DUP '[' U< IF
504+
'A' 10 - - EXIT
505+
THEN
506+
DUP 'a' U< IF
507+
DROP -1 EXIT
508+
THEN
509+
DUP '{' U< IF
510+
'a' 10 - - EXIT
511+
THEN
512+
DROP -1
513+
;
514+
515+
\ Attempt to parse the character.
516+
\ If it is outside of the BASE, returns -1.
517+
: PARSECHAR ( c -- n )
518+
PARSECHARRAW
519+
DUP BASE @ 1- > IF
520+
DROP -1
521+
THEN
522+
;
523+
524+
\ : >NUMBER ( ud1 caddr1 u1 -- ud2 caddr2 u2 )
525+
\ ;

0 commit comments

Comments
 (0)