\ -*- mode: forth -*-
\ $Id: spellcheck.gforth,v 1.1 2001/05/26 15:47:18 doug Exp $
\ http://www.bagley.org/~doug/shootout/
\ from Anton Ertl

wordlist constant dict

32 constant max-word

create line max-word 2 + allot

: read-dict 
    get-current dict set-current
    s" Usr.Dict.Words" r/o open-file throw
    begin
    line max-word 2 pick read-line throw
    while
    line swap nextname create
    repeat
    2drop set-current ;

: spellcheck 
    begin
    line max-word 2 pick read-line throw
    while
    line swap 2dup dict search-wordlist if
        drop 2drop
    else
        type cr
    endif
    repeat
    2drop ;

read-dict stdin spellcheck bye