diff options
author | David Walter Seikel | 2012-02-03 11:56:17 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-03 11:56:17 +1000 |
commit | 219498b453584dae9ffe7b71ffd97d3f5a0f9f60 (patch) | |
tree | 04278f7e3cb5ab4c3f5b9ab5d85e303a13c1b79f /LuaSL | |
parent | More Lua conversions. For, if, else, elseif (sorta), and while. (diff) | |
download | SledjHamr-219498b453584dae9ffe7b71ffd97d3f5a0f9f60.zip SledjHamr-219498b453584dae9ffe7b71ffd97d3f5a0f9f60.tar.gz SledjHamr-219498b453584dae9ffe7b71ffd97d3f5a0f9f60.tar.bz2 SledjHamr-219498b453584dae9ffe7b71ffd97d3f5a0f9f60.tar.xz |
LSL "else if" -> Lua "elseif", and it was a bitch. lol
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 137 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 9 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 1 |
3 files changed, 60 insertions, 87 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index e13c7e7..3488545 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -127,6 +127,7 @@ LSL_Token LSL_Tokens[] = | |||
127 | {LSL_DO, ST_NONE, "do", LSL_NONE, NULL, NULL}, | 127 | {LSL_DO, ST_NONE, "do", LSL_NONE, NULL, NULL}, |
128 | {LSL_FOR, ST_NONE, "for", LSL_NONE, NULL, NULL}, | 128 | {LSL_FOR, ST_NONE, "for", LSL_NONE, NULL, NULL}, |
129 | {LSL_ELSE, ST_NONE, "else", LSL_NONE, NULL, NULL}, | 129 | {LSL_ELSE, ST_NONE, "else", LSL_NONE, NULL, NULL}, |
130 | {LSL_ELSEIF, ST_NONE, "elseif", LSL_NONE, NULL, NULL}, | ||
130 | {LSL_IF, ST_NONE, "if", LSL_NONE, NULL, NULL}, | 131 | {LSL_IF, ST_NONE, "if", LSL_NONE, NULL, NULL}, |
131 | {LSL_JUMP, ST_NONE, "jump", LSL_NONE, NULL, NULL}, | 132 | {LSL_JUMP, ST_NONE, "jump", LSL_NONE, NULL, NULL}, |
132 | {LSL_RETURN, ST_NONE, "return", LSL_NONE, NULL, NULL}, | 133 | {LSL_RETURN, ST_NONE, "return", LSL_NONE, NULL, NULL}, |
@@ -837,7 +838,17 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi | |||
837 | 838 | ||
838 | LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock) | 839 | LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock) |
839 | { | 840 | { |
840 | ifBlock->value.statementValue->elseBlock = elseBlock->value.statementValue; | 841 | if (ifBlock->value.statementValue->elseBlock) |
842 | { | ||
843 | LSL_Statement *oldElseIf = ifBlock->value.statementValue->elseBlock; | ||
844 | |||
845 | while (oldElseIf->elseBlock) | ||
846 | oldElseIf = oldElseIf->elseBlock; | ||
847 | |||
848 | oldElseIf->elseBlock = elseBlock->value.statementValue; | ||
849 | } | ||
850 | else | ||
851 | ifBlock->value.statementValue->elseBlock = elseBlock->value.statementValue; | ||
841 | return ifBlock; | 852 | return ifBlock; |
842 | } | 853 | } |
843 | 854 | ||
@@ -924,6 +935,11 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, | |||
924 | justOne = TRUE; | 935 | justOne = TRUE; |
925 | break; | 936 | break; |
926 | } | 937 | } |
938 | case LSL_ELSEIF : | ||
939 | { | ||
940 | justOne = TRUE; | ||
941 | break; | ||
942 | } | ||
927 | case LSL_JUMP : | 943 | case LSL_JUMP : |
928 | { | 944 | { |
929 | justOne = TRUE; | 945 | justOne = TRUE; |
@@ -1432,6 +1448,10 @@ static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L | |||
1432 | { | 1448 | { |
1433 | break; | 1449 | break; |
1434 | } | 1450 | } |
1451 | case LSL_ELSEIF : | ||
1452 | { | ||
1453 | break; | ||
1454 | } | ||
1435 | case LSL_JUMP : | 1455 | case LSL_JUMP : |
1436 | { | 1456 | { |
1437 | break; | 1457 | break; |
@@ -1519,7 +1539,7 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) | |||
1519 | // Circular references, so declare this one first. | 1539 | // Circular references, so declare this one first. |
1520 | static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *statement); | 1540 | static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *statement); |
1521 | 1541 | ||
1522 | static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block) | 1542 | static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block, boolean doEnd) |
1523 | { | 1543 | { |
1524 | if (block) | 1544 | if (block) |
1525 | { | 1545 | { |
@@ -1533,7 +1553,7 @@ static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block) | |||
1533 | #else | 1553 | #else |
1534 | if (OM_LSL == mode) | 1554 | if (OM_LSL == mode) |
1535 | fprintf(file, "\n{\n"); | 1555 | fprintf(file, "\n{\n"); |
1536 | else if (OM_LUA == mode) | 1556 | else if (doEnd && (OM_LUA == mode)) |
1537 | fprintf(file, "\n"); | 1557 | fprintf(file, "\n"); |
1538 | #endif | 1558 | #endif |
1539 | EINA_CLIST_FOR_EACH_ENTRY(stat, &(block->statements), LSL_Statement, statement) | 1559 | EINA_CLIST_FOR_EACH_ENTRY(stat, &(block->statements), LSL_Statement, statement) |
@@ -1546,7 +1566,7 @@ static void outputRawBlock(FILE *file, outputMode mode, LSL_Block *block) | |||
1546 | #endif | 1566 | #endif |
1547 | if (OM_LSL == mode) | 1567 | if (OM_LSL == mode) |
1548 | fprintf(file, "}"); | 1568 | fprintf(file, "}"); |
1549 | else if (OM_LUA == mode) | 1569 | else if (doEnd && (OM_LUA == mode)) |
1550 | fprintf(file, "end "); | 1570 | fprintf(file, "end "); |
1551 | } | 1571 | } |
1552 | } | 1572 | } |
@@ -1611,8 +1631,8 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1611 | case LSL_FOR : | 1631 | case LSL_FOR : |
1612 | { | 1632 | { |
1613 | #if LUASL_DIFF_CHECK | 1633 | #if LUASL_DIFF_CHECK |
1614 | if ((statement->ignorable) && (statement->ignorable[1])) | 1634 | if ((statement->ignorable) && (statement->ignorable[1])) |
1615 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | 1635 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); |
1616 | #endif | 1636 | #endif |
1617 | if (OM_LSL == mode) | 1637 | if (OM_LSL == mode) |
1618 | { | 1638 | { |
@@ -1632,22 +1652,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1632 | fprintf(file, ") do\n"); | 1652 | fprintf(file, ") do\n"); |
1633 | #endif | 1653 | #endif |
1634 | if (statement->block) | 1654 | if (statement->block) |
1635 | { | 1655 | outputRawBlock(file, mode, statement->block, FALSE); |
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) | 1656 | if (statement->single) |
1652 | outputRawStatement(file, mode, statement->single); | 1657 | outputRawStatement(file, mode, statement->single); |
1653 | fprintf(file, "\n"); | 1658 | fprintf(file, "\n"); |
@@ -1658,77 +1663,41 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1658 | break; | 1663 | break; |
1659 | } | 1664 | } |
1660 | case LSL_IF : | 1665 | case LSL_IF : |
1666 | case LSL_ELSE : | ||
1667 | case LSL_ELSEIF : | ||
1661 | { | 1668 | { |
1662 | isBlock = TRUE; | 1669 | isBlock = TRUE; |
1663 | #if LUASL_DIFF_CHECK | 1670 | #if LUASL_DIFF_CHECK |
1664 | if ((statement->ignorable) && (statement->ignorable[1])) | 1671 | if ((statement->ignorable) && (statement->ignorable[1])) |
1665 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | 1672 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); |
1666 | #endif | 1673 | #endif |
1667 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1674 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1668 | if (OM_LUA == mode) | 1675 | if (OM_LUA == mode) |
1669 | { | 1676 | { |
1670 | if (statement->parenthesis) | 1677 | if (LSL_ELSE != statement->type) |
1671 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); | ||
1672 | else | ||
1673 | outputLeaf(file, mode, statement->expressions); | ||
1674 | fprintf(file, " then\n"); | ||
1675 | if (statement->block) | ||
1676 | { | 1678 | { |
1677 | LSL_Statement *stat = NULL; | 1679 | fprintf(file, " "); |
1678 | 1680 | if (statement->parenthesis) | |
1679 | #if LUASL_DIFF_CHECK | 1681 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); |
1680 | if (statement->block->openIgnorable) | 1682 | else |
1681 | fwrite(eina_strbuf_string_get(statement->block->openIgnorable), 1, eina_strbuf_length_get(statement->block->openIgnorable), file); | 1683 | outputLeaf(file, mode, statement->expressions); |
1682 | #endif | 1684 | fprintf(file, " then\n"); |
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 | } | 1685 | } |
1686 | if (statement->block) | ||
1687 | outputRawBlock(file, mode, statement->block, FALSE); | ||
1692 | if (statement->single) | 1688 | if (statement->single) |
1693 | outputRawStatement(file, mode, statement->single); | 1689 | outputRawStatement(file, mode, statement->single); |
1694 | if (statement->elseBlock) | 1690 | if (statement->elseBlock) |
1695 | outputRawStatement(file, mode, statement->elseBlock); | 1691 | outputRawStatement(file, mode, statement->elseBlock); |
1696 | fprintf(file, "\nend\n"); | 1692 | if (LSL_IF == statement->type) |
1697 | return; | ||
1698 | } | ||
1699 | break; | ||
1700 | } | ||
1701 | case LSL_ELSE : | ||
1702 | { | ||
1703 | isBlock = TRUE; | ||
1704 | #if LUASL_DIFF_CHECK | ||
1705 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1706 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1707 | #endif | ||
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 | { | 1693 | { |
1715 | LSL_Statement *stat = NULL; | 1694 | fprintf(file, " end --[["); |
1716 | 1695 | if (statement->parenthesis) | |
1717 | #if LUASL_DIFF_CHECK | 1696 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); |
1718 | if (statement->block->openIgnorable) | 1697 | else |
1719 | fwrite(eina_strbuf_string_get(statement->block->openIgnorable), 1, eina_strbuf_length_get(statement->block->openIgnorable), file); | 1698 | outputLeaf(file, mode, statement->expressions); |
1720 | #endif | 1699 | fprintf(file, "]]\n"); |
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 | } | 1700 | } |
1730 | if (statement->single) | ||
1731 | outputRawStatement(file, mode, statement->single); | ||
1732 | return; | 1701 | return; |
1733 | } | 1702 | } |
1734 | break; | 1703 | break; |
@@ -1783,7 +1752,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1783 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); | 1752 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); |
1784 | fprintf(file, " do "); | 1753 | fprintf(file, " do "); |
1785 | if (statement->block) | 1754 | if (statement->block) |
1786 | outputRawBlock(file, mode, statement->block); | 1755 | outputRawBlock(file, mode, statement->block, TRUE); |
1787 | if (statement->single) | 1756 | if (statement->single) |
1788 | outputRawStatement(file, mode, statement->single); | 1757 | outputRawStatement(file, mode, statement->single); |
1789 | fprintf(file, "\n"); | 1758 | fprintf(file, "\n"); |
@@ -1837,7 +1806,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1837 | outputLeaf(file, mode, statement->expressions); | 1806 | outputLeaf(file, mode, statement->expressions); |
1838 | 1807 | ||
1839 | if (statement->block) | 1808 | if (statement->block) |
1840 | outputRawBlock(file, mode, statement->block); | 1809 | outputRawBlock(file, mode, statement->block, TRUE); |
1841 | if (statement->single) | 1810 | if (statement->single) |
1842 | outputRawStatement(file, mode, statement->single); | 1811 | outputRawStatement(file, mode, statement->single); |
1843 | 1812 | ||
@@ -1861,7 +1830,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1861 | static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content) | 1830 | static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content) |
1862 | { | 1831 | { |
1863 | if (content) | 1832 | if (content) |
1864 | outputRawBlock(file, mode, content->value.blockValue); | 1833 | outputRawBlock(file, mode, content->value.blockValue, TRUE); |
1865 | } | 1834 | } |
1866 | 1835 | ||
1867 | static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content) | 1836 | static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content) |
@@ -1929,7 +1898,7 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
1929 | first = FALSE; | 1898 | first = FALSE; |
1930 | } | 1899 | } |
1931 | fprintf(file, ")"); | 1900 | fprintf(file, ")"); |
1932 | outputRawBlock(file, mode, func->block); | 1901 | outputRawBlock(file, mode, func->block, TRUE); |
1933 | if (!LUASL_DIFF_CHECK) | 1902 | if (!LUASL_DIFF_CHECK) |
1934 | fprintf(file, "\n"); | 1903 | fprintf(file, "\n"); |
1935 | } | 1904 | } |
@@ -1951,7 +1920,7 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
1951 | first = FALSE; | 1920 | first = FALSE; |
1952 | } | 1921 | } |
1953 | fprintf(file, ")"); | 1922 | fprintf(file, ")"); |
1954 | outputRawBlock(file, mode, func->block); | 1923 | outputRawBlock(file, mode, func->block, TRUE); |
1955 | } | 1924 | } |
1956 | } | 1925 | } |
1957 | } | 1926 | } |
@@ -2085,7 +2054,7 @@ static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
2085 | { | 2054 | { |
2086 | outputText(file, &(state->state), !(LSL_NOIGNORE & content->toKen->flags)); | 2055 | outputText(file, &(state->state), !(LSL_NOIGNORE & content->toKen->flags)); |
2087 | outputText(file, &(state->name), !(LSL_NOIGNORE & content->toKen->flags)); | 2056 | outputText(file, &(state->name), !(LSL_NOIGNORE & content->toKen->flags)); |
2088 | outputRawBlock(file, mode, state->block); | 2057 | outputRawBlock(file, mode, state->block, TRUE); |
2089 | } | 2058 | } |
2090 | } | 2059 | } |
2091 | } | 2060 | } |
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 9199699..716c65a 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -66,15 +66,18 @@ statementList(A) ::= statementList(B) statement(C). { A = collectSt | |||
66 | statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } | 66 | statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } |
67 | 67 | ||
68 | %nonassoc LSL_DO LSL_FOR LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. | 68 | %nonassoc LSL_DO LSL_FOR LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. |
69 | %nonassoc LSL_ELSE. | 69 | %nonassoc LSL_ELSE LSL_ELSEIF. |
70 | statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, L, E, R, B, W); } | 70 | statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, L, E, R, B, W); } |
71 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, B); } | 71 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, B); } |
72 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, S); } | 72 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addFor(compiler, NULL, F, L, E0, S0, E1, S1, E2, R, S); } |
73 | 73 | ||
74 | statement(A) ::= ifBlock(B). { A = B; } | 74 | statement(A) ::= ifBlock(B). { A = B; } |
75 | ifBlock(A) ::= ifBlock(B) elseIfBlock(E). { A = addIfElse(compiler, B, E); } | ||
75 | ifBlock(A) ::= ifBlock(B) elseBlock(E). { A = addIfElse(compiler, B, E); } | 76 | ifBlock(A) ::= ifBlock(B) elseBlock(E). { A = addIfElse(compiler, B, E); } |
76 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } | 77 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } |
77 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); } | 78 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); } |
79 | elseIfBlock(A) ::= LSL_ELSEIF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSEIF] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } | ||
80 | elseIfBlock(A) ::= LSL_ELSEIF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSEIF] { A = addStatement(compiler, NULL, F, L, E, R, S, NULL); } | ||
78 | elseBlock(A) ::= LSL_ELSE(F) block(B). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, B, NULL); } | 81 | elseBlock(A) ::= LSL_ELSE(F) block(B). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, B, NULL); } |
79 | elseBlock(A) ::= LSL_ELSE(F) statement(S). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, S, NULL); } | 82 | elseBlock(A) ::= LSL_ELSE(F) statement(S). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, S, NULL); } |
80 | 83 | ||
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index adee1a7..76d1b5b 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -96,6 +96,7 @@ STRING \"(\\.|[^\\"\n])*\" | |||
96 | "for" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FOR); %} | 96 | "for" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FOR); %} |
97 | "else" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSE); %} | 97 | "else" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSE); %} |
98 | "if" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_IF); %} | 98 | "if" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_IF); %} |
99 | "else"[[:space:]]+"if" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSEIF); %} /* TODO - deal with people that slap a comment in between them. */ | ||
99 | "jump" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_JUMP); %} | 100 | "jump" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_JUMP); %} |
100 | "return" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_RETURN); %} | 101 | "return" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_RETURN); %} |
101 | "state" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STATE_CHANGE); %} | 102 | "state" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STATE_CHANGE); %} |