diff options
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 16e1c1d..dbc7031 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -1,8 +1,10 @@ | |||
1 | |||
1 | #include "LuaSL.h" | 2 | #include "LuaSL.h" |
2 | 3 | ||
3 | /* TODO - problem de jour | 4 | /* TODO - problem de jour |
4 | */ | 5 | */ |
5 | 6 | ||
7 | |||
6 | static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 8 | static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
7 | static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 9 | static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
8 | static LSL_Leaf *evaluateNoToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 10 | static LSL_Leaf *evaluateNoToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
@@ -156,19 +158,19 @@ LSL_Token LSL_Tokens[] = | |||
156 | }; | 158 | }; |
157 | 159 | ||
158 | // VERY IMPORTANT to keep this in sync with enum opType from LuaSL_LSL_tree.h! | 160 | // VERY IMPORTANT to keep this in sync with enum opType from LuaSL_LSL_tree.h! |
159 | allowedTypes allowed[] = | 161 | allowedTypes allowed[] = |
160 | { | 162 | { |
161 | {OT_nothing, "nothing", (ST_NONE)}, // | 163 | {OT_nothing, "nothing", (ST_NONE)}, // |
162 | 164 | ||
163 | {OT_bool, "boolean", (ST_BOOL_NOT)}, // bool ! | 165 | {OT_bool, "boolean", (ST_BOOL_NOT)}, // bool ! |
164 | {OT_integer, "integer", (ST_BOOL_NOT | ST_BIT_NOT | ST_NEGATE)}, // int ! - ~ | 166 | {OT_integer, "integer", (ST_BOOL_NOT | ST_BIT_NOT | ST_NEGATE)}, // int ! - ~ |
165 | {OT_float, "float", (ST_BOOL_NOT | ST_NEGATE)}, // float ! - | 167 | {OT_float, "float", (ST_BOOL_NOT | ST_NEGATE)}, // float ! - |
166 | {OT_key, "key", (ST_BOOL_NOT)}, // key ! | 168 | {OT_key, "key", (ST_BOOL_NOT)}, // key ! |
167 | {OT_list, "list", (ST_NONE)}, // | 169 | {OT_list, "list", (ST_NONE)}, // |
168 | {OT_rotation, "rotation", (ST_NONE)}, // | 170 | {OT_rotation, "rotation", (ST_NONE)}, // |
169 | {OT_string, "string", (ST_BOOL_NOT)}, // string ! | 171 | {OT_string, "string", (ST_BOOL_NOT)}, // string ! |
170 | {OT_vector, "vector", (ST_NONE)}, // | 172 | {OT_vector, "vector", (ST_NONE)}, // |
171 | {OT_other, "other", (ST_NONE)}, // | 173 | {OT_other, "other", (ST_NONE)}, // |
172 | 174 | ||
173 | {OT_bool, "boolean", (ST_BOOLEAN | ST_EQUALITY)}, // bool bool == != = && || | 175 | {OT_bool, "boolean", (ST_BOOLEAN | ST_EQUALITY)}, // bool bool == != = && || |
174 | 176 | ||
@@ -176,7 +178,7 @@ allowedTypes allowed[] = | |||
176 | {OT_integer, "integer", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT | ST_MODULO | ST_BITWISE)}, // int int * / + - % == != < > <= >= = += -= *= /= %= & | ^ << >> | 178 | {OT_integer, "integer", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT | ST_MODULO | ST_BITWISE)}, // int int * / + - % == != < > <= >= = += -= *= /= %= & | ^ << >> |
177 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // int float cast to float float | 179 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // int float cast to float float |
178 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // float int cast to float float | 180 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // float int cast to float float |
179 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // float float * / + - == != < > <= >= = += -= *= /= | 181 | {OT_float, "float", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_COMPARISON | ST_CONCATENATION | ST_ASSIGNMENT)}, // float float * / + - == != < > <= >= = += -= *= /= |
180 | 182 | ||
181 | {OT_string, "string", (ST_ADD | ST_EQUALITY | ST_CONCATENATION)}, // key key cast to string string | 183 | {OT_string, "string", (ST_ADD | ST_EQUALITY | ST_CONCATENATION)}, // key key cast to string string |
182 | {OT_string, "string", (ST_ADD | ST_EQUALITY | ST_CONCATENATION)}, // key string cast to string string | 184 | {OT_string, "string", (ST_ADD | ST_EQUALITY | ST_CONCATENATION)}, // key string cast to string string |
@@ -196,11 +198,11 @@ allowedTypes allowed[] = | |||
196 | {OT_vector, "vector", (ST_MULTIPLY | ST_ASSIGNMENT)}, // vector float * / *= /= | 198 | {OT_vector, "vector", (ST_MULTIPLY | ST_ASSIGNMENT)}, // vector float * / *= /= |
197 | {OT_vector, "vector", (ST_MULTIPLY)}, // vector rotation * / | 199 | {OT_vector, "vector", (ST_MULTIPLY)}, // vector rotation * / |
198 | 200 | ||
199 | {OT_rotation, "rotation", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_CONCATENATION | ST_ASSIGNMENT)}, // rotation rotation * / + - == != = += -= *= /= | 201 | {OT_rotation, "rotation", (ST_MULTIPLY | ST_ADD | ST_SUBTRACT | ST_EQUALITY | ST_CONCATENATION | ST_ASSIGNMENT)}, // rotation rotation * / + - == != = += -= *= /= |
200 | 202 | ||
201 | {OT_other, "other", (ST_NONE)}, // | 203 | {OT_other, "other", (ST_NONE)}, // |
202 | {OT_undeclared, "undeclared", (ST_NONE)}, // | 204 | {OT_undeclared, "undeclared", (ST_NONE)}, // |
203 | {OT_invalid, "invalid", (ST_NONE)} // | 205 | {OT_invalid, "invalid", (ST_NONE)} // |
204 | }; | 206 | }; |
205 | 207 | ||
206 | opType opExpr[][10] = | 208 | opType opExpr[][10] = |
@@ -269,7 +271,7 @@ static LSL_Leaf *findFunction(LuaSL_compiler *compiler, const char *name) | |||
269 | } | 271 | } |
270 | else | 272 | else |
271 | func = eina_hash_find(compiler->script.functions, name); | 273 | func = eina_hash_find(compiler->script.functions, name); |
272 | 274 | ||
273 | } | 275 | } |
274 | 276 | ||
275 | return func; | 277 | return func; |
@@ -499,7 +501,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
499 | * buggerAround(); | 501 | * buggerAround(); |
500 | * } | 502 | * } |
501 | * | 503 | * |
502 | * Turns into - | 504 | * Turns into - |
503 | * | 505 | * |
504 | * x = doSomething(); | 506 | * x = doSomething(); |
505 | * while (x == foo) | 507 | * while (x == foo) |
@@ -873,13 +875,13 @@ LSL_Leaf *addNumby(LSL_Leaf *numby) | |||
873 | case LSL_FLOAT : | 875 | case LSL_FLOAT : |
874 | { | 876 | { |
875 | num->value.floatValue = atof(num->text.text); | 877 | num->value.floatValue = atof(num->text.text); |
876 | numby->basicType = OT_float; | 878 | numby->basicType = OT_float; |
877 | break; | 879 | break; |
878 | } | 880 | } |
879 | case LSL_INTEGER : | 881 | case LSL_INTEGER : |
880 | { | 882 | { |
881 | num->value.integerValue = atoi(num->text.text); | 883 | num->value.integerValue = atoi(num->text.text); |
882 | numby->basicType = OT_integer; | 884 | numby->basicType = OT_integer; |
883 | break; | 885 | break; |
884 | } | 886 | } |
885 | default: | 887 | default: |
@@ -2620,7 +2622,7 @@ boolean compileLSL(gameGlobals *game, char *script, boolean doConstants) | |||
2620 | // Take the result of the parse, and convert it into Lua source. | 2622 | // Take the result of the parse, and convert it into Lua source. |
2621 | // Each LSL script becomes a Lua state. | 2623 | // Each LSL script becomes a Lua state. |
2622 | // LSL states are handled as Lua tables, with each LSL state function being a table function in a common metatable. | 2624 | // LSL states are handled as Lua tables, with each LSL state function being a table function in a common metatable. |
2623 | // LL and OS functions are likely to be C functions. | 2625 | // LL and OS functions are likely to be C functions. |
2624 | 2626 | ||
2625 | // Compile the Lua source by the Lua compiler. | 2627 | // Compile the Lua source by the Lua compiler. |
2626 | 2628 | ||
@@ -2770,4 +2772,3 @@ int main(int argc, char **argv) | |||
2770 | return 0; | 2772 | return 0; |
2771 | } | 2773 | } |
2772 | #endif | 2774 | #endif |
2773 | |||