Merge commit 'git-svn'
[anjuta-git-plugin.git] / tagmanager / asp.c
blob3b4e3e66092814152e8ca007894484dbf3899c33
1 /*
2 * $Id$
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_FUNCTION, K_SUB, K_DIM
29 } aspKind;
31 static kindOption AspKinds [] = {
32 { TRUE, 'c', "constant", "constants"},
33 { TRUE, 'f', "function", "functions"},
34 { TRUE, 's', "subroutine", "subroutines"},
35 { TRUE, 'v', "variable", "variables"}
39 * FUNCTION DEFINITIONS
42 static void findAspTags (void)
44 vString *name = vStringNew ();
45 const unsigned char *line;
47 while ((line = fileReadLine ()) != NULL)
49 const unsigned char *cp = line;
51 while (*cp != '\0')
53 /* jump over whitespace */
54 while (isspace ((int)*cp))
55 cp++;
57 /* jump over strings */
58 if (*cp == '"')
60 cp++;
61 while (*cp!='"' && *cp!='\0')
62 cp++;
65 /* jump over comments */
66 else if (*cp == '\'')
67 break;
69 /* jump over end function/sub lines */
70 else if (strncasecmp ((const char*) cp, "end", (size_t) 3)== 0)
72 cp += 3;
73 if (isspace ((int)*cp))
75 while (isspace ((int)*cp))
76 ++cp;
78 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
80 cp+=8;
81 break;
84 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
86 cp+=3;
87 break;
92 /* jump over exit function/sub lines */
93 else if (strncasecmp ((const char*) cp, "exit", (size_t) 4)==0)
95 cp += 4;
96 if (isspace ((int) *cp))
98 while (isspace ((int) *cp))
99 ++cp;
101 if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
103 cp+=8;
104 break;
107 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
109 cp+=3;
110 break;
115 /* function? */
116 else if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
118 cp += 8;
120 if (isspace ((int) *cp))
122 while (isspace ((int) *cp))
123 ++cp;
124 while (isalnum ((int) *cp) || *cp == '_')
126 vStringPut (name, (int) *cp);
127 ++cp;
129 vStringTerminate (name);
130 makeSimpleTag (name, AspKinds, K_FUNCTION);
131 vStringClear (name);
135 /* sub? */
136 else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
138 cp += 3;
139 if (isspace ((int) *cp))
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);
154 /* dim variable? */
155 else if (strncasecmp ((const char*) cp, "dim", (size_t) 3) == 0)
157 cp += 3;
158 if (isspace ((int) *cp))
160 while (isspace ((int) *cp))
161 ++cp;
162 while (isalnum ((int) *cp) || *cp == '_')
164 vStringPut (name, (int) *cp);
165 ++cp;
167 vStringTerminate (name);
168 makeSimpleTag (name, AspKinds, K_DIM);
169 vStringClear (name);
173 /* const declaration? */
174 else if (strncasecmp ((const char*) cp, "const", (size_t) 5) == 0)
176 cp += 5;
177 if (isspace ((int) *cp))
179 while (isspace ((int) *cp))
180 ++cp;
181 while (isalnum ((int) *cp) || *cp == '_')
183 vStringPut (name, (int) *cp);
184 ++cp;
186 vStringTerminate (name);
187 makeSimpleTag (name, AspKinds, K_CONST);
188 vStringClear (name);
192 /* nothing relevant */
193 else if (*cp != '\0')
194 cp++;
197 vStringDelete (name);
200 extern parserDefinition* AspParser (void)
202 static const char *const extensions [] = { "asp", "asa", NULL };
203 parserDefinition* def = parserNew ("Asp");
204 def->kinds = AspKinds;
205 def->kindCount = KIND_COUNT (AspKinds);
206 def->extensions = extensions;
207 def->parser = findAspTags;
208 return def;
211 /* vi:set tabstop=4 shiftwidth=4: */