From windley@cheetah  Wed Sep 20 14:08:34 1989
Received: by iris (5.57/3.14)
        id AA00129; Wed, 20 Sep 89 14:08:34 PDT
Received: from cheetah.ucdavis.edu by clover.ucdavis.edu (5.59/UCD.EECS.1.11)
        id AA24131; Wed, 20 Sep 89 13:35:34 PDT
Received: by cheetah.ucdavis.edu (AIX  2.1.2/3.14)
        id AA04420; Wed, 20 Sep 89 13:33:13 PDT
Message-Id: <8909202033.AA04420@cheetah.ucdavis.edu>
To: info-hol@clover
Subject: etags for HOL
Date: Wed, 20 Sep 89 13:33:12 -0800
From: Phil Windley <windley@cheetah>


If you have used ctags, especially from within emacs, you have probably
wished that it worked for ML and HOL files as well.  Ctags can be used to
create indexes for collections of files.  Inside emacs, you can use a tags
file to find and automatically visit the file and location of any symbol in
the tag file.

I have modified the GNU distributed etags.c (ver 18.55) so that it
recognizes files with .ml, .sml, or .hol extensions and creates tag files
for them.

The full source for etags (as modified) is available via anonymous ftp from
clover.ucdavis.edu.  I will include the diff output at the end of this file
for those without access to ftp.

--phil--

Phil Windley                          |  windley@iris.ucdavis.edu
Division of Computer Science          |  ucbvax!ucdavis!iris!windley
College of Engineering                |  (916) 752-7324 (or 3168)
University of California, Davis       |  Davis, CA 95616



Use the line:

cc -o etags -DETAGS etags.c

to compile the etags.c file.

---------------------- diff output --------------------------------
94a95,100
> /*
>
> Changed to add syntax functions for HOL/ml by PJWindley (20SEP89)
>
> */
>
535a542,553
>   /* .ml or .sml or .hol implies HOL/ml source code */
>   if (cp && (!strcmp (cp + 1, "ml")
>            || !strcmp (cp + 1, "sml")
>            || !strcmp (cp + 1, "hol")
>            || !strcmp (cp + 1, "ML")
>            || !strcmp (cp + 1, "SML")
>            || !strcmp (cp + 1, "HOL")))
>     {
>       HOL_funcs(inf);
>       fclose(inf);
>       return;
>     }
1200a1219,1274
>     continue;
>   c = cp[0];
>   cp[0] = 0;
>   strcpy(nambuf, dbp);
>   cp[0] = c;
>   pfnote(nambuf, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
>   pfcnt++;
> }
> 
> /*
>  * HOL/ml tag functions
>  * just look for let (LET is not defined) or
>  *               letrec
>  */
>
> HOL_funcs (fi)
>      FILE *fi;
> {
>   lineno = 0;
>   charno = 0;
>   pfcnt = 0;
>
>   while (!feof (fi))
>     {
>       lineno++;
>       linecharno = charno;
>       charno += readline (&lb, fi) + 1;
>       dbp = lb.buffer;
>       if ((dbp[0] == 'l' &&
>          (dbp[1] == 'e') &&
>            (dbp[2] == 't') &&
>              (dbp[3] == ' ')) ||
>         (dbp[0] == 'l' &&
>          (dbp[1] == 'e') &&
>            (dbp[2] == 't') &&
>              (dbp[3] == 'r') &&
>                (dbp[4] == 'e') &&
>                  (dbp[5] == 'c')))
>       {
>         while (!isspace(*dbp)) dbp++;
>         while (isspace(*dbp)) dbp++;
>         HOL_getit();
>       }
>     }
> }
> HOL_getit()
> {
>   register char *cp;
>   char c;
>   char nambuf[BUFSIZ];
>
>   while (isspace(*dbp))
>     dbp++;
>   if (*dbp == 0 || !isalpha(*dbp))
>     return;
>   for (cp = dbp+1; *cp && (isalpha(*cp) || isdigit(*cp) || (*cp == '_')); cp++)

