2
* Copyright (c) 2007, Ritchie Turner
4
* This source code is released for free distribution under the terms of the
5
* GNU General Public License.
13
#include "general.h" /* must always come first */
14
#include <ctype.h> /* to define isalpha () */
30
#define isType(token,t) (boolean) ((token)->type == (t))
31
#define isKeyword(token,k) (boolean) ((token)->keyword == (k))
37
/*static jmp_buf Exception;*/
49
static kindOption HxKinds [] = {
50
{ TRUE, 'm', "method", "methods" },
51
{ TRUE, 'c', "class", "classes" },
52
{ TRUE, 'e', "enum", "enumerations" },
53
{ TRUE, 'v', "variable", "variables" },
54
{ TRUE, 'i', "interface", "interfaces" },
55
{ TRUE, 't', "typedef", "typedefs" },
58
static void findHxTags (void)
60
vString *name = vStringNew ();
61
vString *clsName = vStringNew();
62
vString *scope2 = vStringNew();
63
vString *laccess = vStringNew();
64
const char *const priv = "private";
65
const char *const pub = "public";
67
const unsigned char *line;
69
while ((line = fileReadLine ()) != NULL)
71
const unsigned char *cp = line;
76
vStringCopyS(laccess,priv);
78
if (strncmp ((const char*) cp, "var", (size_t) 3) == 0 &&
79
isspace ((int) cp [3]))
83
while (isspace ((int) *cp))
87
while (isalnum ((int) *cp) || *cp == '_')
89
vStringPut (name, (int) *cp);
92
vStringTerminate (name);
93
makeSimpleTag (name, HxKinds, HXTAG_VARIABLE);
95
makeSimpleScopedTag(name, HxKinds,
96
HXTAG_VARIABLE,vStringValue(clsName),
97
strdup(vStringValue(scope2)),strdup(vStringValue(laccess)));
102
else if (strncmp ((const char*) cp, "function", (size_t) 8) == 0 &&
103
isspace ((int) cp [8]))
107
while (isspace ((int) *cp))
111
while (isalnum ((int) *cp) || *cp == '_')
113
vStringPut (name, (int) *cp);
116
vStringTerminate (name);
117
makeSimpleTag (name, HxKinds, HXTAG_METHODS);
119
makeSimpleScopedTag(name, HxKinds, HXTAG_METHODS,
120
strdup(vStringValue(clsName)),strdup(vStringValue(scope2)),strdup(vStringValue(laccess)));
126
else if (strncmp ((const char*) cp, "class", (size_t) 5) == 0 &&
127
isspace ((int) cp [5]))
131
while (isspace ((int) *cp))
134
while (isalnum ((int) *cp) || *cp == '_')
136
vStringPut (name, (int) *cp);
139
vStringTerminate (name);
140
makeSimpleTag (name, HxKinds, HXTAG_CLASS);
141
vStringCopy(clsName,name);
144
else if (strncmp ((const char*) cp, "enum", (size_t) 4) == 0 &&
145
isspace ((int) cp [4]))
149
while (isspace ((int) *cp))
152
while (isalnum ((int) *cp) || *cp == '_')
154
vStringPut (name, (int) *cp);
157
vStringTerminate (name);
158
makeSimpleTag (name, HxKinds, HXTAG_ENUM);
160
} else if (strncmp ((const char*) cp, "public", (size_t) 6) == 0 &&
161
isspace((int) cp [6]))
164
while (isspace ((int) *cp))
166
vStringCopyS(laccess,pub);
168
} else if (strncmp ((const char*) cp, "static", (size_t) 6) == 0 &&
169
isspace((int) cp [6]))
172
while (isspace ((int) *cp))
175
} else if (strncmp ((const char*) cp, "interface", (size_t) 9) == 0 &&
176
isspace((int) cp [9]))
180
while (isspace ((int) *cp))
183
while (isalnum ((int) *cp) || *cp == '_') {
184
vStringPut (name, (int) *cp);
187
vStringTerminate (name);
188
makeSimpleTag (name, HxKinds, HXTAG_INTERFACE);
190
} else if (strncmp ((const char *) cp,"typedef",(size_t) 7) == 0 && isspace(((int) cp[7]))) {
193
while (isspace ((int) *cp))
196
while (isalnum ((int) *cp) || *cp == '_') {
197
vStringPut (name, (int) *cp);
200
vStringTerminate (name);
201
makeSimpleTag (name, HxKinds, HXTAG_TYPEDEF);
209
vStringDelete(clsName);
210
vStringDelete(scope2);
211
vStringDelete(laccess);
215
/* Create parser definition stucture */
216
extern parserDefinition* HaxeParser (void)
218
static const char *const extensions [] = { "hx", NULL };
220
parserDefinition *const def = parserNew ("Haxe");
221
def->extensions = extensions;
223
* New definitions for parsing instead of regex
225
def->kinds = HxKinds;
226
def->kindCount = KIND_COUNT (HxKinds);
227
def->parser = findHxTags;
228
/*def->initialize = initialize;*/