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 Scheme language
16 #include "general.h" /* must always come first */
31 static kindOption SchemeKinds
[] = {
32 { TRUE
, 'f', "function", "functions" },
33 { TRUE
, 's', "set", "sets" }
37 * FUNCTION DEFINITIONS
40 /* Algorithm adapted from from GNU etags.
41 * Scheme tag functions
42 * look for (def... xyzzy
43 * look for (def... (xyzzy
44 * look for (def ... ((... (xyzzy ....
45 * look for (set! xyzzy
47 static void readIdentifier (vString
*const name
, const unsigned char *cp
)
49 const unsigned char *p
;
51 /* Go till you get to white space or a syntactic break */
52 for (p
= cp
; *p
!= '\0' && *p
!= '(' && *p
!= ')' && !isspace (*p
); p
++)
53 vStringPut (name
, (int) *p
);
54 vStringTerminate (name
);
57 static void findSchemeTags (void)
59 vString
*name
= vStringNew ();
60 const unsigned char *line
;
62 while ((line
= fileReadLine ()) != NULL
)
64 const unsigned char *cp
= line
;
67 (cp
[1] == 'D' || cp
[1] == 'd') &&
68 (cp
[2] == 'E' || cp
[2] == 'e') &&
69 (cp
[3] == 'F' || cp
[3] == 'f'))
71 while (!isspace (*cp
))
73 /* Skip over open parens and white space */
74 while (*cp
!= '\0' && (isspace (*cp
) || *cp
== '('))
76 readIdentifier (name
, cp
);
77 makeSimpleTag (name
, SchemeKinds
, K_FUNCTION
);
80 (cp
[1] == 'S' || cp
[1] == 's') &&
81 (cp
[2] == 'E' || cp
[2] == 'e') &&
82 (cp
[3] == 'T' || cp
[3] == 't') &&
83 (cp
[4] == '!' || cp
[4] == '!') &&
86 while (*cp
!= '\0' && !isspace (*cp
))
88 /* Skip over white space */
91 readIdentifier (name
, cp
);
92 makeSimpleTag (name
, SchemeKinds
, K_SET
);
98 extern parserDefinition
* SchemeParser (void)
100 static const char *const extensions
[] = {
101 "SCM", "SM", "sch", "scheme", "scm", "sm", NULL
103 parserDefinition
* def
= parserNew ("Scheme");
104 def
->kinds
= SchemeKinds
;
105 def
->kindCount
= KIND_COUNT (SchemeKinds
);
106 def
->extensions
= extensions
;
107 def
->parser
= findSchemeTags
;
111 /* vi:set tabstop=4 shiftwidth=4: */