"chainlists - executable wordlists"

chainlist EXTENSIONS
* NEW-WORDLIST ( "name" -- )


create a new WORDLIST and a "name" with a runtime of ( -- wordlist* )
 : NEW-WORDLIST WORDLIST VALUE ;
 : NEW-WORDLIST CREATE: WORDLIST ;
usually used for DO-ALL-WORDS / DO-SYNONYM

EXTENSIONS chainlist ordinary primitive

* .WORDS ( wordlist* -- )


print the WORDLIST interactivly to the user
 : .WORDS ALSO SET-CONTEXT WORDS PREVIOUS ;

WORDS / ORDER / NEW-WORDLIST / DO-ALL-WORDS

EXTENSIONS chainlist ordinary primitive

* REDO-ALL-WORDS ( wordlist* -- )


EXECUTE each entry in the wordlist in the original order defined
 : REDO-ALL-WORDS
      0 FIRST-NAME
      0 SWAP ( under )
      BEGIN ?DUP WHILE 
         DUP NAME> SWAP ( under )
         NAME-NEXT
      REPEAT
      BEGIN ?DUP WHILE
         EXECUTE
      REPEAT
 ;
to run the NEW-WORDLIST in last-run-first order, use DO-ALL-WORDS

EXTENSIONS chainlist ordinary primitive

* DO-ALL-WORDS ( wordlist* -- )


EXECUTE each entry in the wordlist in the reverse order defined
 : DO-ALL-WORDS
      0 FIRST-NAME
      BEGIN ?DUP WHILE 
         DUP NAME> EXECUTE
         NAME-NEXT
      REPEAT
 ;
to run the NEW-WORDLIST in original order, use REDO-ALL-WORDS

EXTENSIONS chainlist ordinary primitive

* DO-ALL-WORDS-WHILE-LOOP ( wordlist* xt -- )


EXECUTE each entry in the wordlist in the reverse order defined
but only as long as after EXECUTE of "word" a TRUE flag is left
on the stack. The wordlist execution is cut when a FALSE flag is seen.
(the current wordlist entry is _not_ on the stack!)
 : DO-ALL-WORDS-WHILE-LOOP >R
      0 FIRST-NAME
      BEGIN ?DUP WHILE 
         R@ EXECUTE 0= IF R>DROP DROP EXIT THEN
         DUP NAME> EXECUTE
         NAME-NEXT
      REPEAT R>DROP
 ;
compare with DO-ALL-WORDS-WHILE

EXTENSIONS chainlist ordinary primitive

* DO-ALL-WORDS-WHILE ( wordlist* "word" -- )


EXECUTE each entry in the wordlist in the reverse order defined
but only as long as after EXECUTE of "word" a TRUE flag is left
on the stack. The wordlist execution is cut when a FALSE flag is seen.
(the current wordlist entry is _not_ on the stack!)
 : DO-ALL-WORDS-WHILE ' 
      STATE @ IF LITERAL, COMPILE DO-ALL-WORDS-WHILE-LOOP EXIT THEN
      >R 0 FIRST-NAME
      BEGIN ?DUP WHILE 
         R@ EXECUTE 0= IF R>DROP DROP EXIT THEN
         DUP NAME> EXECUTE
         NAME-NEXT
      REPEAT R>DROP
 ;
to run the NEW-WORDLIST in original order, use REDO-ALL-WORDS

EXTENSIONS chainlist compiling primitive

* DO-SYNONYM ( wordlist* "do-name" "orig-name" -- )


create a SYNONYM in the specified wordlist.
 : DO-SYNONYM GET-CURRENT SWAP SET-CURRENT SYNONYM SET-CURRENT ;

DO-ALIAS / DO-ALL-WORDS / NEW-WORDLIST / WORDLIST / ORDER

EXTENSIONS chainlist ordinary primitive

* DO-ALIAS ( exec-token wordlist* "do-name" -- )


create an ALIAS with the exec-token in the specified wordlist
 : DO-ALIAS GET-CURRENT SWAP SET-CURRENT SWAP ALIAS SET-CURRENT ;
DO-SYNONYM

EXTENSIONS chainlist ordinary primitive

* ALIAS-ATEXIT ( xt "name" -- )


create a defer word that is initialized with the given x-token.
 : ALIAS-ATEXIT ATEXIT-WORDLIST DO-ALIAS ;
ATEXIT-WORDLIST DO-ALL-WORDS

EXTENSIONS chainlist ordinary primitive

* ALIAS ( xt "name" -- )

create a defer word that is initialized with the given x-token.
DO-ALIAS

EXTENSIONS chainlist ordinary primitive

ATEXIT-WORDLIST

[] no special info, see general notes

EXTENSIONS chainlist loader code P4_DVaL

PROMPT-WORDLIST

[] no special info, see general notes

EXTENSIONS chainlist loader code P4_DVaL

ABORT-WORDLIST

[] no special info, see general notes

EXTENSIONS chainlist loader code P4_DVaL