diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index 9f663e5..57e639a 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c | |||
@@ -50,31 +50,31 @@ LSL_Token LSL_Tokens[] = | |||
50 | {LSL_BIT_NOT, "~", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 50 | {LSL_BIT_NOT, "~", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
51 | // {LSL_TYPECAST_CLOSE, ")", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 51 | // {LSL_TYPECAST_CLOSE, ")", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
52 | // {LSL_TYPECAST_OPEN, "(", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 52 | // {LSL_TYPECAST_OPEN, "(", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
53 | // {LSL_ANGLE_CLOSE, ">", LSL_LEFT2RIGHT | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, | 53 | {LSL_ANGLE_CLOSE, ">", LSL_LEFT2RIGHT | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, |
54 | // {LSL_ANGLE_OPEN, "<", LSL_LEFT2RIGHT | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, | 54 | {LSL_ANGLE_OPEN, "<", LSL_LEFT2RIGHT | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, |
55 | // {LSL_BRACKET_CLOSE, "]", LSL_INNER2OUTER | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, | 55 | {LSL_BRACKET_CLOSE, "]", LSL_INNER2OUTER | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, |
56 | // {LSL_BRACKET_OPEN, "[", LSL_INNER2OUTER | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, | 56 | {LSL_BRACKET_OPEN, "[", LSL_INNER2OUTER | LSL_CREATION, outputOperationToken, NULL, evaluateOperationToken}, |
57 | {LSL_PARENTHESIS_CLOSE, ")", LSL_INNER2OUTER, NULL, NULL, evaluateNoToken}, | 57 | {LSL_PARENTHESIS_CLOSE, ")", LSL_INNER2OUTER, NULL, NULL, evaluateNoToken}, |
58 | {LSL_PARENTHESIS_OPEN, "(", LSL_INNER2OUTER, NULL, NULL, NULL}, | 58 | {LSL_PARENTHESIS_OPEN, "(", LSL_INNER2OUTER, NULL, NULL, NULL}, |
59 | // {LSL_ASSIGNMENT_CONCATENATE, "+=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 59 | // {LSL_ASSIGNMENT_CONCATENATE, "+=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
60 | // {LSL_ASSIGNMENT_ADD, "+=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 60 | {LSL_ASSIGNMENT_ADD, "+=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
61 | // {LSL_ASSIGNMENT_SUBTRACT, "-=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 61 | {LSL_ASSIGNMENT_SUBTRACT, "-=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
62 | // {LSL_ASSIGNMENT_MULTIPLY, "*=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 62 | {LSL_ASSIGNMENT_MULTIPLY, "*=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
63 | // {LSL_ASSIGNMENT_MODULO, "%=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 63 | {LSL_ASSIGNMENT_MODULO, "%=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
64 | // {LSL_ASSIGNMENT_DIVIDE, "/=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 64 | {LSL_ASSIGNMENT_DIVIDE, "/=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
65 | // {LSL_ASSIGNMENT_PLAIN, "=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, | 65 | {LSL_ASSIGNMENT_PLAIN, "=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, outputOperationToken, NULL, evaluateOperationToken}, |
66 | // {LSL_DOT, ".", LSL_RIGHT2LEFT, outputOperationToken, NULL, evaluateOperationToken}, | 66 | {LSL_DOT, ".", LSL_RIGHT2LEFT, outputOperationToken, NULL, evaluateOperationToken}, |
67 | // {LSL_DECREMENT_POST, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 67 | // {LSL_DECREMENT_POST, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
68 | // {LSL_DECREMENT_PRE, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 68 | {LSL_DECREMENT_PRE, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
69 | // {LSL_INCREMENT_POST, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 69 | // {LSL_INCREMENT_POST, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
70 | // {LSL_INCREMENT_PRE, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, | 70 | {LSL_INCREMENT_PRE, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputOperationToken, NULL, evaluateOperationToken}, |
71 | // {LSL_COMMA, ",", LSL_LEFT2RIGHT, outputOperationToken, NULL, evaluateOperationToken}, | 71 | {LSL_COMMA, ",", LSL_LEFT2RIGHT, outputOperationToken, NULL, evaluateOperationToken}, |
72 | 72 | ||
73 | {LSL_EXPRESSION, "expression", LSL_NONE, NULL, NULL, NULL}, | 73 | {LSL_EXPRESSION, "expression", LSL_NONE, NULL, NULL, NULL}, |
74 | 74 | ||
75 | // Types. | 75 | // Types. |
76 | 76 | ||
77 | // {LSL_FLOAT, "float", LSL_NONE, NULL, NULL, NULL}, | 77 | {LSL_FLOAT, "float", LSL_NONE, NULL, NULL, NULL}, |
78 | {LSL_INTEGER, "integer", LSL_NONE, outputIntegerToken, NULL, evaluateIntegerToken}, | 78 | {LSL_INTEGER, "integer", LSL_NONE, outputIntegerToken, NULL, evaluateIntegerToken}, |
79 | // {LSL_KEY, "key", LSL_NONE, NULL, NULL, NULL}, | 79 | // {LSL_KEY, "key", LSL_NONE, NULL, NULL, NULL}, |
80 | // {LSL_LIST, "list", LSL_NONE, NULL, NULL, NULL}, | 80 | // {LSL_LIST, "list", LSL_NONE, NULL, NULL, NULL}, |
@@ -82,25 +82,35 @@ LSL_Token LSL_Tokens[] = | |||
82 | // {LSL_STRING, "string", LSL_NONE, NULL, NULL, NULL}, | 82 | // {LSL_STRING, "string", LSL_NONE, NULL, NULL, NULL}, |
83 | // {LSL_VECTOR, "vector", LSL_NONE, NULL, NULL, NULL}, | 83 | // {LSL_VECTOR, "vector", LSL_NONE, NULL, NULL, NULL}, |
84 | 84 | ||
85 | // Types names. | ||
86 | |||
87 | {LSL_TYPE_FLOAT, "float", LSL_NONE, NULL, NULL, NULL}, | ||
88 | {LSL_TYPE_INTEGER, "integer", LSL_NONE, NULL, NULL, NULL}, | ||
89 | {LSL_TYPE_KEY, "key", LSL_NONE, NULL, NULL, NULL}, | ||
90 | {LSL_TYPE_LIST, "list", LSL_NONE, NULL, NULL, NULL}, | ||
91 | {LSL_TYPE_ROTATION, "rotation", LSL_NONE, NULL, NULL, NULL}, | ||
92 | {LSL_TYPE_STRING, "string", LSL_NONE, NULL, NULL, NULL}, | ||
93 | {LSL_TYPE_VECTOR, "vector", LSL_NONE, NULL, NULL, NULL}, | ||
94 | |||
85 | // Then the rest of the syntax tokens. | 95 | // Then the rest of the syntax tokens. |
86 | 96 | ||
87 | // {LSL_IDENTIFIER, "identifier", LSL_NONE, NULL, NULL, NULL}, | 97 | // {LSL_IDENTIFIER, "identifier", LSL_NONE, NULL, NULL, NULL}, |
88 | 98 | ||
89 | // {LSL_LABEL, "@", LSL_NONE, NULL, NULL, NULL}, | 99 | {LSL_LABEL, "@", LSL_NONE, NULL, NULL, NULL}, |
90 | 100 | ||
91 | // {LSL_DO, "do", LSL_NONE, NULL, NULL, NULL}, | 101 | {LSL_DO, "do", LSL_NONE, NULL, NULL, NULL}, |
92 | // {LSL_FOR, "for", LSL_NONE, NULL, NULL, NULL}, | 102 | {LSL_FOR, "for", LSL_NONE, NULL, NULL, NULL}, |
93 | // {LSL_ELSE_IF, "else if", LSL_NONE, NULL, NULL, NULL}, | 103 | // {LSL_ELSE_IF, "else if", LSL_NONE, NULL, NULL, NULL}, |
94 | // {LSL_ELSE, "else", LSL_NONE, NULL, NULL, NULL}, | 104 | {LSL_ELSE, "else", LSL_NONE, NULL, NULL, NULL}, |
95 | // {LSL_IF, "if", LSL_NONE, NULL, NULL, NULL}, | 105 | {LSL_IF, "if", LSL_NONE, NULL, NULL, NULL}, |
96 | // {LSL_JUMP, "jump", LSL_NONE, NULL, NULL, NULL}, | 106 | {LSL_JUMP, "jump", LSL_NONE, NULL, NULL, NULL}, |
97 | // {LSL_RETURN, "return", LSL_NONE, NULL, NULL, NULL}, | 107 | {LSL_RETURN, "return", LSL_NONE, NULL, NULL, NULL}, |
98 | // {LSL_STATE_CHANGE, "state", LSL_NONE, NULL, NULL, NULL}, | 108 | {LSL_STATE_CHANGE, "state", LSL_NONE, NULL, NULL, NULL}, |
99 | // {LSL_WHILE, "while", LSL_NONE, NULL, NULL, NULL}, | 109 | {LSL_WHILE, "while", LSL_NONE, NULL, NULL, NULL}, |
100 | {LSL_STATEMENT, ";", LSL_NONE, outputStatementToken, NULL, evaluateStatementToken}, | 110 | {LSL_STATEMENT, ";", LSL_NONE, outputStatementToken, NULL, evaluateStatementToken}, |
101 | 111 | ||
102 | // {LSL_BLOCK_CLOSE, "}", LSL_NONE, NULL, NULL, NULL}, | 112 | {LSL_BLOCK_CLOSE, "}", LSL_NONE, NULL, NULL, NULL}, |
103 | // {LSL_BLOCK_OPEN, "{", LSL_NONE, NULL, NULL, NULL}, | 113 | {LSL_BLOCK_OPEN, "{", LSL_NONE, NULL, NULL, NULL}, |
104 | // {LSL_PARAMETER, "parameter", LSL_NONE, NULL, NULL, NULL}, | 114 | // {LSL_PARAMETER, "parameter", LSL_NONE, NULL, NULL, NULL}, |
105 | // {LSL_FUNCTION, "function", LSL_NONE, NULL, NULL, NULL}, | 115 | // {LSL_FUNCTION, "function", LSL_NONE, NULL, NULL, NULL}, |
106 | // {LSL_STATE, "state", LSL_NONE, NULL, NULL, NULL}, | 116 | // {LSL_STATE, "state", LSL_NONE, NULL, NULL, NULL}, |
@@ -281,27 +291,28 @@ static void evaluateOperationToken(LSL_Leaf *content, LSL_Value *left, LSL_Value | |||
281 | 291 | ||
282 | switch (content->operationValue) | 292 | switch (content->operationValue) |
283 | { | 293 | { |
284 | // case LSL_COMMA : | 294 | case LSL_COMMA : |
285 | // case LSL_INCREMENT_PRE : | 295 | case LSL_INCREMENT_PRE : |
286 | // case LSL_INCREMENT_POST : | 296 | // case LSL_INCREMENT_POST : |
287 | // case LSL_DECREMENT_PRE : | 297 | case LSL_DECREMENT_PRE : |
288 | // case LSL_DECREMENT_POST : | 298 | // case LSL_DECREMENT_POST : |
289 | // case LSL_DOT : | 299 | case LSL_DOT : |
290 | // case LSL_ASSIGNMENT_PLAIN : | 300 | case LSL_ASSIGNMENT_PLAIN : |
291 | // case LSL_ASSIGNMENT_DIVIDE : | 301 | case LSL_ASSIGNMENT_DIVIDE : |
292 | // case LSL_ASSIGNMENT_MODULO : | 302 | case LSL_ASSIGNMENT_MODULO : |
293 | // case LSL_ASSIGNMENT_MULTIPLY : | 303 | case LSL_ASSIGNMENT_MULTIPLY : |
294 | // case LSL_ASSIGNMENT_SUBTRACT : | 304 | case LSL_ASSIGNMENT_SUBTRACT : |
295 | // case LSL_ASSIGNMENT_ADD : | 305 | case LSL_ASSIGNMENT_ADD : |
296 | // case LSL_ASSIGNMENT_CONCATENATE : | 306 | // case LSL_ASSIGNMENT_CONCATENATE : |
297 | // case LSL_PARENTHESIS_OPEN : | 307 | case LSL_PARENTHESIS_OPEN : |
298 | // case LSL_PARENTHESIS_CLOSE : | 308 | case LSL_PARENTHESIS_CLOSE : |
299 | // case LSL_BRACKET_OPEN : | 309 | case LSL_BRACKET_OPEN : |
300 | // case LSL_BRACKET_CLOSE : | 310 | case LSL_BRACKET_CLOSE : |
301 | // case LSL_ANGLE_OPEN : | 311 | case LSL_ANGLE_OPEN : |
302 | // case LSL_ANGLE_CLOSE : | 312 | case LSL_ANGLE_CLOSE : |
303 | // case LSL_TYPECAST : | 313 | // case LSL_TYPECAST_OPEN : |
304 | // break; | 314 | // case LSL_TYPECAST_CLOSE : |
315 | break; | ||
305 | case LSL_BIT_NOT : left->content.integerValue = ~ right->content.integerValue; break; | 316 | case LSL_BIT_NOT : left->content.integerValue = ~ right->content.integerValue; break; |
306 | case LSL_BOOL_NOT : left->content.integerValue = ! right->content.integerValue; break; | 317 | case LSL_BOOL_NOT : left->content.integerValue = ! right->content.integerValue; break; |
307 | case LSL_NEGATION : left->content.integerValue = 0 - right->content.integerValue; break; | 318 | case LSL_NEGATION : left->content.integerValue = 0 - right->content.integerValue; break; |