diff --git a/prelude.f b/prelude.f index 1fdc3b7..46ebf32 100644 --- a/prelude.f +++ b/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 ;