diff options
author | David Walter Seikel | 2014-08-14 14:11:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-08-14 14:11:58 +1000 |
commit | ab6b1318f3dd335ef49aa46146c43a51037675b7 (patch) | |
tree | 1946581d4452a07bce1fb400d3b729af70597fda /src/LuaSL | |
parent | Use the new message saving stuff in the parser as well. (diff) | |
download | SledjHamr-ab6b1318f3dd335ef49aa46146c43a51037675b7.zip SledjHamr-ab6b1318f3dd335ef49aa46146c43a51037675b7.tar.gz SledjHamr-ab6b1318f3dd335ef49aa46146c43a51037675b7.tar.bz2 SledjHamr-ab6b1318f3dd335ef49aa46146c43a51037675b7.tar.xz |
Clean up the compiler output. Threaded compiling is much faster when it's not outputting to the console.
Diffstat (limited to '')
-rw-r--r-- | src/LuaSL/LuaSL_LSL_tree.h | 3 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_compile.c | 13 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_lemon_yaccer.y | 12 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_lexer.l | 2 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 2 |
5 files changed, 19 insertions, 13 deletions
diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h index 4192310..98e8e22 100644 --- a/src/LuaSL/LuaSL_LSL_tree.h +++ b/src/LuaSL/LuaSL_LSL_tree.h | |||
@@ -3,7 +3,8 @@ | |||
3 | #define __LUASL_TREE_H__ | 3 | #define __LUASL_TREE_H__ |
4 | 4 | ||
5 | #define LUASL_DEBUG 0 | 5 | #define LUASL_DEBUG 0 |
6 | #define COMPILE_THREADED 0 | 6 | #define COMPILE_THREADED 1 |
7 | #define COMPILE_OUTPUT 0 | ||
7 | #define LUASL_DIFF_CHECK 0 | 8 | #define LUASL_DIFF_CHECK 0 |
8 | #define LUASL_BAD_CHECK 1 | 9 | #define LUASL_BAD_CHECK 1 |
9 | 10 | ||
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index 4764855..a2b2bca 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c | |||
@@ -501,7 +501,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
501 | // someList = someList + notAList -> someList = _LSL.listAddList( someList, notAList) | 501 | // someList = someList + notAList -> someList = _LSL.listAddList( someList, notAList) |
502 | else if ((OT_list == lType) || (OT_list == rType)) | 502 | else if ((OT_list == lType) || (OT_list == rType)) |
503 | { | 503 | { |
504 | 504 | #if COMPILE_OUTPUT | |
505 | if ((left) && (right)) | 505 | if ((left) && (right)) |
506 | printf("LA LINE %d - %s %s %s\n", lval->line, left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); | 506 | printf("LA LINE %d - %s %s %s\n", lval->line, left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); |
507 | else if (left) | 507 | else if (left) |
@@ -510,7 +510,7 @@ else if (right) | |||
510 | printf("LA LINE %d - NOLEFT %s %s\n", lval->line, lval->toKen->toKen, right->toKen->toKen); | 510 | printf("LA LINE %d - NOLEFT %s %s\n", lval->line, lval->toKen->toKen, right->toKen->toKen); |
511 | else | 511 | else |
512 | printf("LA LINE %d - NOLEFT %s NORIGHT\n", lval->line, lval->toKen->toKen); | 512 | printf("LA LINE %d - NOLEFT %s NORIGHT\n", lval->line, lval->toKen->toKen); |
513 | 513 | #endif | |
514 | lval->basicType = OT_list; | 514 | lval->basicType = OT_list; |
515 | lval->toKen = tokens[LSL_LIST_ADD_LIST - lowestToken]; | 515 | lval->toKen = tokens[LSL_LIST_ADD_LIST - lowestToken]; |
516 | } | 516 | } |
@@ -575,6 +575,7 @@ else | |||
575 | { | 575 | { |
576 | if (left->flags & MF_ASSIGNEXP) | 576 | if (left->flags & MF_ASSIGNEXP) |
577 | { | 577 | { |
578 | #if COMPILE_OUTPUT | ||
578 | if ((left) && (right)) | 579 | if ((left) && (right)) |
579 | printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); | 580 | printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); |
580 | else if (left) | 581 | else if (left) |
@@ -584,6 +585,7 @@ else if (right) | |||
584 | else | 585 | else |
585 | printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); | 586 | printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); |
586 | printf("############################################################################## left\n"); | 587 | printf("############################################################################## left\n"); |
588 | #endif | ||
587 | left->flags |= MF_WRAPFUNC; | 589 | left->flags |= MF_WRAPFUNC; |
588 | if (LSL_PARENTHESIS_OPEN == left->toKen->type) | 590 | if (LSL_PARENTHESIS_OPEN == left->toKen->type) |
589 | left->value.parenthesis->flags |= MF_WRAPFUNC; | 591 | left->value.parenthesis->flags |= MF_WRAPFUNC; |
@@ -609,6 +611,7 @@ else | |||
609 | { | 611 | { |
610 | if (right->flags & MF_ASSIGNEXP) | 612 | if (right->flags & MF_ASSIGNEXP) |
611 | { | 613 | { |
614 | #if COMPILE_OUTPUT | ||
612 | if ((left) && (right)) | 615 | if ((left) && (right)) |
613 | printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); | 616 | printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); |
614 | else if (left) | 617 | else if (left) |
@@ -618,6 +621,7 @@ else if (right) | |||
618 | else | 621 | else |
619 | printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); | 622 | printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); |
620 | printf("############################################################################## right\n"); | 623 | printf("############################################################################## right\n"); |
624 | #endif | ||
621 | right->flags |= MF_WRAPFUNC; | 625 | right->flags |= MF_WRAPFUNC; |
622 | } | 626 | } |
623 | } | 627 | } |
@@ -643,8 +647,6 @@ else | |||
643 | rightType = allowed[right->basicType].name; | 647 | rightType = allowed[right->basicType].name; |
644 | } | 648 | } |
645 | 649 | ||
646 | // compiler->compiler->bugCount++; | ||
647 | // 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); | ||
648 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), | 650 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), |
649 | "Invalid operation [%s(%s) %s %s(%s)]", leftType, leftToken, lval->toKen->toKen, rightType, rightToken), | 651 | "Invalid operation [%s(%s) %s %s(%s)]", leftType, leftToken, lval->toKen->toKen, rightType, rightToken), |
650 | 1, lval->column, lval->line); | 652 | 1, lval->column, lval->line); |
@@ -1429,6 +1431,7 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) | |||
1429 | if (MF_WRAPFUNC & leaf->flags) | 1431 | if (MF_WRAPFUNC & leaf->flags) |
1430 | { | 1432 | { |
1431 | // TODO - Leaving this here in case we trip over one. | 1433 | // TODO - Leaving this here in case we trip over one. |
1434 | #if COMPILE_OUTPUT | ||
1432 | if ((leaf->left) && (leaf->right)) | 1435 | if ((leaf->left) && (leaf->right)) |
1433 | printf("%s %s %s\n", leaf->left->toKen->toKen, leaf->toKen->toKen, leaf->right->toKen->toKen); | 1436 | printf("%s %s %s\n", leaf->left->toKen->toKen, leaf->toKen->toKen, leaf->right->toKen->toKen); |
1434 | else if (leaf->left) | 1437 | else if (leaf->left) |
@@ -1437,6 +1440,7 @@ else if (leaf->right) | |||
1437 | printf("NOLEFT %s %s\n", leaf->toKen->toKen, leaf->right->toKen->toKen); | 1440 | printf("NOLEFT %s %s\n", leaf->toKen->toKen, leaf->right->toKen->toKen); |
1438 | else | 1441 | else |
1439 | printf("NOLEFT %s NORIGHT\n", leaf->toKen->toKen); | 1442 | printf("NOLEFT %s NORIGHT\n", leaf->toKen->toKen); |
1443 | #endif | ||
1440 | } | 1444 | } |
1441 | if ((LSL_ASSIGNMENT & leaf->toKen->flags) && (LSL_ASSIGNMENT_PLAIN != leaf->toKen->type)) | 1445 | if ((LSL_ASSIGNMENT & leaf->toKen->flags) && (LSL_ASSIGNMENT_PLAIN != leaf->toKen->type)) |
1442 | { | 1446 | { |
@@ -2315,7 +2319,6 @@ void compileLSL(LuaCompiler *compiler) | |||
2315 | } | 2319 | } |
2316 | else | 2320 | else |
2317 | { | 2321 | { |
2318 | // 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); | ||
2319 | finishMessage(lcompiler->compiler, addMessage(&(lcompiler->compiler->messages), sizeof(compileMessage), | 2322 | finishMessage(lcompiler->compiler, addMessage(&(lcompiler->compiler->messages), sizeof(compileMessage), |
2320 | "NOT FOUND function %s called", call->call->value.stringValue), | 2323 | "NOT FOUND function %s called", call->call->value.stringValue), |
2321 | 1, call->call->column, call->call->line); | 2324 | 1, call->call->column, call->call->line); |
diff --git a/src/LuaSL/LuaSL_lemon_yaccer.y b/src/LuaSL/LuaSL_lemon_yaccer.y index 08fdccc..5ddf45a 100644 --- a/src/LuaSL/LuaSL_lemon_yaccer.y +++ b/src/LuaSL/LuaSL_lemon_yaccer.y | |||
@@ -229,20 +229,20 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; } | |||
229 | 229 | ||
230 | %parse_failure | 230 | %parse_failure |
231 | { | 231 | { |
232 | compiler->compiler->bugCount++; | 232 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), |
233 | PE("Giving up. Parser is hopelessly lost!"); | 233 | "Giving up. Parser is hopelessly lost!"), |
234 | 1, -1, -1); | ||
234 | } | 235 | } |
235 | 236 | ||
236 | %stack_overflow | 237 | %stack_overflow |
237 | { | 238 | { |
238 | compiler->compiler->bugCount++; | 239 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), |
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 | "Giving up. Parser stack overflow"), // Gotta love consistancy, if it ever happens. |
241 | 1, yypMinor->yy0->column, yypMinor->yy0->line); | ||
240 | } | 242 | } |
241 | 243 | ||
242 | %syntax_error | 244 | %syntax_error |
243 | { | 245 | { |
244 | // compiler->compiler->bugCount++; | ||
245 | // PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); | ||
246 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), | 246 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), |
247 | "Syntax error."), | 247 | "Syntax error."), |
248 | 1, yyminor.yy0->column, yyminor.yy0->line); | 248 | 1, yyminor.yy0->column, yyminor.yy0->line); |
diff --git a/src/LuaSL/LuaSL_lexer.l b/src/LuaSL/LuaSL_lexer.l index 85b2821..9d58899 100644 --- a/src/LuaSL/LuaSL_lexer.l +++ b/src/LuaSL/LuaSL_lexer.l | |||
@@ -113,7 +113,7 @@ STRING \"(\\.|[^\\"\n])*\" | |||
113 | <<EOF>> { return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_SCRIPT); } | 113 | <<EOF>> { return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_SCRIPT); } |
114 | 114 | ||
115 | /* Everything else */ | 115 | /* Everything else */ |
116 | . %{ printf(" unexpected character.\n"); yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} | 116 | . %{ if (COMPILE_OUTPUT) printf(" unexpected character '%s'.\n", yytext); yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} |
117 | 117 | ||
118 | %% | 118 | %% |
119 | 119 | ||
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 1eaa43a..0ffc679 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -186,10 +186,12 @@ static void _compileCb(LuaCompiler *compiler) | |||
186 | 186 | ||
187 | EINA_CLIST_FOR_EACH_ENTRY_SAFE(message, safe, &(compiler->messages), compileMessage, node) | 187 | EINA_CLIST_FOR_EACH_ENTRY_SAFE(message, safe, &(compiler->messages), compileMessage, node) |
188 | { | 188 | { |
189 | #if COMPILE_OUTPUT | ||
189 | if (message->type) | 190 | if (message->type) |
190 | sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,%s)", message->line, message->column, message->message); | 191 | sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,%s)", message->line, message->column, message->message); |
191 | else | 192 | else |
192 | sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,%s)", message->line, message->column, message->message); | 193 | sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,%s)", message->line, message->column, message->message); |
194 | #endif | ||
193 | eina_clist_remove(&(message->node)); | 195 | eina_clist_remove(&(message->node)); |
194 | free(message); | 196 | free(message); |
195 | } | 197 | } |