comp.lang.ada
 help / color / mirror / Atom feed
* Is there an ada specific version of ctags?
@ 1996-09-12  0:00 Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
  1996-09-13  0:00 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Sherrill <joel@merlin.gcs.redstone.army.mil> @ 1996-09-12  0:00 UTC (permalink / raw)




I am looking for a program like ctags which is for Ada.  I checked the faq and the home
of the brave but came up empty handed.

Thanks in advance.


+----------------------------------------+--------------------------------+
| Joel Sherrill                          | Sr. Computer Scientist         |
| joel@merlin.gcs.redstone.army.mil      | On-Line Applications Research  |
| Ask me about RTEMS: a free real-time   | Huntsville AL 35805            |
|   multiprocessor executive!            | (205) 883-0131                 |
+----------------------------------------+--------------------------------+







^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is there an ada specific version of ctags?
  1996-09-12  0:00 Is there an ada specific version of ctags? Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
@ 1996-09-13  0:00 ` Tucker Taft
  0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1996-09-13  0:00 UTC (permalink / raw)



Joel Sherrill <joel@merlin.gcs.redstone.army.mil> 
  (joel@redstone.army.mil) wrote:

: I am looking for a program like ctags which is for Ada.  I checked 
: the faq and the home of the brave but came up empty handed.

I have included a very simple one below.  Note that it produces a "vi"
tags file, not one for emacs, and consists of a cshell script and 
two awk programs, and uses "sed" as well.  The same logic could be 
translated to any number of other scripting languages, or written in Ada 
itself.  A few comments wouldn't hurt either ;-).

It might be nice to see these migrate to one of the web-sites (which
would be fine with me -- this is definitely freeware).

: | Joel Sherrill                          | Sr. Computer Scientist         |
: | joel@merlin.gcs.redstone.army.mil      | On-Line Applications Research  |
: | Ask me about RTEMS: a free real-time   | Huntsville AL 35805            |
: |   multiprocessor executive!            | (205) 883-0131                 |

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Cambridge, MA  USA

--------------- 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;
  }
}




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-09-13  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-12  0:00 Is there an ada specific version of ctags? Joel Sherrill <joel@merlin.gcs.redstone.army.mil>
1996-09-13  0:00 ` Tucker Taft

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