aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h11
-rw-r--r--LuaSL/src/LuaSL_compile.c35
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y6
-rw-r--r--LuaSL/src/LuaSL_lexer.l3
-rw-r--r--LuaSL/src/LuaSL_main.c4
5 files changed, 29 insertions, 30 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 3c30129..ca5f844 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -11,7 +11,7 @@
11#include <sys/stat.h> 11#include <sys/stat.h>
12#include <fcntl.h> 12#include <fcntl.h>
13 13
14#include "assert.h" 14#include "assert.h"
15#include <unistd.h> 15#include <unistd.h>
16#include <sys/types.h> 16#include <sys/types.h>
17#include <sys/stat.h> 17#include <sys/stat.h>
@@ -28,7 +28,7 @@
28#include <luaproc/sched.h> 28#include <luaproc/sched.h>
29 29
30#include "LuaSL_lemon_yaccer.h" 30#include "LuaSL_lemon_yaccer.h"
31 31
32#define YYERRCODE 256 32#define YYERRCODE 256
33#define YYDEBUG 1 33#define YYDEBUG 1
34 34
@@ -67,7 +67,7 @@ typedef LSL_Leaf * (*evaluateToken) (LSL_Leaf *content, LSL_Leaf *left, LSL_Lea
67//#ifndef FALSE 67//#ifndef FALSE
68//typedef enum 68//typedef enum
69//{ 69//{
70// FALSE = 0, 70// FALSE = 0,
71// TRUE = 1 71// TRUE = 1
72//} boolean; 72//} boolean;
73//#endif 73//#endif
@@ -266,7 +266,7 @@ struct _LSL_Statement
266/* 266/*
267LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block); 267LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block);
268 268
269expr expr // Might be bogus, 269expr expr // Might be bogus,
270Variable defines identifier, optional expr // For these we only store the variable leaf in expressions. 270Variable defines identifier, optional expr // For these we only store the variable leaf in expressions.
271Function define identifier, block, parens // Also function params, but that's stored in the function anyway. 271Function define identifier, block, parens // Also function params, but that's stored in the function anyway.
272state change identifier 272state change identifier
@@ -395,7 +395,7 @@ Once the parser has condensed things down, it only deals with the
395condensed nodes. So we can get rid of some of the AST parts at this 395condensed nodes. So we can get rid of some of the AST parts at this
396time, so long as we keep the relevant information. This is what the 396time, so long as we keep the relevant information. This is what the
397other data structures above are for. Lemon tries to free the no longer 397other data structures above are for. Lemon tries to free the no longer
398needed AST nodes itself, even if we are still using them internally. 398needed AST nodes itself, even if we are still using them internally.
399Need to do something about that. 399Need to do something about that.
400 400
401*/ 401*/
@@ -464,4 +464,3 @@ void ParseFree(void *p, void (*freeProc)(void*));
464 464
465 465
466#endif // __LUASL_LSL_TREE_H__ 466#endif // __LUASL_LSL_TREE_H__
467
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
6static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 8static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
7static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 9static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
8static LSL_Leaf *evaluateNoToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 10static 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!
159allowedTypes allowed[] = 161allowedTypes 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
206opType opExpr[][10] = 208opType 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
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 71d4399..1ac3cc8 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -1,5 +1,6 @@
1%include { 1%include
2#include "LuaSL.h" 2{
3 #include "LuaSL.h"
3} 4}
4 5
5%extra_argument {LuaSL_compiler *compiler} 6%extra_argument {LuaSL_compiler *compiler}
@@ -272,4 +273,3 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; }
272%endif 273%endif
273 274
274*/ 275*/
275
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l
index 76d1b5b..85b2821 100644
--- a/LuaSL/src/LuaSL_lexer.l
+++ b/LuaSL/src/LuaSL_lexer.l
@@ -8,7 +8,7 @@ int common(YYSTYPE *lval, char *text, int len, LuaSL_compiler *compiler, boolean
8%} 8%}
9 9
10%option reentrant never-interactive batch 10%option reentrant never-interactive batch
11%option bison-bridge 8bit 11%option bison-bridge 8bit
12%option noreject noyymore 12%option noreject noyymore
13%option backup debug perf-report perf-report verbose warn 13%option backup debug perf-report perf-report verbose warn
14%option align full 14%option align full
@@ -162,4 +162,3 @@ int yywrap(yyscan_t yyscanner) // This as actually useless for our needs, as it
162 162
163 return 1; 163 return 1;
164} 164}
165
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 3ee2e8c..5601dde 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -1,3 +1,4 @@
1
1#include "LuaSL.h" 2#include "LuaSL.h"
2 3
3#define LUA_TEST 0 4#define LUA_TEST 0
@@ -313,7 +314,7 @@ main(int argc, char **argv)
313 314
314 if (badArgs) 315 if (badArgs)
315 { 316 {
316 // display the program usage to the user as they have it wrong 317 // display the program usage to the user as they have it wrong
317 printf("Usage: %s [-u]\n", programName); 318 printf("Usage: %s [-u]\n", programName);
318 printf(" -u: Show the test UI.\n"); 319 printf(" -u: Show the test UI.\n");
319 } 320 }
@@ -487,4 +488,3 @@ main(int argc, char **argv)
487 488
488 return 0; 489 return 0;
489} 490}
490