aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-01 22:50:34 +1000
committerDavid Walter Seikel2012-02-01 22:50:34 +1000
commit2b51cab943a6177bf0f1fd359242d03e44fe8046 (patch)
tree9d4c3b4b063dd987815f07249cf0be5e88e09f2c /LuaSL/src
parentDeal with parsing if ... else ... (diff)
downloadSledjHamr-2b51cab943a6177bf0f1fd359242d03e44fe8046.zip
SledjHamr-2b51cab943a6177bf0f1fd359242d03e44fe8046.tar.gz
SledjHamr-2b51cab943a6177bf0f1fd359242d03e44fe8046.tar.bz2
SledjHamr-2b51cab943a6177bf0f1fd359242d03e44fe8046.tar.xz
Parse and output lists.
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h1
-rw-r--r--LuaSL/src/LuaSL_compile.c39
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y2
3 files changed, 39 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index b5dff7a..33f860c 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -399,6 +399,7 @@ LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
399LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); 399LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block);
400LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); 400LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close);
401LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock); 401LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock);
402LSL_Leaf *addList(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right);
402LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 403LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
403LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); 404LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam);
404LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); 405LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval);
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)
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 72d328c..1d28ec5 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -202,7 +202,7 @@ expr(A) ::= LSL_INTEGER(B). { B->basicType = OT_integer; A = B; }
202%nonassoc LSL_KEY. 202%nonassoc LSL_KEY.
203expr(A) ::= LSL_KEY(B). { B->basicType = OT_key; A = B; } 203expr(A) ::= LSL_KEY(B). { B->basicType = OT_key; A = B; }
204%nonassoc LSL_LIST. 204%nonassoc LSL_LIST.
205expr(A) ::= LSL_BRACKET_OPEN(B) exprList LSL_BRACKET_CLOSE. [LSL_BRACKET_OPEN] { B->basicType = OT_list; A = B; } // Probably need a specific addList(). 205expr(A) ::= LSL_BRACKET_OPEN(L) exprList(E) LSL_BRACKET_CLOSE(R). [LSL_BRACKET_OPEN] { A = addList(L, E, R); }
206%nonassoc LSL_ROTATION. 206%nonassoc LSL_ROTATION.
207// Uses the same symbol for less than, greater than, and the rotation / vector delimiters. 207// Uses the same symbol for less than, greater than, and the rotation / vector delimiters.
208expr ::= LSL_LESS_THAN expr LSL_COMMA expr LSL_COMMA expr LSL_COMMA expr LSL_GREATER_THAN. [LSL_ANGLE_OPEN] 208expr ::= LSL_LESS_THAN expr LSL_COMMA expr LSL_COMMA expr LSL_COMMA expr LSL_GREATER_THAN. [LSL_ANGLE_OPEN]