* Re: adatags?
1997-09-11 0:00 adatags? Oliver Kiddle
@ 1997-09-11 0:00 ` Tucker Taft
1997-09-12 0:00 ` adatags? David Wheeler
1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1997-09-11 0:00 UTC (permalink / raw)
Oliver Kiddle (opk101@york.ac.uk) wrote:
: Does anyone know if there is a program like ctags except for Ada. A
: friend of mine thinks that there was such a program, called adatags
: which was posted to this group a while ago. I've tried, archie, ftp
: search, several web searches and have searched the PAL and Ada home
: pages with no success.
Here is my personal version of "adatags". Use it as you see fit.
Note that there are two "awk" scripts as well, adatags.inx and adatags.awk.
Adatags allows you to use the name in all lower case, or in the same
case as was used at the point of declaration. It creates entries
for all program units and all types.
It is of course confused by overloading ;-).
-Tucker Taft stt@inmet.com
Intermetrics, Inc.
Burlington, MA
------------------------ adatags ---------------------
#!/bin/csh -f
set args = ()
foreach a ($*)
switch ($a)
case "-a":
set appflg
breaksw
case "-x":
set indexflg
breaksw
case "-u":
set updateflg
breaksw
case "-*":
echo "$a : Unrecognized switch"
set args = ()
break
default:
set args = ($args $a)
breaksw
endsw
end
set mypath = $0
set myname = $mypath:t
set mydir = $mypath:h
if ($mydir == $mypath) set mydir = "."
if ($#args == 0) then
echo "Usage: $myname [ -a -x -u ] file ..."
exit -1
endif
if ($?indexflg) then
awk -f $mydir/adatags.inx $args | sort
exit 0
endif
if ($?updateflg) then
echo >> tags
set sedargs = ""
foreach a ($args)
set sedargs = ($sedargs:q -e "/ $a ?/d")
end
sed $sedargs:q tags > tags.$$
mv tags.$$ tags
set appflg
endif
if ($?appflg) then
awk -f $mydir/adatags.awk $args | sort tags - > tags.$$
mv tags.$$ tags
else
awk -f $mydir/adatags.awk $args | sort > tags
endif
--------------------- adatags.awk -------------------------
BEGIN {
low["A"] = "a"
low["B"] = "b"
low["C"] = "c"
low["D"] = "d"
low["E"] = "e"
low["F"] = "f"
low["G"] = "g"
low["H"] = "h"
low["I"] = "i"
low["J"] = "j"
low["K"] = "k"
low["L"] = "l"
low["M"] = "m"
low["N"] = "n"
low["O"] = "o"
low["P"] = "p"
low["Q"] = "q"
low["R"] = "r"
low["S"] = "s"
low["T"] = "t"
low["U"] = "u"
low["V"] = "v"
low["W"] = "w"
low["X"] = "x"
low["Y"] = "y"
low["Z"] = "z"
}
/^[ ]*([Pp]rocedure|[Ff]unction|[Tt]ask|[Pp]rotected|[Pp]ackage|[Tt]ype|[Ss]ub[Tt]ype)/ {
if ($2 ~ /^[Tt]ype$/ || $2 ~ /^[Bb]ody$/) {
id = $3
} else {
id = $2
}
split(id, idar, "(");
id = idar[1];
split(id, idar, ";");
id = idar[1];
if (id ~ /^["A-Za-z]/ && $0 !~ /is separate/) {
if (length($0) < 50) lin = $0 "$";
else lin = substr($0, 1, 50);
if (lin ~ /[?*.\\+^]/) {
newlin = "";
ln = length(lin);
for (i = 1; i <= ln; i++) {
j = substr(lin, i, 1);
if (j ~ /[?*.\\+^]/) newlin = newlin "\\" j;
else newlin = newlin j;
}
lin = newlin;
}
if (id ~ /[A-Z]/) {
newid = "";
ln = length(id);
for (i = 1; i <= ln; i++) {
j = substr(id,i,1);
if (j ~ /[A-Z]/) newid = newid low[j];
else newid = newid j;
}
printf("%s %s ?^%s?\n", newid, FILENAME, lin);
}
printf("%s %s ?^%s?\n", id, FILENAME, lin);
}
}
---------------------- adatags.inx ----------------------
{ if (FILENAME != savedfn) {
base = NR-1
savedfn = FILENAME
}
}
/^[ ]*([Pp]rocedure|[Ff]unction|[Tt]ask|[Pp]rotected|[Pp]ackage|[Tt]ype|[Ss]ub[Tt]ype)/ {
if ($2 ~ /^[Tt]ype$/ || $2 ~ /^[Bb]ody$/) {
id = $3
} else {
id = $2
}
split(id, idar, "(");
id = idar[1];
if (id ~ /[A-Za-z].*/) {
x = $1" "$2
front = sprintf("%-15s %4d %-16s", id, NR-base, FILENAME);
max = 78 - length(front);
for (i = 3; i <= NF; i++) {
y = x" "$i
if (length(y) > max) break;
x = y
}
print front, x;
}
}
----------------------------- end of adatags.inx ----------------
: Cheers
: Oliver Kiddle
: --
: __
: / \|. _ _ |_/. _| _|| _ E-mail: opk101@york.ac.uk
: \__/||\/(-| | \|(_|(_||(- Web: http://www.york.ac.uk/~opk101/
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: adatags?
1997-09-11 0:00 adatags? Oliver Kiddle
1997-09-11 0:00 ` adatags? Tucker Taft
@ 1997-09-12 0:00 ` David Wheeler
1 sibling, 0 replies; 3+ messages in thread
From: David Wheeler @ 1997-09-12 0:00 UTC (permalink / raw)
Oliver Kiddle (opk101@york.ac.uk) wrote:
: Does anyone know if there is a program like ctags except for Ada. A
: friend of mine thinks that there was such a program, called adatags
: which was posted to this group a while ago. I've tried, archie, ftp
: search, several web searches and have searched the PAL and Ada home
: pages with no success.
The old Verdix Ada compiler included such a program (I believe it was
called a.tags). If you can't find such a program, you can probably create
a program to generate tags from the output of a cross-reference generator.
I used it and found it useful, but there's an important limitation to
this system; it doesn't handle overloaded names well.
"tags" was created for C, and C doesn't permit the same function name
to be used for different publically-accessible functions (let's ignore
"static" for the moment). This doesn't work well for any OO language
(C++, Ada95), since using the same method name is normal; it doesn't
even work when the language permits overloading with differentiation by
data types (i.e. Ada83).
--- David A. Wheeler
dwheeler@ida.org
^ permalink raw reply [flat|nested] 3+ messages in thread