aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-03 22:36:25 +1000
committerDavid Walter Seikel2012-02-03 22:36:25 +1000
commitba894de3014f02d0c6889b5e2df821b97a265bdb (patch)
tree075e7f15c65354f23c201c0197e7d252664d44f9 /LuaSL/src/LuaSL_compile.c
parentSeparate else and if if it's not an actual elseif. (diff)
downloadSledjHamr-ba894de3014f02d0c6889b5e2df821b97a265bdb.zip
SledjHamr-ba894de3014f02d0c6889b5e2df821b97a265bdb.tar.gz
SledjHamr-ba894de3014f02d0c6889b5e2df821b97a265bdb.tar.bz2
SledjHamr-ba894de3014f02d0c6889b5e2df821b97a265bdb.tar.xz
Assignments in the middle of expressions is legal in LSL, but not in Lua. Bump that problem until later.
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r--LuaSL/src/LuaSL_compile.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index e9a22c1..8194947 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -1,5 +1,40 @@
1#include "LuaSL.h" 1#include "LuaSL.h"
2 2
3/* TODO -
4
5Assignments in the middle of expressions is legal in LSL, but not in Lua.
6The big complication is that they often happen in the conditionals of flow control statements. That's a big bitch.
7
8So things like -
9
10 while ((x = doSomething()) == foo)
11 {
12 buggerAround();
13 }
14
15Turns into -
16
17 x = doSomething();
18 while (x == foo)
19 {
20 buggerAround();
21 x = doSomething();
22 }
23
24http://lua-users.org/wiki/StatementsInExpressions might be helpful. Which suggests something like this -
25
26 while ( (function() x = doSomething(); return x; end)() == foo)
27 {
28 buggerAround();
29 }
30
31The remaining problem is when to recognise the need to do that.
32Note that assignments are really low precedence.
33 While adding operations
34 Flag the assignment expressions
35 If there is an assignment expression (not operation) on the RHS of an operation, we need to do this?
36*/
37
3 38
4static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 39static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
5static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 40static LSL_Leaf *evaluateIntegerToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);