4 * Copyright (c) 2000-2002, Darren Hiebert
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * This module contains functions for generating tags for LISP files.
15 #include "general.h" /* must always come first */
28 static kindOption LispKinds
[] = {
29 { TRUE
, 'f', "function", "functions" }
33 * FUNCTION DEFINITIONS
38 * look for (def or (DEF, quote or QUOTE
40 static int L_isdef (const unsigned char *strp
)
42 return ( (strp
[1] == 'd' || strp
[1] == 'D')
43 && (strp
[2] == 'e' || strp
[2] == 'E')
44 && (strp
[3] == 'f' || strp
[3] == 'F'));
47 static int L_isquote (const unsigned char *strp
)
49 return ( (*(++strp
) == 'q' || *strp
== 'Q')
50 && (*(++strp
) == 'u' || *strp
== 'U')
51 && (*(++strp
) == 'o' || *strp
== 'O')
52 && (*(++strp
) == 't' || *strp
== 'T')
53 && (*(++strp
) == 'e' || *strp
== 'E')
54 && isspace (*(++strp
)));
57 static void L_getit (vString
*const name
, const unsigned char *dbp
)
59 const unsigned char *p
;
61 if (*dbp
== '\'') /* Skip prefix quote */
63 else if (*dbp
== '(' && L_isquote (dbp
)) /* Skip "(quote " */
66 while (isspace (*dbp
))
69 for (p
=dbp
; *p
!='\0' && *p
!='(' && !isspace ((int) *p
) && *p
!=')' ; p
++)
70 vStringPut (name
, *p
);
71 vStringTerminate (name
);
73 if (vStringLength (name
) > 0)
74 makeSimpleTag (name
, LispKinds
, K_FUNCTION
);
78 /* Algorithm adapted from from GNU etags.
80 static void findLispTags (void)
82 vString
*name
= vStringNew ();
83 const unsigned char* p
;
86 while ((p
= fileReadLine ()) != NULL
)
92 while (*p
!= '\0' && !isspace ((int) *p
))
94 while (isspace ((int) *p
))
100 /* Check for (foo::defmumble name-defined ... */
103 while (*p
!= '\0' && !isspace ((int) *p
)
104 && *p
!= ':' && *p
!= '(' && *p
!= ')');
113 while (*p
!= '\0' && !isspace ((int) *p
))
123 vStringDelete (name
);
126 extern parserDefinition
* LispParser (void)
128 static const char *const extensions
[] = {
129 "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL
131 parserDefinition
* def
= parserNew ("Lisp");
132 def
->kinds
= LispKinds
;
133 def
->kindCount
= KIND_COUNT (LispKinds
);
134 def
->extensions
= extensions
;
135 def
->parser
= findLispTags
;
139 /* vi:set tabstop=4 shiftwidth=4: */