3 #fptags - Create an emacs tags file for functional programs
5 #Please send me a copy of any modifications you make.
6 #Denis Howe <dbh@doc.ic.ac.uk>
7 #0.00 20-Sep-1991 created
8 #0.01 09-Apr-1992 don't count ==, <=, >= as definition
9 #0.02 09-Feb-1994 fix bug in fix 0.01. Add /=.
11 # partain: got it from wombat.doc.ic.ac.uk:pub
13 #The algorithm for spotting identifiers is crude to the point of
14 #vulgarity. Any line containing an = is assumed to define an
15 #identifier. If there are no non-white characters before the = then
16 #the definition is assumed to start on the previous line. White
17 #characters are space, tab and > (for literate programs). The =s in
18 #the relations ==, <=, >= and /= are temporarily transformed while
21 #The tags file is not in the format produced by ctags but rather,
22 #that produced by etags and used by GNU-Emacs's find-tag command.
24 #Does not tag constructors in sum data types.
26 #The tags file, TAGS, is created in the current directory. It
27 #contains an entry for each argument file. The entry begins with a
28 #line containing just ^L. The next line contains the filename, a
29 #comma and the number of following bytes before the next ^L or EOF.
30 #Subsequent lines should give the location within the argument file of
31 #identifier definitions. Each line contains a prefix of a line from
32 #the argument file, a ^?, the line number within the argument file, a
33 #comma and the position of the start of that line in the argument file
34 #(first character = 1).
36 [ -z "$1" ] && echo usage: $0 files && exit 1
44 s|/=|/
\1d|g' $f | awk '
45 /^[> ]*=/{ print prevline "
\7f" NR-1 "," prevpos; }
46 /[^> ].*=/{ print $0 "
\7f" NR "," pos; }
47 { prevline = $0; prevpos = pos; pos += length($0)+1; }
48 ' pos=1 | sed 's/[ )]*=.*
\7f/
\7f/
50 echo -n $f,; echo `wc -c < $tf` #lose spaces