diff options
author | David Walter Seikel | 2012-01-19 13:59:45 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-19 13:59:45 +1000 |
commit | 22dcf99d33bba85e719cf13ab77d534562a7647f (patch) | |
tree | 0bcd864d2377afee706af3fc3592a84257c44d20 | |
parent | Add a note about Lua truth values. (diff) | |
download | SledjHamr-22dcf99d33bba85e719cf13ab77d534562a7647f.zip SledjHamr-22dcf99d33bba85e719cf13ab77d534562a7647f.tar.gz SledjHamr-22dcf99d33bba85e719cf13ab77d534562a7647f.tar.bz2 SledjHamr-22dcf99d33bba85e719cf13ab77d534562a7647f.tar.xz |
More notes about Lua quirks.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index b9d6d48..1007c89 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -30,6 +30,9 @@ LSL_Token LSL_Tokens[] = | |||
30 | // QUIRK - Seems to be some disagreement about BOOL_AND/BOOL_OR precedence. Either they are equal, or OR is higher. | 30 | // QUIRK - Seems to be some disagreement about BOOL_AND/BOOL_OR precedence. Either they are equal, or OR is higher. |
31 | // QUIRK - No boolean short circuiting. | 31 | // QUIRK - No boolean short circuiting. |
32 | // QUIRK - Booleans and conditionals are executed right to left. Or maybe not, depending on who you believe. | 32 | // QUIRK - Booleans and conditionals are executed right to left. Or maybe not, depending on who you believe. |
33 | // LUA - Short circiuts boolean operations, and goes left to right. | ||
34 | // LUA - "and" returns its first argument if it is false, otherwise, it returns its second argument. "or" returns its first argument if it is not false, otherwise it returns its second argument. | ||
35 | // Note that the above means that "and/or" can return any type. | ||
33 | {LSL_BOOL_OR, ST_BOOLEAN, "||", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, | 36 | {LSL_BOOL_OR, ST_BOOLEAN, "||", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, |
34 | {LSL_BIT_OR, ST_BITWISE, "|", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, | 37 | {LSL_BIT_OR, ST_BITWISE, "|", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, |
35 | {LSL_BIT_XOR, ST_BITWISE, "^", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, | 38 | {LSL_BIT_XOR, ST_BITWISE, "^", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, |
@@ -41,6 +44,7 @@ LSL_Token LSL_Tokens[] = | |||
41 | {LSL_LESS_EQUAL, ST_COMPARISON, "<=", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, | 44 | {LSL_LESS_EQUAL, ST_COMPARISON, "<=", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, |
42 | {LSL_GREATER_THAN, ST_COMPARISON, ">", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, | 45 | {LSL_GREATER_THAN, ST_COMPARISON, ">", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, |
43 | {LSL_LESS_THAN, ST_COMPARISON, "<", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, | 46 | {LSL_LESS_THAN, ST_COMPARISON, "<", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, |
47 | // LUA - comparisons are always false if they are different types. Tables, userdata, and functions are compared by reference. Strings campare in alphabetical order, depending on current locale. | ||
44 | {LSL_RIGHT_SHIFT, ST_BITWISE, ">>", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, | 48 | {LSL_RIGHT_SHIFT, ST_BITWISE, ">>", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, |
45 | {LSL_LEFT_SHIFT, ST_BITWISE, "<<", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, | 49 | {LSL_LEFT_SHIFT, ST_BITWISE, "<<", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, |
46 | {LSL_CONCATENATE, ST_ADD, "+", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, | 50 | {LSL_CONCATENATE, ST_ADD, "+", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, |
@@ -54,6 +58,17 @@ LSL_Token LSL_Tokens[] = | |||
54 | {LSL_NEGATION, ST_NEGATE, "-", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, | 58 | {LSL_NEGATION, ST_NEGATE, "-", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, |
55 | {LSL_BOOL_NOT, ST_BOOL_NOT, "!", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, | 59 | {LSL_BOOL_NOT, ST_BOOL_NOT, "!", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, |
56 | {LSL_BIT_NOT, ST_BIT_NOT, "~", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, | 60 | {LSL_BIT_NOT, ST_BIT_NOT, "~", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, |
61 | |||
62 | // LUA precedence - (it has no bit operators, at least not until 5.2, but LuaJIT has them.) | ||
63 | // or | ||
64 | // and | ||
65 | // < > <= >= ~= == | ||
66 | // .. | ||
67 | // + - | ||
68 | // * / | ||
69 | // not negate | ||
70 | // exponentiation (^) | ||
71 | |||
57 | {LSL_TYPECAST_CLOSE, ST_NONE, ")", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateNoToken}, | 72 | {LSL_TYPECAST_CLOSE, ST_NONE, ")", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateNoToken}, |
58 | {LSL_TYPECAST_OPEN, ST_NONE, "(", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, | 73 | {LSL_TYPECAST_OPEN, ST_NONE, "(", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, |
59 | {LSL_ANGLE_CLOSE, ST_NONE, ">", LSL_LEFT2RIGHT | LSL_CREATION, NULL, evaluateNoToken}, | 74 | {LSL_ANGLE_CLOSE, ST_NONE, ">", LSL_LEFT2RIGHT | LSL_CREATION, NULL, evaluateNoToken}, |