aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/LuaSL/LuaSL_LSL_tree.h13
-rw-r--r--src/LuaSL/LuaSL_compile.c169
-rw-r--r--src/LuaSL/LuaSL_lemon_yaccer.y6
-rw-r--r--src/LuaSL/LuaSL_main.c28
4 files changed, 94 insertions, 122 deletions
diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h
index 5b61926..b08d1db 100644
--- a/src/LuaSL/LuaSL_LSL_tree.h
+++ b/src/LuaSL/LuaSL_LSL_tree.h
@@ -5,7 +5,7 @@
5#define LUASL_DEBUG 0 5#define LUASL_DEBUG 0
6#define COMPILE_THREADED 0 6#define COMPILE_THREADED 0
7#define LUASL_DIFF_CHECK 0 7#define LUASL_DIFF_CHECK 0
8#define LUASL_BAD_CHECK 0 8#define LUASL_BAD_CHECK 1
9 9
10 10
11#include <stddef.h> // So we can have NULL defined. 11#include <stddef.h> // So we can have NULL defined.
@@ -300,7 +300,7 @@ struct _LSL_Script
300 Eina_Hash *functions; 300 Eina_Hash *functions;
301 Eina_Hash *states; 301 Eina_Hash *states;
302 Eina_Hash *variables; 302 Eina_Hash *variables;
303 int bugCount, warningCount; 303 int warningCount;
304}; 304};
305 305
306/* Tracking variables. 306/* Tracking variables.
@@ -372,11 +372,8 @@ Need to do something about that.
372 372
373typedef struct 373typedef struct
374{ 374{
375 LuaCompiler compiler; 375 LuaCompiler *compiler;
376 void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first. 376 void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first.
377 int argc;
378 char **argv;
379 FILE *file;
380 LSL_Leaf *ast; 377 LSL_Leaf *ast;
381 LSL_Script script; 378 LSL_Script script;
382 LSL_State state; 379 LSL_State state;
@@ -390,8 +387,6 @@ typedef struct
390 int column, line; 387 int column, line;
391 int undeclared; 388 int undeclared;
392 boolean inState; 389 boolean inState;
393 boolean doConstants;
394 boolean result;
395} LuaSL_compiler; 390} LuaSL_compiler;
396 391
397 392
@@ -402,7 +397,7 @@ typedef struct
402 397
403 398
404boolean compilerSetup(gameGlobals *ourGlobals); 399boolean compilerSetup(gameGlobals *ourGlobals);
405boolean compileLSL(LuaSL_compiler *lCompiler); 400void compileLSL(LuaCompiler *compiler);
406void burnLeaf(void *data); 401void burnLeaf(void *data);
407 402
408LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 403LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index 0b27cf5..d1ef48b 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -361,8 +361,8 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf
361 } 361 }
362 else 362 else
363 { 363 {
364 compiler->script.bugCount++; 364 compiler->compiler->bugCount++;
365 sendBack(compiler->compiler.client, compiler->compiler.SID, "compilerError(%d,%d,NOT FOUND variable %s)", identifier->line, identifier->column, identifier->value.stringValue); 365 sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,NOT FOUND variable %s)", identifier->line, identifier->column, identifier->value.stringValue);
366 } 366 }
367 } 367 }
368 368
@@ -404,7 +404,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
404 if (OT_undeclared == lType) 404 if (OT_undeclared == lType)
405 { 405 {
406 compiler->script.warningCount++; 406 compiler->script.warningCount++;
407// sendBack(compiler->compiler.client, compiler->compiler.SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 407// sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
408 lval->basicType = OT_undeclared; 408 lval->basicType = OT_undeclared;
409 return lval; 409 return lval;
410 } 410 }
@@ -432,7 +432,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
432 if (OT_undeclared == rType) 432 if (OT_undeclared == rType)
433 { 433 {
434 compiler->script.warningCount++; 434 compiler->script.warningCount++;
435// sendBack(compiler->compiler.client, compiler->compiler.SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); 435// sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column);
436 lval->basicType = OT_undeclared; 436 lval->basicType = OT_undeclared;
437 return lval; 437 return lval;
438 } 438 }
@@ -632,8 +632,8 @@ else
632 rightType = allowed[right->basicType].name; 632 rightType = allowed[right->basicType].name;
633 } 633 }
634 634
635 compiler->script.bugCount++; 635 compiler->compiler->bugCount++;
636 sendBack(compiler->compiler.client, compiler->compiler.SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); 636 sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken);
637 } 637 }
638 } 638 }
639 639
@@ -1152,7 +1152,7 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow,
1152 } 1152 }
1153 default : 1153 default :
1154 { 1154 {
1155 compiler->script.bugCount++; 1155 compiler->compiler->bugCount++;
1156 PE("Should not be here %d.", stat->type); 1156 PE("Should not be here %d.", stat->type);
1157 break; 1157 break;
1158 } 1158 }
@@ -2169,14 +2169,6 @@ static void outputStringToken(FILE *file, outputMode mode, LSL_Leaf *content)
2169 fprintf(file, "%s", content->value.stringValue); // The quotes are part of the string value already. 2169 fprintf(file, "%s", content->value.stringValue); // The quotes are part of the string value already.
2170} 2170}
2171 2171
2172static void _compileCb(LuaCompiler *compiler)
2173{
2174 free(compiler->luaName);
2175 free(compiler->SID);
2176 free(compiler->file);
2177 free(compiler);
2178}
2179
2180boolean compilerSetup(gameGlobals *ourGlobals) 2172boolean compilerSetup(gameGlobals *ourGlobals)
2181{ 2173{
2182 int i; 2174 int i;
@@ -2191,7 +2183,7 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2191 if (tokens) 2183 if (tokens)
2192 { 2184 {
2193 char buf[PATH_MAX]; 2185 char buf[PATH_MAX];
2194 LuaSL_compiler *compiler = calloc(1, sizeof(LuaSL_compiler)); 2186 LuaCompiler *compiler = calloc(1, sizeof(LuaCompiler));
2195 2187
2196 // Sort the token table. 2188 // Sort the token table.
2197 for (i = 0; LSL_Tokens[i].toKen != NULL; i++) 2189 for (i = 0; LSL_Tokens[i].toKen != NULL; i++)
@@ -2205,13 +2197,11 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2205 snprintf(buf, sizeof(buf), "luajit -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", prefix_lib_get()); 2197 snprintf(buf, sizeof(buf), "luajit -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", prefix_lib_get());
2206 system(buf); 2198 system(buf);
2207 snprintf(buf, sizeof(buf), "%s/constants.lsl", prefix_lib_get()); 2199 snprintf(buf, sizeof(buf), "%s/constants.lsl", prefix_lib_get());
2208 compiler->compiler.file = strdup(buf); 2200 compiler->file = strdup(buf);
2209 compiler->compiler.SID = strdup("FAKE_SID"); 2201 compiler->SID = strdup("FAKE_SID");
2210 compiler->compiler.data = ourGlobals;
2211 compiler->compiler.cb = _compileCb;
2212 compiler->doConstants = TRUE; 2202 compiler->doConstants = TRUE;
2213 if (!compileLSL(compiler)) 2203 compiler->parser = (compileCb) compileLSL;
2214 _compileCb(&compiler->compiler); 2204 compileScript(compiler, COMPILE_THREADED);
2215 2205
2216 return TRUE; 2206 return TRUE;
2217 } 2207 }
@@ -2221,77 +2211,85 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2221 return FALSE; 2211 return FALSE;
2222} 2212}
2223 2213
2224boolean compileLSL(LuaSL_compiler *compiler) 2214void compileLSL(LuaCompiler *compiler)
2225{ 2215{
2216 LuaSL_compiler *lcompiler = calloc(1, sizeof(LuaSL_compiler));
2226 void *pParser = ParseAlloc(malloc); 2217 void *pParser = ParseAlloc(malloc);
2227#if LUASL_BAD_CHECK 2218#if LUASL_BAD_CHECK
2228 char tempName[PATH_MAX]; 2219 char tempName[PATH_MAX];
2229#endif 2220#endif
2221 FILE *in;
2230 int yv; 2222 int yv;
2231 2223
2224 lcompiler->compiler = compiler;
2225
2232// Parse the LSL script, validating it and reporting errors. 2226// Parse the LSL script, validating it and reporting errors.
2233// Just pass all LSL constants and ll*() )function names through to Lua, assume they are globals there. 2227// Just pass all LSL constants and ll*() )function names through to Lua, assume they are globals there.
2234 2228
2235 compiler->result = FALSE; 2229 lcompiler->script.functions = eina_hash_stringshared_new(burnLeaf);
2236 compiler->script.functions = eina_hash_stringshared_new(burnLeaf); 2230 lcompiler->script.states = eina_hash_stringshared_new(burnLeaf);
2237 compiler->script.states = eina_hash_stringshared_new(burnLeaf); 2231 lcompiler->script.variables = eina_hash_stringshared_new(burnLeaf);
2238 compiler->script.variables = eina_hash_stringshared_new(burnLeaf); 2232 eina_clist_init(&(lcompiler->danglingCalls));
2239 eina_clist_init(&(compiler->danglingCalls));
2240#if LUASL_DIFF_CHECK 2233#if LUASL_DIFF_CHECK
2241 compiler->ignorable = eina_strbuf_new(); 2234 lcompiler->ignorable = eina_strbuf_new();
2242#endif 2235#endif
2243 2236
2244 PI("Compiling %s.", compiler->compiler.file); 2237 PI("Compiling %s.", lcompiler->compiler->file);
2245 2238
2246 compiler->file = fopen(compiler->compiler.file, "r"); 2239 in = fopen(lcompiler->compiler->file, "r");
2247 if (NULL == compiler->file) 2240 if (NULL == in)
2248 { 2241 {
2249 PE("Error opening file %s.", compiler->compiler.file); 2242 PE("Error opening file %s.", lcompiler->compiler->file);
2250 return FALSE; 2243 return;
2251 } 2244 }
2252#if LUASL_BAD_CHECK 2245#if LUASL_BAD_CHECK
2253 // Mark the file as bad, in case we crash while compiling it. 2246 // Mark the file as bad, in case we crash while compiling it.
2254 // NOTE - wont work so well when we are threaded. 2247 // NOTE - wont work so well when we are threaded.
2255 sprintf(tempName, "%s.BAD", compiler->compiler.file); 2248 sprintf(tempName, "%s.BAD", lcompiler->compiler->file);
2256 ecore_file_mv(compiler->compiler.file, tempName); 2249 ecore_file_mv(lcompiler->compiler->file, tempName);
2257#endif 2250#endif
2258 compiler->ast = NULL; 2251 lcompiler->ast = NULL;
2259 compiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL); 2252 lcompiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL);
2260 // Text editors usually start counting at 1, even programmers editors. mcedit is an exception, but you can deal with that yourself. 2253 // Text editors usually start counting at 1, even programmers editors. mcedit is an exception, but you can deal with that yourself.
2261 compiler->column = 1; 2254 lcompiler->column = 1;
2262 compiler->line = 1; 2255 lcompiler->line = 1;
2263 2256
2264 if (yylex_init_extra(compiler, &(compiler->scanner))) 2257 if (yylex_init_extra(lcompiler, &(lcompiler->scanner)))
2265 return compiler->result; 2258 return;
2266 if (LUASL_DEBUG) 2259 if (LUASL_DEBUG)
2267 { 2260 {
2268 yyset_debug(1, compiler->scanner); 2261 yyset_debug(1, lcompiler->scanner);
2269 ParseTrace(stdout, "LSL_lemon "); 2262 ParseTrace(stdout, "LSL_lemon ");
2270 } 2263 }
2271 yyset_in(compiler->file, compiler->scanner); 2264 yyset_in(in, lcompiler->scanner);
2272 // on EOF yylex will return 0 2265 // on EOF yylex will return 0
2273 while((yv = yylex(compiler->lval, compiler->scanner)) != 0) 2266 while((yv = yylex(lcompiler->lval, lcompiler->scanner)) != 0)
2274 { 2267 {
2275 Parse(pParser, yv, compiler->lval, compiler); 2268 Parse(pParser, yv, lcompiler->lval, lcompiler);
2276 if (LSL_SCRIPT == yv) 2269 if (LSL_SCRIPT == yv)
2277 break; 2270 break;
2278 compiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL); 2271 lcompiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL);
2279 } 2272 }
2280 2273
2281 yylex_destroy(compiler->scanner); 2274 yylex_destroy(lcompiler->scanner);
2282 Parse(pParser, 0, compiler->lval, compiler); 2275 Parse(pParser, 0, lcompiler->lval, lcompiler);
2283 ParseFree(pParser, free); 2276 ParseFree(pParser, free);
2277 if (NULL != in)
2278 {
2279 fclose(in);
2280 in = NULL;
2281 }
2284 2282
2285 if (compiler->undeclared) 2283 if (lcompiler->undeclared)
2286 { 2284 {
2287// PW("A second pass is needed to check if functions where used before they where declared. To avoid this second pass, don't do that."); 2285// PW("A second pass is needed to check if functions where used before they where declared. To avoid this second pass, don't do that.");
2288 if (eina_clist_count(&(compiler->danglingCalls))) 2286 if (eina_clist_count(&(lcompiler->danglingCalls)))
2289 { 2287 {
2290 LSL_FunctionCall *call = NULL; 2288 LSL_FunctionCall *call = NULL;
2291 2289
2292 EINA_CLIST_FOR_EACH_ENTRY(call, &(compiler->danglingCalls), LSL_FunctionCall, dangler) 2290 EINA_CLIST_FOR_EACH_ENTRY(call, &(lcompiler->danglingCalls), LSL_FunctionCall, dangler)
2293 { 2291 {
2294 LSL_Leaf *func = findFunction(compiler, call->call->value.stringValue); 2292 LSL_Leaf *func = findFunction(lcompiler, call->call->value.stringValue);
2295 2293
2296 if (func) 2294 if (func)
2297 { 2295 {
@@ -2302,23 +2300,18 @@ boolean compileLSL(LuaSL_compiler *compiler)
2302 call->call->basicType = func->basicType; 2300 call->call->basicType = func->basicType;
2303 } 2301 }
2304 else 2302 else
2305 sendBack(compiler->compiler.client, compiler->compiler.SID, "compilerError(%d,%d,NOT FOUND function %s called)", call->call->line, call->call->column, call->call->value.stringValue); 2303 sendBack(lcompiler->compiler->client, lcompiler->compiler->SID, "compilerError(%d,%d,NOT FOUND function %s called)", call->call->line, call->call->column, call->call->value.stringValue);
2306 } 2304 }
2307 } 2305 }
2308 secondPass(compiler, compiler->ast); 2306 secondPass(lcompiler, lcompiler->ast);
2309// PD("Second pass completed."); 2307// PD("Second pass completed.");
2310 } 2308 }
2311 2309
2312 if (compiler->doConstants) 2310 if (lcompiler->compiler->doConstants)
2313 { 2311 memcpy(&constants, &(lcompiler->script), sizeof(LSL_Script));
2314 memcpy(&constants, &(compiler->script), sizeof(LSL_Script));
2315 compiler->result = TRUE;
2316 }
2317 else 2312 else
2318 { 2313 {
2319 compiler->result = FALSE; 2314 if (lcompiler->ast)
2320
2321 if (compiler->ast)
2322 { 2315 {
2323 FILE *out; 2316 FILE *out;
2324 char buffer[PATH_MAX]; 2317 char buffer[PATH_MAX];
@@ -2328,28 +2321,32 @@ boolean compileLSL(LuaSL_compiler *compiler)
2328 2321
2329 if (LUASL_DIFF_CHECK) 2322 if (LUASL_DIFF_CHECK)
2330 { 2323 {
2331 strcpy(outName, compiler->compiler.file); 2324 strcpy(outName, lcompiler->compiler->file);
2332 strcat(outName, "2"); 2325 strcat(outName, "2");
2333 out = fopen(outName, "w"); 2326 out = fopen(outName, "w");
2334 if (out) 2327 if (out)
2335 { 2328 {
2336 char diffName[PATH_MAX]; 2329 char diffName[PATH_MAX];
2337 2330
2338 strcpy(diffName, compiler->compiler.file); 2331 strcpy(diffName, lcompiler->compiler->file);
2339 strcat(diffName, ".diff"); 2332 strcat(diffName, ".diff");
2340 outputLeaf(out, OM_LSL, compiler->ast); 2333 outputLeaf(out, OM_LSL, lcompiler->ast);
2341 fclose(out); 2334 fclose(out);
2342 sprintf(buffer, "diff -u \"%s\" \"%s\" > \"%s\"", compiler->compiler.file, outName, diffName); 2335 sprintf(buffer, "diff -u \"%s\" \"%s\" > \"%s\"", lcompiler->compiler->file, outName, diffName);
2343 count = system(buffer); 2336 count = system(buffer);
2344 if (0 != count) 2337 if (0 != count)
2338 {
2339 lcompiler->compiler->bugCount++;
2345 PE("LSL output file is different - %s!", outName); 2340 PE("LSL output file is different - %s!", outName);
2346 else 2341 }
2347 compiler->result = TRUE;
2348 } 2342 }
2349 else 2343 else
2344 {
2345 lcompiler->compiler->bugCount++;
2350 PC("Unable to open file %s for writing!", outName); 2346 PC("Unable to open file %s for writing!", outName);
2347 }
2351 } 2348 }
2352 strcpy(luaName, compiler->compiler.file); 2349 strcpy(luaName, lcompiler->compiler->file);
2353 strcat(luaName, ".lua"); 2350 strcat(luaName, ".lua");
2354 out = fopen(luaName, "w"); 2351 out = fopen(luaName, "w");
2355 // Generate the Lua source code. 2352 // Generate the Lua source code.
@@ -2360,38 +2357,32 @@ boolean compileLSL(LuaSL_compiler *compiler)
2360 fprintf(out, "--// Generated code goes here.\n\n"); 2357 fprintf(out, "--// Generated code goes here.\n\n");
2361 fprintf(out, "local _bit = require(\"bit\")\n"); 2358 fprintf(out, "local _bit = require(\"bit\")\n");
2362 fprintf(out, "local _LSL = require(\"LSL\")\n\n"); 2359 fprintf(out, "local _LSL = require(\"LSL\")\n\n");
2363 fprintf(out, "local _SID = [=[%s]=]\n\n", compiler->compiler.SID); 2360 fprintf(out, "local _SID = [=[%s]=]\n\n", lcompiler->compiler->SID);
2364 strcpy(buffer, basename(compiler->compiler.file)); 2361 strcpy(buffer, basename(lcompiler->compiler->file));
2365 if ((ext = rindex(buffer, '.'))) 2362 if ((ext = rindex(buffer, '.')))
2366 ext[0] = '\0'; 2363 ext[0] = '\0';
2367 fprintf(out, "local _scriptName = [=[%s]=]\n\n", buffer); 2364 fprintf(out, "local _scriptName = [=[%s]=]\n\n", buffer);
2368 outputLeaf(out, OM_LUA, compiler->ast); 2365 outputLeaf(out, OM_LUA, lcompiler->ast);
2369 fprintf(out, "\n\n_LSL.mainLoop(_SID, _scriptName, _defaultState)\n"); // This actually starts the script running. 2366 fprintf(out, "\n\n_LSL.mainLoop(_SID, _scriptName, _defaultState)\n"); // This actually starts the script running.
2370 fprintf(out, "\n--// End of generated code.\n\n"); 2367 fprintf(out, "\n--// End of generated code.\n\n");
2371 fclose(out); 2368 fclose(out);
2372 2369
2373 // Compile the Lua source code. 2370 // Make sure the output gets compiled by Lua.
2374 compiler->compiler.luaName = strdup(luaName); 2371 lcompiler->compiler->luaName = strdup(luaName);
2375 compiler->compiler.bugCount = compiler->script.bugCount;
2376 compileScript(&compiler->compiler, COMPILE_THREADED);
2377 compiler->result = TRUE;
2378 } 2372 }
2379 else 2373 else
2374 {
2375 lcompiler->compiler->bugCount++;
2380 PC("Unable to open file %s for writing!", luaName); 2376 PC("Unable to open file %s for writing!", luaName);
2377 }
2381 } 2378 }
2379 burnLeaf(lcompiler->ast);
2382 } 2380 }
2383 2381
2384 if (NULL != compiler->file)
2385 {
2386 fclose(compiler->file);
2387 compiler->file = NULL;
2388 }
2389
2390 if (!compiler->doConstants)
2391 burnLeaf(compiler->ast);
2392
2393#if LUASL_BAD_CHECK 2382#if LUASL_BAD_CHECK
2394 ecore_file_mv(tempName, compiler->compiler.file); 2383 ecore_file_mv(tempName, lcompiler->compiler->file);
2395#endif 2384#endif
2396 return compiler->result; 2385
2386 free(lcompiler);
2387 return;
2397} 2388}
diff --git a/src/LuaSL/LuaSL_lemon_yaccer.y b/src/LuaSL/LuaSL_lemon_yaccer.y
index f03837e..2a23e84 100644
--- a/src/LuaSL/LuaSL_lemon_yaccer.y
+++ b/src/LuaSL/LuaSL_lemon_yaccer.y
@@ -229,19 +229,19 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
229 229
230%parse_failure 230%parse_failure
231{ 231{
232 compiler->script.bugCount++; 232 compiler->compiler->bugCount++;
233 PE("Giving up. Parser is hopelessly lost!"); 233 PE("Giving up. Parser is hopelessly lost!");
234} 234}
235 235
236%stack_overflow 236%stack_overflow
237{ 237{
238 compiler->script.bugCount++; 238 compiler->compiler->bugCount++;
239 PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. 239 PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens.
240} 240}
241 241
242%syntax_error 242%syntax_error
243{ 243{
244 compiler->script.bugCount++; 244 compiler->compiler->bugCount++;
245 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); 245 PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column);
246} 246}
247 247
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c
index 3ed9004..f316fdb 100644
--- a/src/LuaSL/LuaSL_main.c
+++ b/src/LuaSL/LuaSL_main.c
@@ -186,10 +186,6 @@ static void _compileCb(LuaCompiler *compiler)
186 sendBack(compiler->client, compiler->SID, "compiled(true)"); 186 sendBack(compiler->client, compiler->SID, "compiled(true)");
187 else 187 else
188 sendBack(compiler->client, compiler->SID, "compiled(false)"); 188 sendBack(compiler->client, compiler->SID, "compiled(false)");
189 free(compiler->luaName);
190 free(compiler->SID);
191 free(compiler->file);
192 free(compiler);
193} 189}
194 190
195static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev) 191static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Data *ev)
@@ -218,7 +214,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
218 { 214 {
219 char *temp; 215 char *temp;
220 char *file; 216 char *file;
221 LuaSL_compiler *compiler = calloc(1, sizeof(LuaSL_compiler)); 217 LuaCompiler *compiler = calloc(1, sizeof(LuaCompiler));
222 218
223 strcpy(buf, &command[8]); 219 strcpy(buf, &command[8]);
224 temp = buf; 220 temp = buf;
@@ -227,23 +223,13 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D
227 temp++; 223 temp++;
228 temp[0] = '\0'; 224 temp[0] = '\0';
229 225
230 compiler->compiler.file = strdup(file); 226 compiler->file = strdup(file);
231 compiler->compiler.SID = strdup(SID); 227 compiler->SID = strdup(SID);
232 compiler->compiler.client = ev->client; 228 compiler->client = ev->client;
233 compiler->compiler.data = ourGlobals;
234 compiler->compiler.cb = _compileCb;
235 compiler->doConstants = FALSE; 229 compiler->doConstants = FALSE;
236#if COMPILE_THREADED 230 compiler->parser = (compileCb) compileLSL;
237 compiler->compiler.parser = (compileCb) compileLSL; 231 compiler->cb = _compileCb;
238 compileScript(&compiler->compiler); 232 compileScript(compiler, COMPILE_THREADED);
239#else
240 if (!compileLSL(compiler))
241 {
242 compiler->compiler.bugCount++;
243 PE("Compile of %s failed in a mysterious way.", file);
244 _compileCb(&(compiler->compiler));
245 }
246#endif
247 } 233 }
248 else if (0 == strncmp(command, "run(", 4)) 234 else if (0 == strncmp(command, "run(", 4))
249 { 235 {