home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tile-forth-2.1-bin.lha / lib / tile-forth / index.f83 < prev    next >
Text File  |  1996-10-12  |  2KB  |  91 lines

  1. .( Loading Source Index definitions...) cr
  2.  
  3. \ Filter for the result from 'grep' on definition lines in forth-83
  4. \ source code. Assumes the syntax:
  5. \     <filename> <type> <entryname> <stackcomment>
  6. \ and will reorder the symbols to the following form:
  7. \    <entryname> <stackcomment> <filename>
  8. \ The <filename> contains the directory, file, and source code line.
  9.  
  10. string forth definitions
  11.  
  12. \ String variables for scanned symbols
  13.  
  14. 128 constant file-name-size ( -- num)
  15. create file-name ( -- str) file-name-size allot
  16.  
  17. 128 constant entry-name-size ( -- num)
  18. create entry-name ( -- str) entry-name-size allot
  19.  
  20. 128 constant stack-comment-size ( -- num)
  21. create stack-comment ( -- str) stack-comment-size allot
  22.  
  23. \ Utility string functions
  24.  
  25. : $assign ( str1 str2 -- )
  26.   0 over c! $cat
  27. ;
  28.  
  29. : $more ( str -- bool)
  30.   c@
  31. ;
  32.  
  33. \ Scanning functions for file and entry name, and stack comment
  34. \ Build the corresponding output symbols
  35.  
  36. : scan-file-name ( -- )
  37.   32 word
  38.   dup c@ 
  39.   if dup
  40.     begin 1+ dup c@ ascii : = until
  41.     begin 1+ dup c@ ascii : = until
  42.     0 swap c!
  43.   then
  44.   file-name $assign
  45. ;
  46.  
  47. : scan-entry-name ( -- )
  48.   ascii ( word
  49.   dup >r
  50.   dup $length +
  51.   begin 1- dup c@ 32 = not over r@ = or until
  52.   0 over 1+ c!
  53.   dup r@ >
  54.   if begin dup c@ 32 = over r@ = or not while 1- repeat
  55.     dup c@ 32 = if 1+ then
  56.   then
  57.   entry-name $assign
  58.   r> drop
  59. ;
  60.  
  61. : scan-stack-comment ( -- )
  62.   " ( " stack-comment $assign
  63.   ascii ) word stack-comment $cat
  64.   " )" stack-comment $cat
  65. ;
  66.  
  67. : scan-end-of-line ( -- )
  68.   begin key 10 = until
  69. ;
  70.  
  71. \ Index generation function. The application start symbol
  72.  
  73. : index ( -- )
  74.   begin
  75.     scan-file-name
  76.     file-name $more
  77.   while
  78.     scan-entry-name
  79.     entry-name $more
  80.     if scan-stack-comment
  81.       entry-name $print space
  82.       stack-comment $print space
  83.       file-name $print cr
  84.     then
  85.     scan-end-of-line
  86.   repeat
  87. ;
  88.  
  89.  
  90. forth only
  91.