2 * $Id: asp.c 711 2009-07-04 16:52:11Z dhiebert $
4 * Copyright (c) 2000, Patrick Dehne <patrick@steidle.net>
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 the ASP (Active
10 * Server Pages) web page scripting language.
16 #include "general.h" /* must always come first */
28 K_CONST
, K_CLASS
, K_FUNCTION
, K_SUB
, K_DIM
31 static kindOption AspKinds
[] = {
32 { TRUE
, 'd', "constant", "constants"},
33 { TRUE
, 'c', "class", "classes"},
34 { TRUE
, 'f', "function", "functions"},
35 { TRUE
, 's', "subroutine", "subroutines"},
36 { TRUE
, 'v', "variable", "variables"}
40 * FUNCTION DEFINITIONS
43 static void findAspTags (void)
45 vString
*name
= vStringNew ();
46 const unsigned char *line
;
48 while ((line
= fileReadLine ()) != NULL
)
50 const unsigned char *cp
= line
;
54 /* jump over whitespace */
55 while (isspace ((int)*cp
))
58 /* jump over strings */
62 while (*cp
!='"' && *cp
!='\0')
66 /* jump over comments */
70 /* jump over end function/sub lines */
71 else if (strncasecmp ((const char*) cp
, "end", (size_t) 3)== 0)
74 if (isspace ((int)*cp
))
76 while (isspace ((int)*cp
))
79 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0)
85 else if (strncasecmp ((const char*) cp
, "sub", (size_t) 3) == 0)
93 /* jump over exit function/sub lines */
94 else if (strncasecmp ((const char*) cp
, "exit", (size_t) 4)==0)
97 if (isspace ((int) *cp
))
99 while (isspace ((int) *cp
))
102 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0)
108 else if (strncasecmp ((const char*) cp
, "sub", (size_t) 3) == 0)
117 else if (strncasecmp ((const char*) cp
, "public", (size_t) 6) == 0)
120 if (isspace ((int) *cp
))
122 while (isspace ((int) *cp
))
124 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0)
127 while (isspace ((int) *cp
))
129 while (isalnum ((int) *cp
) || *cp
== '_')
131 vStringPut (name
, (int) *cp
);
134 vStringTerminate (name
);
135 makeSimpleTag (name
, AspKinds
, K_FUNCTION
);
138 else if (strncasecmp ((const char*) cp
, "sub", (size_t) 3) == 0)
141 while (isspace ((int) *cp
))
143 while (isalnum ((int) *cp
) || *cp
== '_')
145 vStringPut (name
, (int) *cp
);
148 vStringTerminate (name
);
149 makeSimpleTag (name
, AspKinds
, K_SUB
);
153 while (isalnum ((int) *cp
) || *cp
== '_')
155 vStringPut (name
, (int) *cp
);
158 vStringTerminate (name
);
159 makeSimpleTag (name
, AspKinds
, K_DIM
);
164 else if (strncasecmp ((const char*) cp
, "private", (size_t) 7) == 0)
167 if (isspace ((int) *cp
))
169 while (isspace ((int) *cp
))
171 if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0)
174 while (isspace ((int) *cp
))
176 while (isalnum ((int) *cp
) || *cp
== '_')
178 vStringPut (name
, (int) *cp
);
181 vStringTerminate (name
);
182 makeSimpleTag (name
, AspKinds
, K_FUNCTION
);
185 else if (strncasecmp ((const char*) cp
, "sub", (size_t) 3) == 0)
188 while (isspace ((int) *cp
))
190 while (isalnum ((int) *cp
) || *cp
== '_')
192 vStringPut (name
, (int) *cp
);
195 vStringTerminate (name
);
196 makeSimpleTag (name
, AspKinds
, K_SUB
);
200 while (isalnum ((int) *cp
) || *cp
== '_')
202 vStringPut (name
, (int) *cp
);
205 vStringTerminate (name
);
206 makeSimpleTag (name
, AspKinds
, K_DIM
);
213 else if (strncasecmp ((const char*) cp
, "function", (size_t) 8) == 0)
217 if (isspace ((int) *cp
))
219 while (isspace ((int) *cp
))
221 while (isalnum ((int) *cp
) || *cp
== '_')
223 vStringPut (name
, (int) *cp
);
226 vStringTerminate (name
);
227 makeSimpleTag (name
, AspKinds
, K_FUNCTION
);
233 else if (strncasecmp ((const char*) cp
, "sub", (size_t) 3) == 0)
236 if (isspace ((int) *cp
))
238 while (isspace ((int) *cp
))
240 while (isalnum ((int) *cp
) || *cp
== '_')
242 vStringPut (name
, (int) *cp
);
245 vStringTerminate (name
);
246 makeSimpleTag (name
, AspKinds
, K_SUB
);
252 else if (strncasecmp ((const char*) cp
, "dim", (size_t) 3) == 0)
255 if (isspace ((int) *cp
))
257 while (isspace ((int) *cp
))
259 while (isalnum ((int) *cp
) || *cp
== '_')
261 vStringPut (name
, (int) *cp
);
264 vStringTerminate (name
);
265 makeSimpleTag (name
, AspKinds
, K_DIM
);
270 /* class declaration? */
271 else if (strncasecmp ((const char*) cp
, "class", (size_t) 5) == 0)
274 if (isspace ((int) *cp
))
276 while (isspace ((int) *cp
))
278 while (isalnum ((int) *cp
) || *cp
== '_')
280 vStringPut (name
, (int) *cp
);
283 vStringTerminate (name
);
284 makeSimpleTag (name
, AspKinds
, K_CLASS
);
289 /* const declaration? */
290 else if (strncasecmp ((const char*) cp
, "const", (size_t) 5) == 0)
293 if (isspace ((int) *cp
))
295 while (isspace ((int) *cp
))
297 while (isalnum ((int) *cp
) || *cp
== '_')
299 vStringPut (name
, (int) *cp
);
302 vStringTerminate (name
);
303 makeSimpleTag (name
, AspKinds
, K_CONST
);
308 /* nothing relevant */
309 else if (*cp
!= '\0')
313 vStringDelete (name
);
316 extern parserDefinition
* AspParser (void)
318 static const char *const extensions
[] = { "asp", "asa", NULL
};
319 parserDefinition
* def
= parserNew ("Asp");
320 def
->kinds
= AspKinds
;
321 def
->kindCount
= KIND_COUNT (AspKinds
);
322 def
->extensions
= extensions
;
323 def
->parser
= findAspTags
;
327 /* vi:set tabstop=4 shiftwidth=4: */