Add a better word-not-found handler
This commit is contained in:
24
prelude.f
24
prelude.f
@@ -210,6 +210,30 @@ CHAR . EMIT
|
||||
|
||||
CHAR . EMIT
|
||||
|
||||
\ A better word-not-found handler
|
||||
|
||||
: ANY-RX? RXHEAD AC@ RXTAIL AC@ <> ;
|
||||
|
||||
: WNF-HANDLER
|
||||
." Unknown word: "
|
||||
WORDBUF SWAP TYPE CR
|
||||
STATE @ IF
|
||||
\ Remove incomplete definition and switch back to interpret mode
|
||||
LATEST @ HERE !
|
||||
LATEST @ @ LATEST !
|
||||
[COMPILE] [
|
||||
THEN
|
||||
\ We only consume to the next newline if there is RX data available,
|
||||
\ because if the offending word was at the end of the line then the
|
||||
\ newline would have already been consumed by WORD.
|
||||
ANY-RX? IF BEGIN KEY 10 = UNTIL THEN
|
||||
QUIT
|
||||
;
|
||||
|
||||
' WNF-HANDLER TO WNFHOOK
|
||||
|
||||
CHAR . EMIT
|
||||
|
||||
\ Version number
|
||||
|
||||
: VERSION-MAJOR 0 ;
|
||||
|
||||
Reference in New Issue
Block a user