diff options
author | David Walter Seikel | 2012-01-08 20:22:30 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-08 20:22:30 +1000 |
commit | aee5a20afb25260a8997d16f82cce0e71a41ebe1 (patch) | |
tree | ff9fbc9a4243dd44f9a3ac4e69215dfc0083aa8b /LuaSL/src | |
parent | Apparently order of these ALSO sets precedence. shrugs (diff) | |
download | SledjHamr-aee5a20afb25260a8997d16f82cce0e71a41ebe1.zip SledjHamr-aee5a20afb25260a8997d16f82cce0e71a41ebe1.tar.gz SledjHamr-aee5a20afb25260a8997d16f82cce0e71a41ebe1.tar.bz2 SledjHamr-aee5a20afb25260a8997d16f82cce0e71a41ebe1.tar.xz |
Bite the bullet and get rid of my dreams to use enums, yacc insists on #defines.
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 54 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 91 |
2 files changed, 26 insertions, 119 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index cc9007c..11a481d 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c | |||
@@ -272,44 +272,38 @@ static void evaluateOperationToken(LSL_Leaf *content, LSL_Value *left, LSL_Value | |||
272 | 272 | ||
273 | switch (content->operationValue) | 273 | switch (content->operationValue) |
274 | { | 274 | { |
275 | #ifdef LUASL_USE_ENUM | 275 | // case LSL_COMMA : |
276 | case LSL_COMMA : | 276 | // case LSL_INCREMENT_PRE : |
277 | case LSL_INCREMENT_PRE : | 277 | // case LSL_INCREMENT_POST : |
278 | case LSL_INCREMENT_POST : | 278 | // case LSL_DECREMENT_PRE : |
279 | case LSL_DECREMENT_PRE : | 279 | // case LSL_DECREMENT_POST : |
280 | case LSL_DECREMENT_POST : | 280 | // case LSL_DOT : |
281 | case LSL_DOT : | 281 | // case LSL_ASSIGNMENT_PLAIN : |
282 | case LSL_ASSIGNMENT_PLAIN : | 282 | // case LSL_ASSIGNMENT_DIVIDE : |
283 | case LSL_ASSIGNMENT_DIVIDE : | 283 | // case LSL_ASSIGNMENT_MODULO : |
284 | case LSL_ASSIGNMENT_MODULO : | 284 | // case LSL_ASSIGNMENT_MULTIPLY : |
285 | case LSL_ASSIGNMENT_MULTIPLY : | 285 | // case LSL_ASSIGNMENT_SUBTRACT : |
286 | case LSL_ASSIGNMENT_SUBTRACT : | 286 | // case LSL_ASSIGNMENT_ADD : |
287 | case LSL_ASSIGNMENT_ADD : | 287 | // case LSL_ASSIGNMENT_CONCATENATE : |
288 | case LSL_ASSIGNMENT_CONCATENATE : | 288 | // case LSL_PARENTHESIS_OPEN : |
289 | case LSL_PARENTHESIS_OPEN : | 289 | // case LSL_PARENTHESIS_CLOSE : |
290 | case LSL_PARENTHESIS_CLOSE : | 290 | // case LSL_BRACKET_OPEN : |
291 | case LSL_BRACKET_OPEN : | 291 | // case LSL_BRACKET_CLOSE : |
292 | case LSL_BRACKET_CLOSE : | 292 | // case LSL_ANGLE_OPEN : |
293 | case LSL_ANGLE_OPEN : | 293 | // case LSL_ANGLE_CLOSE : |
294 | case LSL_ANGLE_CLOSE : | 294 | // case LSL_TYPECAST : |
295 | case LSL_TYPECAST : | 295 | // break; |
296 | break; | ||
297 | #endif | ||
298 | case LSL_BIT_NOT : left->content.integerValue = ~ right->content.integerValue; break; | 296 | case LSL_BIT_NOT : left->content.integerValue = ~ right->content.integerValue; break; |
299 | case LSL_BOOL_NOT : left->content.integerValue = ! right->content.integerValue; break; | 297 | case LSL_BOOL_NOT : left->content.integerValue = ! right->content.integerValue; break; |
300 | case LSL_NEGATION : left->content.integerValue = 0 - right->content.integerValue; break; | 298 | case LSL_NEGATION : left->content.integerValue = 0 - right->content.integerValue; break; |
301 | case LSL_DIVIDE : left->content.integerValue = left->content.integerValue / right->content.integerValue; break; | 299 | case LSL_DIVIDE : left->content.integerValue = left->content.integerValue / right->content.integerValue; break; |
302 | case LSL_MODULO : left->content.integerValue = left->content.integerValue % right->content.integerValue; break; | 300 | case LSL_MODULO : left->content.integerValue = left->content.integerValue % right->content.integerValue; break; |
303 | case LSL_MULTIPLY : left->content.integerValue = left->content.integerValue * right->content.integerValue; break; | 301 | case LSL_MULTIPLY : left->content.integerValue = left->content.integerValue * right->content.integerValue; break; |
304 | #ifdef LUASL_USE_ENUM | 302 | // case LSL_DOT_PRODUCT : break; |
305 | case LSL_DOT_PRODUCT : break; | 303 | // case LSL_CROSS_PRODUCT : break; |
306 | case LSL_CROSS_PRODUCT : break; | ||
307 | #endif | ||
308 | case LSL_SUBTRACT : left->content.integerValue = left->content.integerValue - right->content.integerValue; break; | 304 | case LSL_SUBTRACT : left->content.integerValue = left->content.integerValue - right->content.integerValue; break; |
309 | case LSL_ADD : left->content.integerValue = left->content.integerValue + right->content.integerValue; break; | 305 | case LSL_ADD : left->content.integerValue = left->content.integerValue + right->content.integerValue; break; |
310 | #ifdef LUASL_USE_ENUM | 306 | // case LSL_CONCATENATE : break; |
311 | case LSL_CONCATENATE : break; | ||
312 | #endif | ||
313 | case LSL_LEFT_SHIFT : left->content.integerValue = left->content.integerValue << right->content.integerValue; break; | 307 | case LSL_LEFT_SHIFT : left->content.integerValue = left->content.integerValue << right->content.integerValue; break; |
314 | case LSL_RIGHT_SHIFT : left->content.integerValue = left->content.integerValue >> right->content.integerValue; break; | 308 | case LSL_RIGHT_SHIFT : left->content.integerValue = left->content.integerValue >> right->content.integerValue; break; |
315 | case LSL_LESS_THAN : left->content.integerValue = left->content.integerValue < right->content.integerValue; break; | 309 | case LSL_LESS_THAN : left->content.integerValue = left->content.integerValue < right->content.integerValue; break; |
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 0b2f125..257f18b 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -2,17 +2,15 @@ | |||
2 | #ifndef __EXPRESSION_H__ | 2 | #ifndef __EXPRESSION_H__ |
3 | #define __EXPRESSION_H__ | 3 | #define __EXPRESSION_H__ |
4 | 4 | ||
5 | //#define LUASL_USE_ENUM | ||
6 | #define LUASL_DEBUG | 5 | #define LUASL_DEBUG |
7 | 6 | ||
8 | #ifndef LUASL_USE_ENUM | ||
9 | #include "LuaSL_yaccer.tab.h" | ||
10 | #endif | ||
11 | 7 | ||
12 | #include <stddef.h> // So we can have NULL defined. | 8 | #include <stddef.h> // So we can have NULL defined. |
13 | #include <sys/types.h> | 9 | #include <sys/types.h> |
14 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
15 | #include <fcntl.h> | 11 | #include <fcntl.h> |
12 | |||
13 | #include "LuaSL_yaccer.tab.h" | ||
16 | 14 | ||
17 | #define YYERRCODE 256 | 15 | #define YYERRCODE 256 |
18 | #define YYDEBUG 1 | 16 | #define YYDEBUG 1 |
@@ -41,92 +39,7 @@ typedef enum | |||
41 | LSL_CREATION = 32 | 39 | LSL_CREATION = 32 |
42 | } LSL_Flags; | 40 | } LSL_Flags; |
43 | 41 | ||
44 | #ifdef LUASL_USE_ENUM | ||
45 | typedef enum // In order of precedence, high to low. | ||
46 | // Left to right, unless oterwise stated. | ||
47 | // According to http://wiki.secondlife.com/wiki/Category:LSL_Operators | ||
48 | { | ||
49 | LSL_COMMA = 257, | ||
50 | LSL_INCREMENT_PRE, // Right to left. | ||
51 | LSL_INCREMENT_POST, // Right to left. | ||
52 | LSL_DECREMENT_PRE, // Right to left. | ||
53 | LSL_DECREMENT_POST, // Right to left. | ||
54 | LSL_DOT, // Right to left. | ||
55 | LSL_ASSIGNMENT_PLAIN, // Right to left. | ||
56 | LSL_ASSIGNMENT_DIVIDE, // Right to left. | ||
57 | LSL_ASSIGNMENT_MODULO, // Right to left. | ||
58 | LSL_ASSIGNMENT_MULTIPLY, // Right to left. | ||
59 | LSL_ASSIGNMENT_SUBTRACT, // Right to left. | ||
60 | LSL_ASSIGNMENT_ADD, // Right to left. | ||
61 | LSL_ASSIGNMENT_CONCATENATE, // Right to left. | ||
62 | LSL_PARENTHESIS_OPEN, // Inner to outer. | ||
63 | LSL_PARENTHESIS_CLOSE, // Inner to outer. | ||
64 | LSL_BRACKET_OPEN, // Inner to outer. | ||
65 | LSL_BRACKET_CLOSE, // Inner to outer. | ||
66 | LSL_ANGLE_OPEN, | ||
67 | LSL_ANGLE_CLOSE, | ||
68 | LSL_TYPECAST, // Right to left. | ||
69 | LSL_BIT_NOT, // Right to left. | ||
70 | LSL_BOOL_NOT, // Right to left. | ||
71 | LSL_NEGATION, // Right to left. | ||
72 | LSL_DIVIDE, | ||
73 | LSL_MODULO, | ||
74 | LSL_MULTIPLY, | ||
75 | LSL_DOT_PRODUCT, | ||
76 | LSL_CROSS_PRODUCT, | ||
77 | LSL_SUBTRACT, | ||
78 | LSL_ADD, | ||
79 | LSL_CONCATENATE, | ||
80 | LSL_LEFT_SHIFT, | ||
81 | LSL_RIGHT_SHIFT, | ||
82 | LSL_LESS_THAN, | ||
83 | LSL_GREATER_THAN, | ||
84 | LSL_LESS_EQUAL, | ||
85 | LSL_GREATER_EQUAL, | ||
86 | LSL_EQUAL, | ||
87 | LSL_NOT_EQUAL, | ||
88 | LSL_BIT_AND, | ||
89 | LSL_BIT_XOR, | ||
90 | LSL_BIT_OR, | ||
91 | LSL_BOOL_OR, | ||
92 | LSL_BOOL_AND, | ||
93 | |||
94 | // The rest are not operater types. | ||
95 | |||
96 | LSL_SPACE, | ||
97 | LSL_COMMENT, | ||
98 | LSL_TYPE, | ||
99 | LSL_NAME, | ||
100 | LSL_IDENTIFIER, | ||
101 | LSL_FLOAT, | ||
102 | LSL_INTEGER, | ||
103 | LSL_STRING, | ||
104 | LSL_KEY, | ||
105 | LSL_VECTOR, | ||
106 | LSL_ROTATION, | ||
107 | LSL_LIST, | ||
108 | LSL_LABEL, | ||
109 | LSL_EXPRESSION, | ||
110 | LSL_DO, | ||
111 | LSL_FOR, | ||
112 | LSL_IF, | ||
113 | LSL_ELSE, | ||
114 | LSL_ELSEIF, | ||
115 | LSL_JUMP, | ||
116 | LSL_STATE_CHANGE, | ||
117 | LSL_WHILE, | ||
118 | LSL_RETURN, | ||
119 | LSL_STATEMENT, | ||
120 | LSL_BLOCK, | ||
121 | LSL_PARAMETER, | ||
122 | LSL_FUNCTION, | ||
123 | LSL_STATE, | ||
124 | LSL_SCRIPT, | ||
125 | LSL_UNKNOWN | ||
126 | } LSL_Type; | ||
127 | #else | ||
128 | typedef int LSL_Type; | 42 | typedef int LSL_Type; |
129 | #endif | ||
130 | 43 | ||
131 | typedef struct | 44 | typedef struct |
132 | { | 45 | { |