aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_compile.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index eada67f..0183599 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -13,6 +13,7 @@ static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content);
13static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *content); 13static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *content);
14static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content); 14static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content);
15static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content); 15static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content);
16static void outputListToken(FILE *file, outputMode mode, LSL_Leaf *content);
16static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content); 17static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content);
17static void outputParenthesisToken(FILE *file, outputMode mode, LSL_Leaf *content); 18static void outputParenthesisToken(FILE *file, outputMode mode, LSL_Leaf *content);
18static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content); 19static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content);
@@ -101,7 +102,7 @@ LSL_Token LSL_Tokens[] =
101 {LSL_FLOAT, ST_NONE, "float", LSL_NONE, outputFloatToken, evaluateFloatToken}, 102 {LSL_FLOAT, ST_NONE, "float", LSL_NONE, outputFloatToken, evaluateFloatToken},
102 {LSL_INTEGER, ST_NONE, "integer", LSL_NONE, outputIntegerToken, evaluateIntegerToken}, 103 {LSL_INTEGER, ST_NONE, "integer", LSL_NONE, outputIntegerToken, evaluateIntegerToken},
103 {LSL_KEY, ST_NONE, "key", LSL_NONE, outputStringToken, NULL}, 104 {LSL_KEY, ST_NONE, "key", LSL_NONE, outputStringToken, NULL},
104 {LSL_LIST, ST_NONE, "list", LSL_NONE, NULL, NULL}, 105 {LSL_LIST, ST_NONE, "list", LSL_NONE, outputListToken, NULL},
105 {LSL_ROTATION, ST_NONE, "rotation", LSL_NONE, NULL, NULL}, 106 {LSL_ROTATION, ST_NONE, "rotation", LSL_NONE, NULL, NULL},
106 {LSL_STRING, ST_NONE, "string", LSL_NONE, outputStringToken, NULL}, 107 {LSL_STRING, ST_NONE, "string", LSL_NONE, outputStringToken, NULL},
107 {LSL_VECTOR, ST_NONE, "vector", LSL_NONE, NULL, NULL}, 108 {LSL_VECTOR, ST_NONE, "vector", LSL_NONE, NULL, NULL},
@@ -672,6 +673,14 @@ LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Le
672 return identifier; 673 return identifier;
673} 674}
674 675
676LSL_Leaf *addList(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right)
677{
678 left = addParenthesis(left, list, LSL_LIST, right);
679 left->toKen = tokens[LSL_LIST - lowestToken];
680 left->basicType = OT_list;
681 return left;
682}
683
675LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval) 684LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval)
676{ 685{
677 LSL_Parenthesis *parens = calloc(1, sizeof(LSL_Parenthesis)); 686 LSL_Parenthesis *parens = calloc(1, sizeof(LSL_Parenthesis));
@@ -1237,7 +1246,7 @@ static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL
1237 1246
1238 if (content) 1247 if (content)
1239 { 1248 {
1240 if (LSL_PARAMETER_LIST != content->value.parenthesis->type) 1249 if ((LSL_PARAMETER_LIST != content->value.parenthesis->type) && (LSL_LIST != content->value.parenthesis->type))
1241 result = evaluateLeaf(content->value.parenthesis->contents, left, right); 1250 result = evaluateLeaf(content->value.parenthesis->contents, left, right);
1242 } 1251 }
1243 return result; 1252 return result;
@@ -1610,6 +1619,32 @@ static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content
1610 } 1619 }
1611} 1620}
1612 1621
1622static void outputListToken(FILE *file, outputMode mode, LSL_Leaf *content)
1623{
1624 if (content)
1625 {
1626 LSL_Parenthesis *parens = content->value.parenthesis;
1627
1628 if (parens->contents)
1629 {
1630 LSL_FunctionCall *call = parens->contents->value.functionCallValue;
1631 LSL_Leaf *param = NULL;
1632
1633 // TODO - should output it's own ignorable here.
1634 fprintf(file, "[");
1635 EINA_INARRAY_FOREACH((&(call->params)), param)
1636 {
1637 outputLeaf(file, mode, param);
1638 }
1639#if LUASL_DIFF_CHECK
1640 fprintf(file, "%s]", eina_strbuf_string_get(parens->rightIgnorable));
1641#else
1642 fprintf(file, "]");
1643#endif
1644 }
1645 }
1646}
1647
1613static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) 1648static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content)
1614{ 1649{
1615 if (content) 1650 if (content)