diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 4f51ee4..40b7b00 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -225,7 +225,9 @@ void burnLeaf(void *data) | |||
225 | // burnLeaf(leaf->left); | 225 | // burnLeaf(leaf->left); |
226 | // burnLeaf(leaf->right); | 226 | // burnLeaf(leaf->right); |
227 | // TODO - Should free up the value to. | 227 | // TODO - Should free up the value to. |
228 | #ifdef LUASL_DIFF_CHECK | ||
228 | // eina_strbuf_free(leaf->ignorableText); | 229 | // eina_strbuf_free(leaf->ignorableText); |
230 | #endif | ||
229 | // free(leaf); | 231 | // free(leaf); |
230 | } | 232 | } |
231 | } | 233 | } |
@@ -468,9 +470,11 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf | |||
468 | { | 470 | { |
469 | parens->contents = expr; | 471 | parens->contents = expr; |
470 | parens->type = type; | 472 | parens->type = type; |
473 | #ifdef LUASL_DIFF_CHECK | ||
471 | parens->rightIgnorableText = rval->ignorableText; | 474 | parens->rightIgnorableText = rval->ignorableText; |
472 | // Actualy, at this point, rval is no longer needed. | 475 | // Actualy, at this point, rval is no longer needed. |
473 | // rval->ignorableText = eina_strbuf_new(); | 476 | // rval->ignorableText = eina_strbuf_new(); |
477 | #endif | ||
474 | if (lval) | 478 | if (lval) |
475 | { | 479 | { |
476 | lval->value.parenthesis = parens; | 480 | lval->value.parenthesis = parens; |
@@ -878,8 +882,10 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) | |||
878 | if (leaf) | 882 | if (leaf) |
879 | { | 883 | { |
880 | outputLeaf(file, mode, leaf->left); | 884 | outputLeaf(file, mode, leaf->left); |
885 | #ifdef LUASL_DIFF_CHECK | ||
881 | if ((!(LSL_NOIGNORE & leaf->token->flags)) && (leaf->ignorableText)) | 886 | if ((!(LSL_NOIGNORE & leaf->token->flags)) && (leaf->ignorableText)) |
882 | fwrite(eina_strbuf_string_get(leaf->ignorableText), 1, eina_strbuf_length_get(leaf->ignorableText), file); | 887 | fwrite(eina_strbuf_string_get(leaf->ignorableText), 1, eina_strbuf_length_get(leaf->ignorableText), file); |
888 | #endif | ||
883 | if (leaf->token->output) | 889 | if (leaf->token->output) |
884 | leaf->token->output(file, mode, leaf); | 890 | leaf->token->output(file, mode, leaf); |
885 | else | 891 | else |
@@ -904,6 +910,9 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
904 | fprintf(file, "%s", func->name); | 910 | fprintf(file, "%s", func->name); |
905 | outputLeaf(file, mode, func->params); | 911 | outputLeaf(file, mode, func->params); |
906 | outputLeaf(file, mode, func->block); | 912 | outputLeaf(file, mode, func->block); |
913 | #ifndef LUASL_DIFF_CHECK | ||
914 | fprintf(file, "\n"); | ||
915 | #endif | ||
907 | } | 916 | } |
908 | } | 917 | } |
909 | 918 | ||
@@ -916,7 +925,11 @@ static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
916 | static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content) | 925 | static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content) |
917 | { | 926 | { |
918 | if (content) | 927 | if (content) |
928 | #ifdef LUASL_DIFF_CHECK | ||
919 | fprintf(file, "%s", content->value.identifierValue->name); | 929 | fprintf(file, "%s", content->value.identifierValue->name); |
930 | #else | ||
931 | fprintf(file, " %s", content->value.identifierValue->name); | ||
932 | #endif | ||
920 | } | 933 | } |
921 | 934 | ||
922 | static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) | 935 | static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) |
@@ -934,7 +947,11 @@ static void outputParenthesisToken(FILE *file, outputMode mode, LSL_Leaf *conten | |||
934 | fprintf(file, "%s", allowed[content->basicType].name); // TODO - We are missing the type ignorable text here. | 947 | fprintf(file, "%s", allowed[content->basicType].name); // TODO - We are missing the type ignorable text here. |
935 | else | 948 | else |
936 | outputLeaf(file, mode, content->value.parenthesis->contents); | 949 | outputLeaf(file, mode, content->value.parenthesis->contents); |
950 | #ifdef LUASL_DIFF_CHECK | ||
937 | fprintf(file, "%s)", eina_strbuf_string_get(content->value.parenthesis->rightIgnorableText)); | 951 | fprintf(file, "%s)", eina_strbuf_string_get(content->value.parenthesis->rightIgnorableText)); |
952 | #else | ||
953 | fprintf(file, ")"); | ||
954 | #endif | ||
938 | if (LSL_TYPECAST_OPEN == content->value.parenthesis->type) | 955 | if (LSL_TYPECAST_OPEN == content->value.parenthesis->type) |
939 | outputLeaf(file, mode, content->value.parenthesis->contents); | 956 | outputLeaf(file, mode, content->value.parenthesis->contents); |
940 | } | 957 | } |
@@ -956,9 +973,14 @@ static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
956 | if (content) | 973 | if (content) |
957 | { | 974 | { |
958 | outputLeaf(file, mode, content->value.statementValue->expressions); | 975 | outputLeaf(file, mode, content->value.statementValue->expressions); |
976 | #ifdef LUASL_DIFF_CHECK | ||
959 | if (content->ignorableText) | 977 | if (content->ignorableText) |
960 | fwrite(eina_strbuf_string_get(content->ignorableText), 1, eina_strbuf_length_get(content->ignorableText), file); | 978 | fwrite(eina_strbuf_string_get(content->ignorableText), 1, eina_strbuf_length_get(content->ignorableText), file); |
979 | #endif | ||
961 | fprintf(file, "%s", content->token->token); | 980 | fprintf(file, "%s", content->token->token); |
981 | #ifndef LUASL_DIFF_CHECK | ||
982 | fprintf(file, "\n"); | ||
983 | #endif | ||
962 | } | 984 | } |
963 | } | 985 | } |
964 | 986 | ||
@@ -985,14 +1007,18 @@ static void doneParsing(LuaSL_compiler *compiler) | |||
985 | out = fopen(outName, "w"); | 1007 | out = fopen(outName, "w"); |
986 | if (out) | 1008 | if (out) |
987 | { | 1009 | { |
988 | // int count; | 1010 | #ifdef LUASL_DIFF_CHECK |
1011 | int count; | ||
1012 | #endif | ||
989 | outputLeaf(out, OM_LSL, compiler->ast); | 1013 | outputLeaf(out, OM_LSL, compiler->ast); |
990 | fclose(out); | 1014 | fclose(out); |
991 | sprintf(buffer, "diff %s %s", compiler->fileName, outName); | 1015 | sprintf(buffer, "diff %s %s", compiler->fileName, outName); |
992 | // count = system(buffer); | 1016 | #ifdef LUASL_DIFF_CHECK |
993 | // PI("Return value of %s is %d", buffer, count); | 1017 | count = system(buffer); |
994 | // if (0 != count) | 1018 | PI("Return value of %s is %d", buffer, count); |
995 | // PE("%s says they are different!", buffer); | 1019 | if (0 != count) |
1020 | PE("%s says they are different!", buffer); | ||
1021 | #endif | ||
996 | } | 1022 | } |
997 | else | 1023 | else |
998 | PC("Unable to open file %s for writing!", outName); | 1024 | PC("Unable to open file %s for writing!", outName); |
@@ -1050,7 +1076,9 @@ Eina_Bool compileLSL(gameGlobals *game, char *script) | |||
1050 | compiler.script.functions = eina_hash_stringshared_new(burnLeaf); | 1076 | compiler.script.functions = eina_hash_stringshared_new(burnLeaf); |
1051 | compiler.script.states = eina_hash_stringshared_new(burnLeaf); | 1077 | compiler.script.states = eina_hash_stringshared_new(burnLeaf); |
1052 | compiler.script.variables = eina_hash_stringshared_new(burnLeaf); | 1078 | compiler.script.variables = eina_hash_stringshared_new(burnLeaf); |
1079 | #ifdef LUASL_DIFF_CHECK | ||
1053 | compiler.ignorableText = eina_strbuf_new(); | 1080 | compiler.ignorableText = eina_strbuf_new(); |
1081 | #endif | ||
1054 | 1082 | ||
1055 | strncpy(compiler.fileName, script, PATH_MAX - 1); | 1083 | strncpy(compiler.fileName, script, PATH_MAX - 1); |
1056 | compiler.fileName[PATH_MAX - 1] = '\0'; | 1084 | compiler.fileName[PATH_MAX - 1] = '\0'; |