Making "inline" behave like an attribute. Fixes #1
[arduino-ctags.git] / asp.c
blob7290ad88b9e3bd8bb3476202207320de82c89f7c
1 /*
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.
14 * INCLUDE FILES
16 #include "general.h" /* must always come first */
18 #include <string.h>
20 #include "parse.h"
21 #include "read.h"
22 #include "vstring.h"
25 * DATA DEFINITIONS
27 typedef enum {
28 K_CONST, K_CLASS, K_FUNCTION, K_SUB, K_DIM
29 } aspKind;
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;
52 while (*cp != '\0')
54 /* jump over whitespace */
55 while (isspace ((int)*cp))
56 cp++;
58 /* jump over strings */
59 if (*cp == '"')
61 cp++;
62 while (*cp!='"' && *cp!='\0')
63 cp++;
66 /* jump over comments */
67 else if (*cp == '\'')
68 break;
70 /* jump over end function/sub lines */
71 else if (strncasecmp ((const char*) cp, "end", (size_t) 3)== 0)
73 cp += 3;
74 if (isspace ((int)*cp))
76 while (isspace ((int)*cp))
77 ++cp;
79 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
81 cp+=8;
82 break;
85 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
87 cp+=3;
88 break;
93 /* jump over exit function/sub lines */
94 else if (strncasecmp ((const char*) cp, "exit", (size_t) 4)==0)
96 cp += 4;
97 if (isspace ((int) *cp))
99 while (isspace ((int) *cp))
100 ++cp;
102 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
104 cp+=8;
105 break;
108 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
110 cp+=3;
111 break;
116 /* class member? */
117 else if (strncasecmp ((const char*) cp, "public", (size_t) 6) == 0)
119 cp += 6;
120 if (isspace ((int) *cp))
122 while (isspace ((int) *cp))
123 ++cp;
124 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
126 cp+=8;
127 while (isspace ((int) *cp))
128 ++cp;
129 while (isalnum ((int) *cp) || *cp == '_')
131 vStringPut (name, (int) *cp);
132 ++cp;
134 vStringTerminate (name);
135 makeSimpleTag (name, AspKinds, K_FUNCTION);
136 vStringClear (name);
138 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
140 cp+=3;
141 while (isspace ((int) *cp))
142 ++cp;
143 while (isalnum ((int) *cp) || *cp == '_')
145 vStringPut (name, (int) *cp);
146 ++cp;
148 vStringTerminate (name);
149 makeSimpleTag (name, AspKinds, K_SUB);
150 vStringClear (name);
152 else {
153 while (isalnum ((int) *cp) || *cp == '_')
155 vStringPut (name, (int) *cp);
156 ++cp;
158 vStringTerminate (name);
159 makeSimpleTag (name, AspKinds, K_DIM);
160 vStringClear (name);
164 else if (strncasecmp ((const char*) cp, "private", (size_t) 7) == 0)
166 cp += 7;
167 if (isspace ((int) *cp))
169 while (isspace ((int) *cp))
170 ++cp;
171 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
173 cp+=8;
174 while (isspace ((int) *cp))
175 ++cp;
176 while (isalnum ((int) *cp) || *cp == '_')
178 vStringPut (name, (int) *cp);
179 ++cp;
181 vStringTerminate (name);
182 makeSimpleTag (name, AspKinds, K_FUNCTION);
183 vStringClear (name);
185 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
187 cp+=3;
188 while (isspace ((int) *cp))
189 ++cp;
190 while (isalnum ((int) *cp) || *cp == '_')
192 vStringPut (name, (int) *cp);
193 ++cp;
195 vStringTerminate (name);
196 makeSimpleTag (name, AspKinds, K_SUB);
197 vStringClear (name);
199 else {
200 while (isalnum ((int) *cp) || *cp == '_')
202 vStringPut (name, (int) *cp);
203 ++cp;
205 vStringTerminate (name);
206 makeSimpleTag (name, AspKinds, K_DIM);
207 vStringClear (name);
212 /* function? */
213 else if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
215 cp += 8;
217 if (isspace ((int) *cp))
219 while (isspace ((int) *cp))
220 ++cp;
221 while (isalnum ((int) *cp) || *cp == '_')
223 vStringPut (name, (int) *cp);
224 ++cp;
226 vStringTerminate (name);
227 makeSimpleTag (name, AspKinds, K_FUNCTION);
228 vStringClear (name);
232 /* sub? */
233 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
235 cp += 3;
236 if (isspace ((int) *cp))
238 while (isspace ((int) *cp))
239 ++cp;
240 while (isalnum ((int) *cp) || *cp == '_')
242 vStringPut (name, (int) *cp);
243 ++cp;
245 vStringTerminate (name);
246 makeSimpleTag (name, AspKinds, K_SUB);
247 vStringClear (name);
251 /* dim variable? */
252 else if (strncasecmp ((const char*) cp, "dim", (size_t) 3) == 0)
254 cp += 3;
255 if (isspace ((int) *cp))
257 while (isspace ((int) *cp))
258 ++cp;
259 while (isalnum ((int) *cp) || *cp == '_')
261 vStringPut (name, (int) *cp);
262 ++cp;
264 vStringTerminate (name);
265 makeSimpleTag (name, AspKinds, K_DIM);
266 vStringClear (name);
270 /* class declaration? */
271 else if (strncasecmp ((const char*) cp, "class", (size_t) 5) == 0)
273 cp += 5;
274 if (isspace ((int) *cp))
276 while (isspace ((int) *cp))
277 ++cp;
278 while (isalnum ((int) *cp) || *cp == '_')
280 vStringPut (name, (int) *cp);
281 ++cp;
283 vStringTerminate (name);
284 makeSimpleTag (name, AspKinds, K_CLASS);
285 vStringClear (name);
289 /* const declaration? */
290 else if (strncasecmp ((const char*) cp, "const", (size_t) 5) == 0)
292 cp += 5;
293 if (isspace ((int) *cp))
295 while (isspace ((int) *cp))
296 ++cp;
297 while (isalnum ((int) *cp) || *cp == '_')
299 vStringPut (name, (int) *cp);
300 ++cp;
302 vStringTerminate (name);
303 makeSimpleTag (name, AspKinds, K_CONST);
304 vStringClear (name);
308 /* nothing relevant */
309 else if (*cp != '\0')
310 cp++;
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;
324 return def;
327 /* vi:set tabstop=4 shiftwidth=4: */