summaryrefslogtreecommitdiff
path: root/ipl/progs/roffcmds.icn
blob: bfeb1539c63337b6e6851b0b0d337dfe2c4a0550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
############################################################################
#
#	File:     roffcmds.icn
#
#	Subject:  Program to list roff commands and macros
#
#	Author:   Ralph E. Griswold
#
#	Date:     June 10, 1988
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#  
#     This progam processes standard input and writes a tabulation of
#  nroff/troff commands and defined strings to standard output.
#  
#  Limitations:
#  
#     This program only recognizes commands that appear at the beginning of
#  lines and does not attempt to unravel conditional constructions.
#  Similarly, defined strings buried in disguised form in definitions are
#  not recognized.
#  
#  Reference:
#  
#     Nroff/Troff User's Manual, Joseph F. Ossana, Bell Laboratories,
#  Murray Hill, New Jersey. October 11, 1976.
#  
############################################################################

procedure main()
   local line, con, mac, y, nonpuncs, i, inname, infile, outname, outfile

   nonpuncs := ~'. \t\\'

   con := table(0)
   mac := table(0)
   while line := read() do {
      line ? if tab(any('.\'')) then
         con[tab(any(nonpuncs)) || (tab(upto(' ') | 0))] +:= 1
      line ? while tab((i := find("\\")) + 1) do {
      case move(1) of {
      "(":   move(2)
      "*" | "f" | "n":  if ="(" then move(2) else move(1)
      }
      mac[&subject[i:&pos]] +:= 1
      }
   }
   con := sort(con,3)
   write(,"Commands:\n")
   while write(,get(con),"\t",get(con))
   mac := sort(mac,3)
   write(,"\nControls:\n")
   while write(,get(mac),"\t",get(mac))

end