diff options
author | David Walter Seikel | 2012-01-12 04:54:17 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-12 04:54:17 +1000 |
commit | b5ba6b85252e5052c64174d6f3abad5a4a5a2a34 (patch) | |
tree | e12191109e9036257a39beea82fec7f167c18123 /LuaSL/src/LuaSL_LSL_tree.c | |
parent | Update .gitignore for lemon. (diff) | |
download | SledjHamr-b5ba6b85252e5052c64174d6f3abad5a4a5a2a34.zip SledjHamr-b5ba6b85252e5052c64174d6f3abad5a4a5a2a34.tar.gz SledjHamr-b5ba6b85252e5052c64174d6f3abad5a4a5a2a34.tar.bz2 SledjHamr-b5ba6b85252e5052c64174d6f3abad5a4a5a2a34.tar.xz |
Some general cleanup.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index a0c07f0..beae756 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c | |||
@@ -11,13 +11,12 @@ static void evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf * | |||
11 | static void outputIntegerToken(LSL_Leaf *content); | 11 | static void outputIntegerToken(LSL_Leaf *content); |
12 | static void outputParenthesisToken(LSL_Leaf *content); | 12 | static void outputParenthesisToken(LSL_Leaf *content); |
13 | static void outputStatementToken(LSL_Leaf *content); | 13 | static void outputStatementToken(LSL_Leaf *content); |
14 | static void outputSpaceToken(LSL_Leaf *content); | ||
15 | 14 | ||
16 | LSL_Token LSL_Tokens[] = | 15 | LSL_Token LSL_Tokens[] = |
17 | { | 16 | { |
18 | {LSL_COMMENT, "/*", LSL_NONE, NULL, NULL, NULL}, | 17 | {LSL_COMMENT, "/*", LSL_NONE, NULL, NULL, NULL}, |
19 | {LSL_COMMENT_LINE, "//", LSL_NONE, NULL, NULL, NULL}, | 18 | {LSL_COMMENT_LINE, "//", LSL_NONE, NULL, NULL, NULL}, |
20 | {LSL_SPACE, " ", LSL_NONE, outputSpaceToken, NULL, NULL}, | 19 | {LSL_SPACE, " ", LSL_NONE, NULL, NULL, NULL}, |
21 | 20 | ||
22 | // Operators, in order of precedence, low to high | 21 | // Operators, in order of precedence, low to high |
23 | // Left to right, unless oterwise stated. | 22 | // Left to right, unless oterwise stated. |
@@ -96,7 +95,7 @@ LSL_Token LSL_Tokens[] = | |||
96 | 95 | ||
97 | // Then the rest of the syntax tokens. | 96 | // Then the rest of the syntax tokens. |
98 | 97 | ||
99 | {LSL_IDENTIFIER, "identifier", LSL_NONE, NULL, NULL, NULL}, | 98 | {LSL_IDENTIFIER, "identifier", LSL_NONE, NULL, NULL, NULL}, |
100 | 99 | ||
101 | {LSL_LABEL, "@", LSL_NONE, NULL, NULL, NULL}, | 100 | {LSL_LABEL, "@", LSL_NONE, NULL, NULL, NULL}, |
102 | 101 | ||
@@ -118,7 +117,7 @@ LSL_Token LSL_Tokens[] = | |||
118 | // {LSL_STATE, "state", LSL_NONE, NULL, NULL, NULL}, | 117 | // {LSL_STATE, "state", LSL_NONE, NULL, NULL, NULL}, |
119 | {LSL_SCRIPT, "", LSL_NONE, NULL, NULL, NULL}, | 118 | {LSL_SCRIPT, "", LSL_NONE, NULL, NULL, NULL}, |
120 | 119 | ||
121 | {LSL_UNKNOWN, "unknown", LSL_NONE, NULL, NULL, NULL}, | 120 | {LSL_UNKNOWN, "unknown", LSL_NONE, NULL, NULL, NULL}, |
122 | 121 | ||
123 | // A sentinal. | 122 | // A sentinal. |
124 | 123 | ||
@@ -129,6 +128,7 @@ LSL_Token **tokens = NULL; | |||
129 | int lowestToken = 999999; | 128 | int lowestToken = 999999; |
130 | 129 | ||
131 | 130 | ||
131 | /* Not actually used, but it might be some day. | ||
132 | static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) | 132 | static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) |
133 | { | 133 | { |
134 | LSL_Leaf *leaf = calloc(1, sizeof(LSL_Leaf)); | 134 | LSL_Leaf *leaf = calloc(1, sizeof(LSL_Leaf)); |
@@ -142,6 +142,7 @@ static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) | |||
142 | 142 | ||
143 | return leaf; | 143 | return leaf; |
144 | } | 144 | } |
145 | */ | ||
145 | 146 | ||
146 | void burnLeaf(LSL_Leaf *leaf) | 147 | void burnLeaf(LSL_Leaf *leaf) |
147 | { | 148 | { |
@@ -155,22 +156,12 @@ void burnLeaf(LSL_Leaf *leaf) | |||
155 | } | 156 | } |
156 | } | 157 | } |
157 | 158 | ||
158 | LSL_Leaf *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) | 159 | LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) |
159 | { | 160 | { |
160 | printf("******************************addOperation(%s, %d, , )\n", lval->token->token, type); | ||
161 | if (lval) | 161 | if (lval) |
162 | { | 162 | { |
163 | lval->left = left; | 163 | lval->left = left; |
164 | lval->right = right; | 164 | lval->right = right; |
165 | if (LSL_EXPRESSION == type) | ||
166 | { | ||
167 | lval->value.expressionValue = right; | ||
168 | lval->left = NULL; | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | lval->value.operationValue = type; | ||
173 | } | ||
174 | } | 165 | } |
175 | 166 | ||
176 | return lval; | 167 | return lval; |
@@ -194,7 +185,6 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval) | |||
194 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr) | 185 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr) |
195 | { | 186 | { |
196 | LSL_Statement *stat = malloc(sizeof(LSL_Statement)); | 187 | LSL_Statement *stat = malloc(sizeof(LSL_Statement)); |
197 | printf("******************************addStatement(%s, %d, , )\n", lval->token->token, type); | ||
198 | 188 | ||
199 | if (stat) | 189 | if (stat) |
200 | { | 190 | { |
@@ -270,13 +260,13 @@ static void evaluateNoToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) | |||
270 | 260 | ||
271 | static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) | 261 | static void evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right) |
272 | { | 262 | { |
273 | if ((content) && (content->value.operationValue)) | 263 | if (content) |
274 | { | 264 | { |
275 | #ifdef LUASL_DEBUG | 265 | #ifdef LUASL_DEBUG |
276 | printf(" [%s] ", content->token->token); | 266 | printf(" [%s] ", content->token->token); |
277 | #endif | 267 | #endif |
278 | 268 | ||
279 | switch (content->value.operationValue) | 269 | switch (content->token->type) |
280 | { | 270 | { |
281 | case LSL_COMMA : | 271 | case LSL_COMMA : |
282 | case LSL_INCREMENT_PRE : | 272 | case LSL_INCREMENT_PRE : |
@@ -391,12 +381,6 @@ static void outputStatementToken(LSL_Leaf *content) | |||
391 | } | 381 | } |
392 | } | 382 | } |
393 | 383 | ||
394 | static void outputSpaceToken(LSL_Leaf *content) | ||
395 | { | ||
396 | if (content) | ||
397 | printf("%s", content->value.spaceValue); | ||
398 | } | ||
399 | |||
400 | static void convertLeaf2Lua(LSL_Leaf *leaf) | 384 | static void convertLeaf2Lua(LSL_Leaf *leaf) |
401 | { | 385 | { |
402 | if (leaf) | 386 | if (leaf) |