diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 21 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 66 |
2 files changed, 16 insertions, 71 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 42b0798..f84b1e1 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -295,14 +295,23 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name) | |||
295 | LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier) | 295 | LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier) |
296 | { | 296 | { |
297 | gameGlobals *game = compiler->game; | 297 | gameGlobals *game = compiler->game; |
298 | LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue); | ||
299 | 298 | ||
300 | if (NULL == var) | 299 | if (identifier) |
301 | PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); | 300 | { |
302 | else if (LUASL_DEBUG) | 301 | LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue); |
303 | PI("Found %s!", identifier->value.stringValue); | ||
304 | 302 | ||
305 | return var; | 303 | if (var) |
304 | { | ||
305 | if (LUASL_DEBUG) | ||
306 | PI("Found %s!", identifier->value.stringValue); | ||
307 | identifier->value.identifierValue = var->value.identifierValue; | ||
308 | identifier->basicType = var->basicType; | ||
309 | } | ||
310 | else | ||
311 | PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); | ||
312 | } | ||
313 | |||
314 | return identifier; | ||
306 | } | 315 | } |
307 | 316 | ||
308 | LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) | 317 | LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) |
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index f67b9d1..38b9c36 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -159,70 +159,6 @@ expr(A) ::= LSL_IDENTIFIER(B) LSL_PARENTHESIS_OPEN(C) exprList(D) LSL_PARENTHESI | |||
159 | 159 | ||
160 | expr(A) ::= identifier(B). { A = B; } | 160 | expr(A) ::= identifier(B). { A = B; } |
161 | 161 | ||
162 | /* | ||
163 | --accepting rule at line 85 ("integer") | ||
164 | LSL_lemon Input LSL_TYPE_INTEGER | ||
165 | LSL_lemon Reduce [script ::=]. | ||
166 | LSL_lemon Shift 1 | ||
167 | LSL_lemon Stack: script | ||
168 | LSL_lemon Shift 177 | ||
169 | LSL_lemon Stack: script LSL_TYPE_INTEGER | ||
170 | --accepting rule at line 36 (" ") | ||
171 | --accepting rule at line 104 ("Checking") | ||
172 | LSL_lemon Input LSL_IDENTIFIER | ||
173 | LSL_lemon Reduce [type ::= LSL_TYPE_INTEGER]. | ||
174 | LSL_lemon Shift 107 | ||
175 | LSL_lemon Stack: script type | ||
176 | LSL_lemon Shift 97 | ||
177 | LSL_lemon Stack: script type LSL_IDENTIFIER | ||
178 | --accepting rule at line 36 (" ") | ||
179 | --accepting rule at line 71 ("=") | ||
180 | LSL_lemon Input LSL_ASSIGNMENT_PLAIN | ||
181 | LSL_lemon Shift 16 | ||
182 | LSL_lemon Stack: script type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN | ||
183 | --accepting rule at line 36 (" ") | ||
184 | --accepting rule at line 104 ("FALSE") | ||
185 | LSL_lemon Input LSL_IDENTIFIER | ||
186 | LSL_lemon Shift 127 | ||
187 | LSL_lemon Stack: script type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN LSL_IDENTIFIER | ||
188 | --accepting rule at line 81 (";") | ||
189 | LSL_lemon Input LSL_STATEMENT | ||
190 | LSL_lemon Reduce [identifier ::= LSL_IDENTIFIER]. | ||
191 | 22/01/2012 15:32:13 INF<15847>:LuaSL LuaSL_compile.c :305 checkVariable() Found FALSE! | ||
192 | LSL_lemon Shift 94 | ||
193 | LSL_lemon Stack: script type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN identifier | ||
194 | LSL_lemon Reduce [expr ::= identifier]. | ||
195 | LSL_lemon Shift 67 | ||
196 | LSL_lemon Stack: script type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr | ||
197 | LSL_lemon Shift 142 | ||
198 | LSL_lemon Stack: script type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr LSL_STATEMENT | ||
199 | --accepting rule at line 36 (" ") | ||
200 | --accepting rule at line 39 ("// whether doing consistency check") | ||
201 | --accepting rule at line 36 (" | ||
202 | |||
203 | ") | ||
204 | --accepting rule at line 85 ("integer") | ||
205 | LSL_lemon Input LSL_TYPE_INTEGER | ||
206 | LSL_lemon Reduce [statement ::= type LSL_IDENTIFIER LSL_ASSIGNMENT_PLAIN expr LSL_STATEMENT]. | ||
207 | LSL_lemon Shift 194 | ||
208 | LSL_lemon Stack: script statement | ||
209 | LSL_lemon Reduce [script ::= script statement]. | ||
210 | LSL_lemon Shift 1 | ||
211 | LSL_lemon Stack: script | ||
212 | |||
213 | |||
214 | Results in - | ||
215 | integer Checking = | ||
216 | integer FALSE = 0; // whether doing consistency check | ||
217 | |||
218 | Instead of - | ||
219 | integer Checking = FALSE; // whether doing consistency check | ||
220 | |||
221 | Coz it replaces the variable with the definition of the variable. | ||
222 | |||
223 | */ | ||
224 | |||
225 | |||
226 | %right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. | 162 | %right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. |
227 | // Yes, these can be expressions, and can happen in if statements and such. | 163 | // Yes, these can be expressions, and can happen in if statements and such. |
228 | expr(A) ::= identifier LSL_ASSIGNMENT_CONCATENATE expr(B). { A = B; } | 164 | expr(A) ::= identifier LSL_ASSIGNMENT_CONCATENATE expr(B). { A = B; } |
@@ -240,7 +176,7 @@ statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_STATEMENT(F). { A = addStatem | |||
240 | 176 | ||
241 | %right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL. | 177 | %right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL. |
242 | identifier ::= identifier LSL_DOT LSL_IDENTIFIER. | 178 | identifier ::= identifier LSL_DOT LSL_IDENTIFIER. |
243 | identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); } | 179 | identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); } |
244 | 180 | ||
245 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. | 181 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. |
246 | expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C); } | 182 | expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C); } |