aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 16:41:00 +1000
committerDavid Walter Seikel2012-02-02 16:41:00 +1000
commit8f6add72b4fea14599ab637433b087951f631053 (patch)
treeaae21e7d96539f63f47b488fc3aeec529d04dbfd /LuaSL/src
parentSome Lua conversions. Types, typecasts, blocks, list, vector, rotation. (diff)
downloadSledjHamr-8f6add72b4fea14599ab637433b087951f631053.zip
SledjHamr-8f6add72b4fea14599ab637433b087951f631053.tar.gz
SledjHamr-8f6add72b4fea14599ab637433b087951f631053.tar.bz2
SledjHamr-8f6add72b4fea14599ab637433b087951f631053.tar.xz
More Lua conversions. Concatenate, function arguments and table elemnt separaters.
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h2
-rw-r--r--LuaSL/src/LuaSL_compile.c33
2 files changed, 28 insertions, 7 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 615a905..6273d60 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -3,7 +3,7 @@
3#define __LUASL_TREE_H__ 3#define __LUASL_TREE_H__
4 4
5#define LUASL_DEBUG 0 5#define LUASL_DEBUG 0
6#define LUASL_DIFF_CHECK 1 6#define LUASL_DIFF_CHECK 0
7 7
8 8
9#include <stddef.h> // So we can have NULL defined. 9#include <stddef.h> // So we can have NULL defined.
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index b4ed295..eac098b 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -424,6 +424,10 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
424 rType = allowed[rType].result; 424 rType = allowed[rType].result;
425 } 425 }
426 426
427 // Convert add to concatenate if needed.
428 if ((LSL_ADD == lval->toKen->type) && (OT_string == lType) && (OT_string == rType))
429 lval->toKen = tokens[LSL_CONCATENATE - lowestToken];
430
427 switch (lval->toKen->subType) 431 switch (lval->toKen->subType)
428 { 432 {
429 case ST_BOOLEAN : 433 case ST_BOOLEAN :
@@ -1496,8 +1500,15 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf)
1496 leaf->toKen->output(file, mode, leaf); 1500 leaf->toKen->output(file, mode, leaf);
1497 else 1501 else
1498 { 1502 {
1499 if ((OM_LUA == mode) && (LSL_TYPE & leaf->toKen->flags)) 1503 if (OM_LUA == mode)
1500 fprintf(file, "--[[%s]] ", leaf->toKen->toKen); 1504 {
1505 if (LSL_TYPE & leaf->toKen->flags)
1506 fprintf(file, " --[[%s]] ", leaf->toKen->toKen);
1507 else if (LSL_CONCATENATE == leaf->toKen->type)
1508 fprintf(file, " .. ");
1509 else
1510 fprintf(file, "%s", leaf->toKen->toKen);
1511 }
1501 else 1512 else
1502 fprintf(file, "%s", leaf->toKen->toKen); 1513 fprintf(file, "%s", leaf->toKen->toKen);
1503 } 1514 }
@@ -1544,7 +1555,7 @@ static void outputRawParenthesisToken(FILE *file, outputMode mode, LSL_Parenthes
1544{ 1555{
1545 if ((OM_LUA == mode) && (LSL_TYPECAST_OPEN == parenthesis->type)) 1556 if ((OM_LUA == mode) && (LSL_TYPECAST_OPEN == parenthesis->type))
1546 { 1557 {
1547 fprintf(file, "--[[(%s)]] ", typeName); 1558 fprintf(file, " --[[(%s)]] ", typeName);
1548 outputLeaf(file, mode, parenthesis->contents); 1559 outputLeaf(file, mode, parenthesis->contents);
1549 return; 1560 return;
1550 } 1561 }
@@ -1688,6 +1699,9 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1688#if LUASL_DIFF_CHECK 1699#if LUASL_DIFF_CHECK
1689 if ((statement->ignorable) && (statement->ignorable[2])) 1700 if ((statement->ignorable) && (statement->ignorable[2]))
1690 fwrite(eina_strbuf_string_get(statement->ignorable[2]), 1, eina_strbuf_length_get(statement->ignorable[2]), file); 1701 fwrite(eina_strbuf_string_get(statement->ignorable[2]), 1, eina_strbuf_length_get(statement->ignorable[2]), file);
1702#else
1703 if (OM_LUA == mode)
1704 fprintf(file, " ");
1691#endif 1705#endif
1692 if (LSL_FOR == statement->type) 1706 if (LSL_FOR == statement->type)
1693 { 1707 {
@@ -1813,13 +1827,16 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content)
1813 { 1827 {
1814 fprintf(file, "\n\nfunction "); 1828 fprintf(file, "\n\nfunction ");
1815 if (func->type.text) 1829 if (func->type.text)
1816 fprintf(file, "--[[%s]] ", func->type.text); 1830 fprintf(file, " --[[%s]] ", func->type.text);
1817 fprintf(file, "%s(", func->name.text); 1831 fprintf(file, "%s(", func->name.text);
1818 EINA_INARRAY_FOREACH((&(func->vars)), param) 1832 EINA_INARRAY_FOREACH((&(func->vars)), param)
1819 { 1833 {
1820 // TODO - comment out param types. 1834 // TODO - comment out param types.
1821// if (!first) 1835 if (!LUASL_DIFF_CHECK)
1822// fprintf(file, ", "); 1836 {
1837 if (!first)
1838 fprintf(file, ", ");
1839 }
1823 outputLeaf(file, mode, param); 1840 outputLeaf(file, mode, param);
1824 first = FALSE; 1841 first = FALSE;
1825 } 1842 }
@@ -1842,6 +1859,8 @@ static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *conte
1842 EINA_INARRAY_FOREACH((&(call->params)), param) 1859 EINA_INARRAY_FOREACH((&(call->params)), param)
1843 { 1860 {
1844 outputLeaf(file, mode, param); 1861 outputLeaf(file, mode, param);
1862 if (OM_LUA == mode)
1863 fprintf(file, ", ");
1845 } 1864 }
1846 fprintf(file, ")"); 1865 fprintf(file, ")");
1847 } 1866 }
@@ -1904,6 +1923,8 @@ static void outputListToken(FILE *file, outputMode mode, LSL_Leaf *content)
1904 EINA_INARRAY_FOREACH((&(call->params)), param) 1923 EINA_INARRAY_FOREACH((&(call->params)), param)
1905 { 1924 {
1906 outputLeaf(file, mode, param); 1925 outputLeaf(file, mode, param);
1926 if (OM_LUA == mode)
1927 fprintf(file, ", ");
1907 } 1928 }
1908#if LUASL_DIFF_CHECK 1929#if LUASL_DIFF_CHECK
1909 ig = eina_strbuf_string_get(parens->rightIgnorable); 1930 ig = eina_strbuf_string_get(parens->rightIgnorable);