aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL_compile.c122
1 files changed, 116 insertions, 6 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index eac098b..e13c7e7 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -1610,12 +1610,51 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1610 } 1610 }
1611 case LSL_FOR : 1611 case LSL_FOR :
1612 { 1612 {
1613 isBlock = TRUE;
1614#if LUASL_DIFF_CHECK 1613#if LUASL_DIFF_CHECK
1615 if ((statement->ignorable) && (statement->ignorable[1])) 1614 if ((statement->ignorable) && (statement->ignorable[1]))
1616 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); 1615 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file);
1617#endif 1616#endif
1618 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); 1617 if (OM_LSL == mode)
1618 {
1619 isBlock = TRUE;
1620 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1621 }
1622 else if (OM_LUA == mode)
1623 {
1624 LSL_Leaf **exprs = (LSL_Leaf **) statement->expressions;
1625
1626 outputLeaf(file, mode, exprs[0]);
1627 fprintf(file, ";\nwhile (");
1628 outputLeaf(file, mode, exprs[2]);
1629#if LUASL_DIFF_CHECK
1630 fprintf(file, "%s)\n", eina_strbuf_string_get(statement->parenthesis->rightIgnorable));
1631#else
1632 fprintf(file, ") do\n");
1633#endif
1634 if (statement->block)
1635 {
1636 LSL_Statement *stat = NULL;
1637
1638#if LUASL_DIFF_CHECK
1639 if (statement->block->openIgnorable)
1640 fwrite(eina_strbuf_string_get(statement->block->openIgnorable), 1, eina_strbuf_length_get(statement->block->openIgnorable), file);
1641#endif
1642 EINA_CLIST_FOR_EACH_ENTRY(stat, &(statement->block->statements), LSL_Statement, statement)
1643 {
1644 outputRawStatement(file, mode, stat);
1645 }
1646#if LUASL_DIFF_CHECK
1647 if (statement->block->closeIgnorable)
1648 fwrite(eina_strbuf_string_get(statement->block->closeIgnorable), 1, eina_strbuf_length_get(statement->block->closeIgnorable), file);
1649#endif
1650 }
1651 if (statement->single)
1652 outputRawStatement(file, mode, statement->single);
1653 fprintf(file, "\n");
1654 outputLeaf(file, mode, exprs[4]);
1655 fprintf(file, ";\nend\n");
1656 return;
1657 }
1619 break; 1658 break;
1620 } 1659 }
1621 case LSL_IF : 1660 case LSL_IF :
@@ -1626,16 +1665,72 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1626 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); 1665 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file);
1627#endif 1666#endif
1628 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); 1667 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1668 if (OM_LUA == mode)
1669 {
1670 if (statement->parenthesis)
1671 outputRawParenthesisToken(file, mode, statement->parenthesis, "");
1672 else
1673 outputLeaf(file, mode, statement->expressions);
1674 fprintf(file, " then\n");
1675 if (statement->block)
1676 {
1677 LSL_Statement *stat = NULL;
1678
1679#if LUASL_DIFF_CHECK
1680 if (statement->block->openIgnorable)
1681 fwrite(eina_strbuf_string_get(statement->block->openIgnorable), 1, eina_strbuf_length_get(statement->block->openIgnorable), file);
1682#endif
1683 EINA_CLIST_FOR_EACH_ENTRY(stat, &(statement->block->statements), LSL_Statement, statement)
1684 {
1685 outputRawStatement(file, mode, stat);
1686 }
1687#if LUASL_DIFF_CHECK
1688 if (statement->block->closeIgnorable)
1689 fwrite(eina_strbuf_string_get(statement->block->closeIgnorable), 1, eina_strbuf_length_get(statement->block->closeIgnorable), file);
1690#endif
1691 }
1692 if (statement->single)
1693 outputRawStatement(file, mode, statement->single);
1694 if (statement->elseBlock)
1695 outputRawStatement(file, mode, statement->elseBlock);
1696 fprintf(file, "\nend\n");
1697 return;
1698 }
1629 break; 1699 break;
1630 } 1700 }
1631 case LSL_ELSE : 1701 case LSL_ELSE :
1632 { 1702 {
1633 isBlock = TRUE; 1703 isBlock = TRUE;
1634#if LUASL_DIFF_CHECK 1704#if LUASL_DIFF_CHECK
1635 if ((statement->ignorable) && (statement->ignorable[1])) 1705 if ((statement->ignorable) && (statement->ignorable[1]))
1636 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); 1706 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file);
1637#endif 1707#endif
1638 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); 1708 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1709 if (OM_LUA == mode)
1710 {
1711 // TODO - look ahead to se if it's an elseif.
1712 // Or not, seems to have happened by accident. lol
1713 if (statement->block)
1714 {
1715 LSL_Statement *stat = NULL;
1716
1717#if LUASL_DIFF_CHECK
1718 if (statement->block->openIgnorable)
1719 fwrite(eina_strbuf_string_get(statement->block->openIgnorable), 1, eina_strbuf_length_get(statement->block->openIgnorable), file);
1720#endif
1721 EINA_CLIST_FOR_EACH_ENTRY(stat, &(statement->block->statements), LSL_Statement, statement)
1722 {
1723 outputRawStatement(file, mode, stat);
1724 }
1725#if LUASL_DIFF_CHECK
1726 if (statement->block->closeIgnorable)
1727 fwrite(eina_strbuf_string_get(statement->block->closeIgnorable), 1, eina_strbuf_length_get(statement->block->closeIgnorable), file);
1728#endif
1729 }
1730 if (statement->single)
1731 outputRawStatement(file, mode, statement->single);
1732 return;
1733 }
1639 break; 1734 break;
1640 } 1735 }
1641 case LSL_JUMP : 1736 case LSL_JUMP :
@@ -1675,10 +1770,25 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1675 { 1770 {
1676 isBlock = TRUE; 1771 isBlock = TRUE;
1677#if LUASL_DIFF_CHECK 1772#if LUASL_DIFF_CHECK
1678 if ((statement->ignorable) && (statement->ignorable[1])) 1773 if ((statement->ignorable) && (statement->ignorable[1]))
1679 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); 1774 fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file);
1775#else
1776 if (OM_LUA == mode)
1777 fprintf(file, "\n");
1680#endif 1778#endif
1681 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); 1779 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1780 if (OM_LUA == mode)
1781 {
1782 if (statement->parenthesis)
1783 outputRawParenthesisToken(file, mode, statement->parenthesis, "");
1784 fprintf(file, " do ");
1785 if (statement->block)
1786 outputRawBlock(file, mode, statement->block);
1787 if (statement->single)
1788 outputRawStatement(file, mode, statement->single);
1789 fprintf(file, "\n");
1790 return;
1791 }
1682 break; 1792 break;
1683 } 1793 }
1684 case LSL_IDENTIFIER : 1794 case LSL_IDENTIFIER :