comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: adatags?
Date: 1997/09/11
Date: 1997-09-11T00:00:00+00:00	[thread overview]
Message-ID: <EGCM7F.2MM.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 5v8k6n$pbs$1@netty.york.ac.uk


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




  reply	other threads:[~1997-09-11  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-11  0:00 adatags? Oliver Kiddle
1997-09-11  0:00 ` Tucker Taft [this message]
1997-09-12  0:00 ` adatags? David Wheeler
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox