home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / roffcmds.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  60 lines

  1. ############################################################################
  2. #
  3. #    File:     roffcmds.icn
  4. #
  5. #    Subject:  Program to list roff commands and macros
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 10, 1988
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #  
  17. #     This progam processes standard input and writes a tabulation of
  18. #  nroff/troff commands and defined strings to standard output.
  19. #  
  20. #  Limitations:
  21. #  
  22. #     This program only recognizes commands that appear at the beginning of
  23. #  lines and does not attempt to unravel conditional constructions.
  24. #  Similarly, defined strings buried in disguised form in definitions are
  25. #  not recognized.
  26. #  
  27. #  Reference:
  28. #  
  29. #     Nroff/Troff User's Manual, Joseph F. Ossana, Bell Laboratories,
  30. #  Murray Hill, New Jersey. October 11, 1976.
  31. #  
  32. ############################################################################
  33.  
  34. procedure main()
  35.    local line, con, mac, y, nonpuncs, i, inname, infile, outname, outfile
  36.  
  37.    nonpuncs := ~'. \t\\'
  38.  
  39.    con := table(0)
  40.    mac := table(0)
  41.    while line := read() do {
  42.       line ? if tab(any('.\'')) then
  43.          con[tab(any(nonpuncs)) || (tab(upto(' ') | 0))] +:= 1
  44.       line ? while tab((i := find("\\")) + 1) do {
  45.       case move(1) of {
  46.       "(":   move(2)
  47.       "*" | "f" | "n":  if ="(" then move(2) else move(1)
  48.       }
  49.       mac[&subject[i:&pos]] +:= 1
  50.       }
  51.    }
  52.    con := sort(con,3)
  53.    write(,"Commands:\n")
  54.    while write(,get(con),"\t",get(con))
  55.    mac := sort(mac,3)
  56.    write(,"\nControls:\n")
  57.    while write(,get(mac),"\t",get(mac))
  58.  
  59. end
  60.