aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 02:10:30 +1000
committerDavid Walter Seikel2012-02-02 02:10:30 +1000
commitf434dc1fe3af702179dc8c827bf26c663f34f138 (patch)
tree81dec04c5f9d292985fc5921c4e069aa1436b39b /LuaSL/src
parentParse dot subbies. (diff)
downloadSledjHamr-f434dc1fe3af702179dc8c827bf26c663f34f138.zip
SledjHamr-f434dc1fe3af702179dc8c827bf26c663f34f138.tar.gz
SledjHamr-f434dc1fe3af702179dc8c827bf26c663f34f138.tar.bz2
SledjHamr-f434dc1fe3af702179dc8c827bf26c663f34f138.tar.xz
Output state changes properly.
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h2
-rw-r--r--LuaSL/src/LuaSL_compile.c40
2 files changed, 24 insertions, 18 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 7791b10..94be1a6 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -218,7 +218,7 @@ struct _LSL_Identifier // For variables and function parameters.
218struct _LSL_Statement 218struct _LSL_Statement
219{ 219{
220 Eina_Clist statement; // For block statement lists, this is the entry. 220 Eina_Clist statement; // For block statement lists, this is the entry.
221 LSL_Identifier *identifier; 221 LSL_Text identifier;
222 LSL_Parenthesis *parenthesis; 222 LSL_Parenthesis *parenthesis;
223 LSL_Leaf *expressions; // A for statement will have three expressions, and two semicolons, everything else has zero or one. 223 LSL_Leaf *expressions; // A for statement will have three expressions, and two semicolons, everything else has zero or one.
224 LSL_Block *block; 224 LSL_Block *block;
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 5fb3946..cae3c86 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -810,7 +810,13 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow,
810 } 810 }
811 eina_clist_element_init(&(stat->statement)); 811 eina_clist_element_init(&(stat->statement));
812 if (identifier) 812 if (identifier)
813 stat->identifier = identifier->value.identifierValue; 813 {
814 stat->identifier.text = identifier->value.stringValue;
815#if LUASL_DIFF_CHECK
816 stat->identifier.ignorable = identifier->ignorable;
817 identifier->ignorable = NULL;
818#endif
819 }
814 if (left) 820 if (left)
815 { 821 {
816 LSL_Leaf *parens = addParenthesis(left, expr, LSL_EXPRESSION, right); 822 LSL_Leaf *parens = addParenthesis(left, expr, LSL_EXPRESSION, right);
@@ -869,7 +875,7 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow,
869 } 875 }
870 case LSL_WHILE : 876 case LSL_WHILE :
871 { 877 {
872 stat->identifier = NULL; 878 stat->identifier.text = NULL;
873 justOne = TRUE; 879 justOne = TRUE;
874 break; 880 break;
875 } 881 }
@@ -1469,6 +1475,18 @@ static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthes
1469 outputLeaf(file, mode, parenthesis->contents); 1475 outputLeaf(file, mode, parenthesis->contents);
1470} 1476}
1471 1477
1478static void outputText(FILE *file, LSL_Text *text, boolean ignore)
1479{
1480 if (text->text)
1481 {
1482#if LUASL_DIFF_CHECK
1483 if (ignore && (text->ignorable))
1484 fwrite(eina_strbuf_string_get(text->ignorable), 1, eina_strbuf_length_get(text->ignorable), file);
1485#endif
1486 fprintf(file, "%s", text->text);
1487 }
1488}
1489
1472static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *statement) 1490static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *statement)
1473{ 1491{
1474 boolean isBlock = FALSE; 1492 boolean isBlock = FALSE;
@@ -1546,8 +1564,8 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1546 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); 1564 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file);
1547#endif 1565#endif
1548 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); 1566 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1549 if (statement->identifier) 1567 if (statement->identifier.text)
1550 outputText(file, &(statement->identifier->name), FALSE); 1568 outputText(file, &(statement->identifier), TRUE);
1551 break; 1569 break;
1552 } 1570 }
1553 case LSL_STATEMENT : 1571 case LSL_STATEMENT :
@@ -1628,18 +1646,6 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1628 } 1646 }
1629} 1647}
1630 1648
1631static void outputText(FILE *file, LSL_Text *text, boolean ignore)
1632{
1633 if (text->text)
1634 {
1635#if LUASL_DIFF_CHECK
1636 if (ignore && (text->ignorable))
1637 fwrite(eina_strbuf_string_get(text->ignorable), 1, eina_strbuf_length_get(text->ignorable), file);
1638#endif
1639 fprintf(file, "%s", text->text);
1640 }
1641}
1642
1643static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content) 1649static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content)
1644{ 1650{
1645 if (content) 1651 if (content)
@@ -1843,7 +1849,7 @@ static boolean doneParsing(LuaSL_compiler *compiler)
1843 strcat(diffName, ".diff"); 1849 strcat(diffName, ".diff");
1844 outputLeaf(out, OM_LSL, compiler->ast); 1850 outputLeaf(out, OM_LSL, compiler->ast);
1845 fclose(out); 1851 fclose(out);
1846 sprintf(buffer, "diff -wu \"%s\" \"%s\" > \"%s\"", compiler->fileName, outName, diffName); 1852 sprintf(buffer, "diff -u \"%s\" \"%s\" > \"%s\"", compiler->fileName, outName, diffName);
1847 count = system(buffer); 1853 count = system(buffer);
1848 if (0 != count) 1854 if (0 != count)
1849 PE("LSL output file is different - %s!", outName); 1855 PE("LSL output file is different - %s!", outName);