~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to sdk/codelite_indexer/libctags/asp.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-02-10 02:27:55 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20090210022755-mxlvij3ndab1n5ty
Tags: upstream-1.0.2759+dfsg
ImportĀ upstreamĀ versionĀ 1.0.2759+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*   $Id: asp.c,v 1.8 2006/05/30 04:37:11 darren Exp $
 
3
*
 
4
*   Copyright (c) 2000, Patrick Dehne <patrick@steidle.net>
 
5
*
 
6
*   This source code is released for free distribution under the terms of the
 
7
*   GNU General Public License.
 
8
*
 
9
*   This module contains functions for generating tags for the ASP (Active
 
10
*   Server Pages) web page scripting language.
 
11
*/
 
12
 
 
13
/*
 
14
*   INCLUDE FILES
 
15
*/
 
16
#include "general.h"  /* must always come first */
 
17
 
 
18
#include <string.h>
 
19
 
 
20
#include "parse.h"
 
21
#include "read.h"
 
22
#include "vstring.h"
 
23
 
 
24
/*
 
25
*   DATA DEFINITIONS
 
26
*/
 
27
typedef enum {
 
28
        K_CONST, K_FUNCTION, K_SUB, K_DIM
 
29
} aspKind;
 
30
 
 
31
static kindOption AspKinds [] = {
 
32
        { TRUE, 'c', "constant",   "constants"},
 
33
        { TRUE, 'f', "function",   "functions"},
 
34
        { TRUE, 's', "subroutine", "subroutines"},
 
35
        { TRUE, 'v', "variable",   "variables"}
 
36
};
 
37
 
 
38
/*
 
39
*   FUNCTION DEFINITIONS
 
40
*/
 
41
 
 
42
static void findAspTags (void)
 
43
{
 
44
        vString *name = vStringNew ();
 
45
        const unsigned char *line;
 
46
 
 
47
        while ((line = fileReadLine ()) != NULL)
 
48
        {
 
49
                const unsigned char *cp = line;
 
50
 
 
51
                while (*cp != '\0')
 
52
                {
 
53
                        /* jump over whitespace */
 
54
                        while (isspace ((int)*cp))
 
55
                                cp++;
 
56
 
 
57
                        /* jump over strings */
 
58
                        if (*cp == '"')
 
59
                        {
 
60
                                cp++;
 
61
                                while (*cp!='"' && *cp!='\0')
 
62
                                        cp++;
 
63
                        }
 
64
 
 
65
                        /* jump over comments */ 
 
66
                        else if (*cp == '\'')
 
67
                                break;
 
68
                        
 
69
                        /* jump over end function/sub lines */
 
70
                        else if (strncasecmp ((const char*) cp, "end", (size_t) 3)== 0)
 
71
                        {
 
72
                                cp += 3;
 
73
                                if (isspace ((int)*cp))
 
74
                                {
 
75
                                        while (isspace ((int)*cp))
 
76
                                                ++cp;
 
77
 
 
78
                                        if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
 
79
                                        {
 
80
                                                cp+=8;
 
81
                                                break;
 
82
                                        }
 
83
 
 
84
                                        else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
 
85
                                        {
 
86
                                                cp+=3;
 
87
                                                break;
 
88
                                        }
 
89
                                }
 
90
                        }
 
91
 
 
92
                        /* jump over exit function/sub lines */
 
93
                        else if (strncasecmp ((const char*) cp, "exit", (size_t) 4)==0)
 
94
                        {
 
95
                                cp += 4;
 
96
                                if (isspace ((int) *cp))
 
97
                                {
 
98
                                        while (isspace ((int) *cp))
 
99
                                                ++cp;
 
100
 
 
101
                                        if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
 
102
                                        {
 
103
                                                cp+=8;
 
104
                                                break;
 
105
                                        }
 
106
 
 
107
                                        else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
 
108
                                        {
 
109
                                                cp+=3;
 
110
                                                break;
 
111
                                        }
 
112
                                }
 
113
                        }
 
114
 
 
115
                        /* function? */
 
116
                        else if (strncasecmp ((const char*) cp, "function", (size_t) 8) == 0)
 
117
                        {
 
118
                                cp += 8;
 
119
 
 
120
                                if (isspace ((int) *cp))
 
121
                                {
 
122
                                        while (isspace ((int) *cp))
 
123
                                                ++cp;
 
124
                                        while (isalnum ((int) *cp)  ||  *cp == '_')
 
125
                                        {
 
126
                                                vStringPut (name, (int) *cp);
 
127
                                                ++cp;
 
128
                                        }
 
129
                                        vStringTerminate (name);
 
130
                                        makeSimpleTag (name, AspKinds, K_FUNCTION);
 
131
                                        vStringClear (name);
 
132
                                }
 
133
                        }
 
134
 
 
135
                        /* sub? */
 
136
                        else if (strncasecmp ((const char*) cp, "sub", (size_t) 3) == 0)
 
137
                        {
 
138
                                cp += 3;
 
139
                                if (isspace ((int) *cp))
 
140
                                {
 
141
                                        while (isspace ((int) *cp))
 
142
                                                ++cp;
 
143
                                        while (isalnum ((int) *cp)  ||  *cp == '_')
 
144
                                        {
 
145
                                                vStringPut (name, (int) *cp);
 
146
                                                ++cp;
 
147
                                        }
 
148
                                        vStringTerminate (name);
 
149
                                        makeSimpleTag (name, AspKinds, K_SUB);
 
150
                                        vStringClear (name);
 
151
                                }
 
152
                        }
 
153
 
 
154
                        /* dim variable? */
 
155
                        else if (strncasecmp ((const char*) cp, "dim", (size_t) 3) == 0)
 
156
                        {
 
157
                                cp += 3;
 
158
                                if (isspace ((int) *cp))
 
159
                                {
 
160
                                        while (isspace ((int) *cp))
 
161
                                                ++cp;
 
162
                                        while (isalnum ((int) *cp)  ||  *cp == '_')
 
163
                                        {
 
164
                                                vStringPut (name, (int) *cp);
 
165
                                                ++cp;
 
166
                                        }
 
167
                                        vStringTerminate (name);
 
168
                                        makeSimpleTag (name, AspKinds, K_DIM);
 
169
                                        vStringClear (name);
 
170
                                }
 
171
                        }
 
172
 
 
173
                        /* const declaration? */
 
174
                        else if (strncasecmp ((const char*) cp, "const", (size_t) 5) == 0)
 
175
                        {
 
176
                                cp += 5;
 
177
                                if (isspace ((int) *cp))
 
178
                                {
 
179
                                        while (isspace ((int) *cp))
 
180
                                                ++cp;
 
181
                                        while (isalnum ((int) *cp)  ||  *cp == '_')
 
182
                                        {
 
183
                                                vStringPut (name, (int) *cp);
 
184
                                                ++cp;
 
185
                                        }
 
186
                                        vStringTerminate (name);
 
187
                                        makeSimpleTag (name, AspKinds, K_CONST);
 
188
                                        vStringClear (name);
 
189
                                }
 
190
                        }
 
191
 
 
192
                        /* nothing relevant */
 
193
                        else if (*cp != '\0')
 
194
                                cp++;
 
195
                }
 
196
        }
 
197
        vStringDelete (name);
 
198
}
 
199
 
 
200
extern parserDefinition* AspParser (void)
 
201
{
 
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;
 
209
}
 
210
 
 
211
/* vi:set tabstop=4 shiftwidth=4: */