home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / windex.seq < prev    next >
Text File  |  1988-09-19  |  2KB  |  60 lines

  1. \ WINDEX.SEQ    Make an index of Forth words.           by Tom Zimmer
  2.  
  3. .comment:
  4.  
  5. Displays a more or less alphabetized list of Forth words showing
  6. vocabulary and file where it was defined.
  7.  
  8. Just type ALLWORDS <enter>  to display an index of all forth words.
  9.  
  10. Load PRINT.SEQ and use PFILE <name>, then print the file to disk with
  11. PRINT ALLWORDS.
  12.  
  13. comment;
  14.  
  15.  
  16. VARIABLE WADDR
  17. 0 value FIRSTLETTER
  18.  
  19. : >wviewfile     ( cfa --- offset a1 )
  20.                 >r files_set off> maxcfa off> maxname
  21.                 begin   1file dup
  22.                 while   r@ over name> u>
  23.                         if      dup name> maxcfa u>
  24.                                 if      dup =: maxname
  25.                                         dup name> =: maxcfa
  26.                                 then
  27.                         then    drop
  28.                 repeat  drop r> >view y@
  29.                 maxname name>pad ;
  30.  
  31. : W.ANAME       ( NFA --- )
  32.                 DUP 1+ YC@ 127 AND FIRSTLETTER =
  33.                 IF      CR DUP  .ID TAB
  34.                         WADDR @ .ID TAB
  35.                         NAME> >wviewfile nip count type
  36.                 ELSE    DROP THEN    ;
  37.  
  38. : .AVOCWORDS    ( A1 --- )      \ A1 = BODY of vocabulary
  39.                 DUP HERE 1000 + #THREADS 2* CMOVE
  40.                 BODY> >NAME WADDR !
  41.                 BEGIN   HERE 1000 + #THREADS LARGEST DUP
  42.                         ?KEYPAUSE
  43.                 WHILE   DUP L>NAME W.ANAME Y@ SWAP !
  44.                 REPEAT  2DROP ;
  45.  
  46. : <awords>      ( c1 --- )
  47.                 =: firstletter
  48.                 VOC-LINK @
  49.                 BEGIN   DUP #THREADS 2* - .AVOCWORDS @ DUP 0=
  50.                 UNTIL   DROP ;
  51.  
  52. : ALLWORDS      ( --- )
  53.                 60 RMARGIN !
  54.                 16 TABSIZE !
  55.                 ASCII a BL 1+
  56.                 DO      CR CR ." Words starting with "  I EMIT CR
  57.                         I <AWORDS>
  58.                 LOOP ;
  59.  
  60.