diff options
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 4 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 28 |
2 files changed, 24 insertions, 8 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 875e1b9..7e59075 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -251,6 +251,10 @@ struct _LSL_Block | |||
251 | Eina_Clist statements; // For statement lists, this is the HEAD. | 251 | Eina_Clist statements; // For statement lists, this is the HEAD. |
252 | Eina_Hash *variables; // Those variables in this scope. | 252 | Eina_Hash *variables; // Those variables in this scope. |
253 | LSL_Function *function; // A pointer to the function if this block is a function. | 253 | LSL_Function *function; // A pointer to the function if this block is a function. |
254 | #if LUASL_DIFF_CHECK | ||
255 | Eina_Strbuf *openIgnorableText; | ||
256 | Eina_Strbuf *closeIgnorableText; | ||
257 | #endif | ||
254 | }; | 258 | }; |
255 | 259 | ||
256 | struct _LSL_Function | 260 | struct _LSL_Function |
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 772f01a..09463a9 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -450,6 +450,10 @@ LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL | |||
450 | { | 450 | { |
451 | // Damn, look ahead. The } symbol is getting read (and thus endBlock called) before the last statement in the block is reduced (which actually calls the add*() functions). | 451 | // Damn, look ahead. The } symbol is getting read (and thus endBlock called) before the last statement in the block is reduced (which actually calls the add*() functions). |
452 | compiler->currentBlock = compiler->currentBlock->outerBlock; | 452 | compiler->currentBlock = compiler->currentBlock->outerBlock; |
453 | #if LUASL_DIFF_CHECK | ||
454 | left->value.blockValue->closeIgnorableText = right->ignorableText; | ||
455 | right->ignorableText = NULL; | ||
456 | #endif | ||
453 | return lval; | 457 | return lval; |
454 | } | 458 | } |
455 | 459 | ||
@@ -834,6 +838,10 @@ LSL_Leaf *beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block) | |||
834 | blok->variables = eina_hash_stringshared_new(burnLeaf); | 838 | blok->variables = eina_hash_stringshared_new(burnLeaf); |
835 | block->value.blockValue = blok; | 839 | block->value.blockValue = blok; |
836 | blok->outerBlock = compiler->currentBlock; | 840 | blok->outerBlock = compiler->currentBlock; |
841 | #if LUASL_DIFF_CHECK | ||
842 | blok->openIgnorableText = block->ignorableText; | ||
843 | block->ignorableText = NULL; | ||
844 | #endif | ||
837 | compiler->currentBlock = blok; | 845 | compiler->currentBlock = blok; |
838 | blok->function = compiler->currentFunction; | 846 | blok->function = compiler->currentFunction; |
839 | compiler->currentFunction = NULL; | 847 | compiler->currentFunction = NULL; |
@@ -1225,23 +1233,27 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1225 | 1233 | ||
1226 | static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block) | 1234 | static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block) |
1227 | { | 1235 | { |
1228 | if (LUASL_DIFF_CHECK) | ||
1229 | fprintf(file, "\n{"); | ||
1230 | else | ||
1231 | fprintf(file, "\n{\n"); | ||
1232 | if (block) | 1236 | if (block) |
1233 | { | 1237 | { |
1234 | LSL_Statement *stat = NULL; | 1238 | LSL_Statement *stat = NULL; |
1235 | 1239 | ||
1240 | #if LUASL_DIFF_CHECK | ||
1241 | if (block->openIgnorableText) | ||
1242 | fwrite(eina_strbuf_string_get(block->openIgnorableText), 1, eina_strbuf_length_get(block->openIgnorableText), file); | ||
1243 | fprintf(file, "{"); | ||
1244 | #else | ||
1245 | fprintf(file, "\n{\n"); | ||
1246 | #endif | ||
1236 | EINA_CLIST_FOR_EACH_ENTRY(stat, &(block->statements), LSL_Statement, statement) | 1247 | EINA_CLIST_FOR_EACH_ENTRY(stat, &(block->statements), LSL_Statement, statement) |
1237 | { | 1248 | { |
1238 | outputRawStatement(file, mode, stat); | 1249 | outputRawStatement(file, mode, stat); |
1239 | } | 1250 | } |
1240 | } | 1251 | #if LUASL_DIFF_CHECK |
1241 | if (LUASL_DIFF_CHECK) | 1252 | if (block->closeIgnorableText) |
1242 | fprintf(file, "\n}"); | 1253 | fwrite(eina_strbuf_string_get(block->closeIgnorableText), 1, eina_strbuf_length_get(block->closeIgnorableText), file); |
1243 | else | 1254 | #endif |
1244 | fprintf(file, "}"); | 1255 | fprintf(file, "}"); |
1256 | } | ||
1245 | } | 1257 | } |
1246 | 1258 | ||
1247 | static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthesis *parenthesis, const char *typeName) | 1259 | static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthesis *parenthesis, const char *typeName) |