aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 12:59:47 +1000
committerDavid Walter Seikel2012-02-02 12:59:47 +1000
commit21bcc5ba96159d9b00d59e92ffc16078a0f4c4ed (patch)
treed124acf1b2b0ad32cda3a677316fd82df58b1269 /LuaSL/src
parentGet the right type for identifier subs. (diff)
downloadSledjHamr-21bcc5ba96159d9b00d59e92ffc16078a0f4c4ed.zip
SledjHamr-21bcc5ba96159d9b00d59e92ffc16078a0f4c4ed.tar.gz
SledjHamr-21bcc5ba96159d9b00d59e92ffc16078a0f4c4ed.tar.bz2
SledjHamr-21bcc5ba96159d9b00d59e92ffc16078a0f4c4ed.tar.xz
Partially implement parsing/outputting rotations and vectors.
Diffstat (limited to 'LuaSL/src')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h1
-rw-r--r--LuaSL/src/LuaSL_compile.c36
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y15
3 files changed, 37 insertions, 15 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 8be8afd..ca91ff0 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -421,6 +421,7 @@ LSL_Leaf *addNumby(LSL_Leaf *numby);
421LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 421LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
422LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); 422LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam);
423LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); 423LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval);
424LSL_Leaf *addRotVec(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right);
424LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifier, LSL_Leaf *block); 425LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifier, LSL_Leaf *block);
425LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier); 426LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier);
426LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr); 427LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr);
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 2d5878f..cf9d767 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -104,9 +104,9 @@ LSL_Token LSL_Tokens[] =
104 {LSL_INTEGER, ST_NONE, "integer", LSL_NONE, outputIntegerToken, evaluateIntegerToken}, 104 {LSL_INTEGER, ST_NONE, "integer", LSL_NONE, outputIntegerToken, evaluateIntegerToken},
105 {LSL_KEY, ST_NONE, "key", LSL_NONE, outputStringToken, NULL}, 105 {LSL_KEY, ST_NONE, "key", LSL_NONE, outputStringToken, NULL},
106 {LSL_LIST, ST_NONE, "list", LSL_NONE, outputListToken, NULL}, 106 {LSL_LIST, ST_NONE, "list", LSL_NONE, outputListToken, NULL},
107 {LSL_ROTATION, ST_NONE, "rotation", LSL_NONE, NULL, NULL}, 107 {LSL_ROTATION, ST_NONE, "rotation", LSL_NONE, outputListToken, NULL},
108 {LSL_STRING, ST_NONE, "string", LSL_NONE, outputStringToken, NULL}, 108 {LSL_STRING, ST_NONE, "string", LSL_NONE, outputStringToken, NULL},
109 {LSL_VECTOR, ST_NONE, "vector", LSL_NONE, NULL, NULL}, 109 {LSL_VECTOR, ST_NONE, "vector", LSL_NONE, outputListToken, NULL},
110 110
111 // Types names. 111 // Types names.
112 {LSL_TYPE_FLOAT, ST_NONE, "float", LSL_NONE, NULL, NULL}, 112 {LSL_TYPE_FLOAT, ST_NONE, "float", LSL_NONE, NULL, NULL},
@@ -724,6 +724,18 @@ LSL_Leaf *addList(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right)
724 return left; 724 return left;
725} 725}
726 726
727LSL_Leaf *addRotVec(LSL_Leaf *left, LSL_Leaf *list, LSL_Leaf *right)
728{
729 LSL_Type type = LSL_ROTATION;
730 opType otype = OT_rotation;
731
732 // TODO - count the members of list to see if it's a vector.
733 left = addParenthesis(left, list, type, right);
734 left->toKen = tokens[type - lowestToken];
735 left->basicType = otype;
736 return left;
737}
738
727LSL_Leaf *addNumby(LSL_Leaf *numby) 739LSL_Leaf *addNumby(LSL_Leaf *numby)
728{ 740{
729 LSL_Numby *num = calloc(1, sizeof(LSL_Numby)); 741 LSL_Numby *num = calloc(1, sizeof(LSL_Numby));
@@ -1820,18 +1832,30 @@ static void outputListToken(FILE *file, outputMode mode, LSL_Leaf *content)
1820 { 1832 {
1821 LSL_FunctionCall *call = parens->contents->value.functionCallValue; 1833 LSL_FunctionCall *call = parens->contents->value.functionCallValue;
1822 LSL_Leaf *param = NULL; 1834 LSL_Leaf *param = NULL;
1835 const char *ig = "";
1823 1836
1824 // TODO - should output it's own ignorable here. 1837 // TODO - should output it's own ignorable here.
1825 fprintf(file, "["); 1838 switch (parens->type)
1839 {
1840 case LSL_LIST : fprintf(file, "["); break;
1841 case LSL_ROTATION :
1842 case LSL_VECTOR : fprintf(file, "<");
1843 default : break;
1844 }
1826 EINA_INARRAY_FOREACH((&(call->params)), param) 1845 EINA_INARRAY_FOREACH((&(call->params)), param)
1827 { 1846 {
1828 outputLeaf(file, mode, param); 1847 outputLeaf(file, mode, param);
1829 } 1848 }
1830#if LUASL_DIFF_CHECK 1849#if LUASL_DIFF_CHECK
1831 fprintf(file, "%s]", eina_strbuf_string_get(parens->rightIgnorable)); 1850 ig = eina_strbuf_string_get(parens->rightIgnorable);
1832#else
1833 fprintf(file, "]");
1834#endif 1851#endif
1852 switch (parens->type)
1853 {
1854 case LSL_LIST : fprintf(file, "%s]", ig); break;
1855 case LSL_ROTATION :
1856 case LSL_VECTOR : fprintf(file, "%s>", ig);
1857 default : break;
1858 }
1835 } 1859 }
1836 } 1860 }
1837} 1861}
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index d2731d8..8b6c3d7 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -196,21 +196,18 @@ expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler,
196// Values. 196// Values.
197 197
198%nonassoc LSL_FLOAT. 198%nonassoc LSL_FLOAT.
199expr(A) ::= LSL_FLOAT(B). { A = addNumby(B); } 199expr(A) ::= LSL_FLOAT(B). { A = addNumby(B); }
200%nonassoc LSL_INTEGER. 200%nonassoc LSL_INTEGER.
201expr(A) ::= LSL_INTEGER(B). { A = addNumby(B); } 201expr(A) ::= LSL_INTEGER(B). { A = addNumby(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(L) exprList(E) LSL_BRACKET_CLOSE(R). [LSL_BRACKET_OPEN] { A = addList(L, E, R); } 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 LSL_VECTOR.
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(A) ::= LSL_LESS_THAN(L) exprList(E) LSL_GREATER_THAN(R). [LSL_ANGLE_OPEN] { A = addRotVec(L, E, R); }
209%nonassoc LSL_STRING. 209%nonassoc LSL_STRING.
210expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; } 210expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
211%nonassoc LSL_VECTOR.
212expr ::= LSL_VECTOR.
213expr ::= LSL_LESS_THAN expr LSL_COMMA expr LSL_COMMA expr LSL_GREATER_THAN. [LSL_ANGLE_OPEN]
214 211
215 212
216// Parser callbacks. 213// Parser callbacks.