aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h4
-rw-r--r--LuaSL/src/LuaSL_compile.c106
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y18
-rw-r--r--LuaSL/src/LuaSL_lexer.l2
4 files changed, 65 insertions, 65 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index 349d74f..24f838a 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -154,7 +154,7 @@ struct _LSL_Token
154{ 154{
155 LSL_Type type; 155 LSL_Type type;
156 opSubType subType; 156 opSubType subType;
157 const char *token; 157 const char *toKen;
158 LSL_Flags flags; 158 LSL_Flags flags;
159 outputToken output; 159 outputToken output;
160 evaluateToken evaluate; 160 evaluateToken evaluate;
@@ -164,7 +164,7 @@ struct _LSL_Leaf
164{ 164{
165 LSL_Leaf *left; 165 LSL_Leaf *left;
166 LSL_Leaf *right; 166 LSL_Leaf *right;
167 LSL_Token *token; 167 LSL_Token *toKen;
168#if LUASL_DIFF_CHECK 168#if LUASL_DIFF_CHECK
169 Eina_Strbuf *ignorableText; 169 Eina_Strbuf *ignorableText;
170#endif 170#endif
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index c53a09a..48f2910 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -222,7 +222,7 @@ static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right)
222 { 222 {
223 leaf->left = left; 223 leaf->left = left;
224 leaf->right = right; 224 leaf->right = right;
225 leaf->token = tokens[type - lowestToken]; 225 leaf->toKen = tokens[type - lowestToken];
226 } 226 }
227 227
228 return leaf; 228 return leaf;
@@ -274,7 +274,7 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
274 LSL_Leaf *param = NULL; 274 LSL_Leaf *param = NULL;
275 EINA_INARRAY_FOREACH((&(block->function->vars)), param) 275 EINA_INARRAY_FOREACH((&(block->function->vars)), param)
276 { 276 {
277 if ((param) && (LSL_PARAMETER == param->token->type)) 277 if ((param) && (LSL_PARAMETER == param->toKen->type))
278 { 278 {
279// if (name == param->value.identifierValue->name) // Assuming they are stringshares. 279// if (name == param->value.identifierValue->name) // Assuming they are stringshares.
280 if (0 == strcmp(name, param->value.identifierValue->name)) // Not assuming they are stringeshares. 280 if (0 == strcmp(name, param->value.identifierValue->name)) // Not assuming they are stringeshares.
@@ -330,15 +330,15 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
330 lval->right = right; 330 lval->right = right;
331 331
332 // Convert subtract to negate if needed. 332 // Convert subtract to negate if needed.
333 if ((NULL == left) && (LSL_SUBTRACT == lval->token->type)) 333 if ((NULL == left) && (LSL_SUBTRACT == lval->toKen->type))
334 lval->token = tokens[LSL_NEGATION - lowestToken]; 334 lval->toKen = tokens[LSL_NEGATION - lowestToken];
335 335
336 // Try to figure out what type of operation this is. 336 // Try to figure out what type of operation this is.
337 if (NULL == left) 337 if (NULL == left)
338 lType = OT_nothing; 338 lType = OT_nothing;
339 else 339 else
340 { 340 {
341 if ((left->token) && (LSL_IDENTIFIER == left->token->type) && (left->value.identifierValue)) 341 if ((left->toKen) && (LSL_IDENTIFIER == left->toKen->type) && (left->value.identifierValue))
342 { 342 {
343 LSL_Leaf *var = findVariable(compiler, left->value.identifierValue->name); 343 LSL_Leaf *var = findVariable(compiler, left->value.identifierValue->name);
344 344
@@ -360,7 +360,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
360 rType = OT_nothing; 360 rType = OT_nothing;
361 else 361 else
362 { 362 {
363 if ((right->token) && (LSL_IDENTIFIER == right->token->type) && (right->value.identifierValue)) 363 if ((right->toKen) && (LSL_IDENTIFIER == right->toKen->type) && (right->value.identifierValue))
364 { 364 {
365 LSL_Leaf *var = findVariable(compiler, right->value.identifierValue->name); 365 LSL_Leaf *var = findVariable(compiler, right->value.identifierValue->name);
366 366
@@ -379,7 +379,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
379 rType = allowed[rType].result; 379 rType = allowed[rType].result;
380 } 380 }
381 381
382 switch (lval->token->subType) 382 switch (lval->toKen->subType)
383 { 383 {
384 case ST_BOOLEAN : 384 case ST_BOOLEAN :
385 case ST_COMPARISON : 385 case ST_COMPARISON :
@@ -392,20 +392,20 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
392 if (OT_invalid != lval->basicType) 392 if (OT_invalid != lval->basicType)
393 { 393 {
394 // Check if it's an allowed operation. 394 // Check if it's an allowed operation.
395 if (0 == (lval->token->subType & allowed[lval->basicType].subTypes)) 395 if (0 == (lval->toKen->subType & allowed[lval->basicType].subTypes))
396 lval->basicType = OT_invalid; 396 lval->basicType = OT_invalid;
397 else 397 else
398 { 398 {
399 // Double check the corner cases. 399 // Double check the corner cases.
400 switch (lval->token->subType) 400 switch (lval->toKen->subType)
401 { 401 {
402 case ST_MULTIPLY : 402 case ST_MULTIPLY :
403 if (OT_vectorVector == lval->basicType) 403 if (OT_vectorVector == lval->basicType)
404 { 404 {
405 if (LSL_MULTIPLY == lval->token->type) 405 if (LSL_MULTIPLY == lval->toKen->type)
406 { 406 {
407 lval->basicType = OT_float; 407 lval->basicType = OT_float;
408 lval->token = tokens[LSL_DOT_PRODUCT - lowestToken]; 408 lval->toKen = tokens[LSL_DOT_PRODUCT - lowestToken];
409 } 409 }
410 else 410 else
411 lval->basicType = OT_vector; 411 lval->basicType = OT_vector;
@@ -424,22 +424,22 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
424 424
425 if (left) 425 if (left)
426 { 426 {
427 if (left->token) 427 if (left->toKen)
428 leftToken = left->token->token; 428 leftToken = left->toKen->toKen;
429 else 429 else
430 PE("BROKEN LEFT TOKEN!!!!!!!!!!!!!!!!!!"); 430 PE("BROKEN LEFT TOKEN!!!!!!!!!!!!!!!!!!");
431 leftType = allowed[left->basicType].name; 431 leftType = allowed[left->basicType].name;
432 } 432 }
433 if (right) 433 if (right)
434 { 434 {
435 if (right->token) 435 if (right->toKen)
436 rightToken = right->token->token; 436 rightToken = right->toKen->toKen;
437 else 437 else
438 PE("BROKEN RIGHT TOKEN!!!!!!!!!!!!!!!!!!"); 438 PE("BROKEN RIGHT TOKEN!!!!!!!!!!!!!!!!!!");
439 rightType = allowed[right->basicType].name; 439 rightType = allowed[right->basicType].name;
440 } 440 }
441 441
442 PE("Invalid operation [%s(%s) %s %s(%s)] @ line %d, column %d!", leftType, leftToken, lval->token->token, rightType, rightToken, lval->line, lval->column); 442 PE("Invalid operation [%s(%s) %s %s(%s)] @ line %d, column %d!", leftType, leftToken, lval->toKen->toKen, rightType, rightToken, lval->line, lval->column);
443 } 443 }
444 } 444 }
445 445
@@ -463,15 +463,15 @@ LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *ident
463 if ( (identifier) && (result)) 463 if ( (identifier) && (result))
464 { 464 {
465 result->name = identifier->value.stringValue; 465 result->name = identifier->value.stringValue;
466 result->value.token = tokens[LSL_UNKNOWN - lowestToken]; 466 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken];
467 identifier->value.identifierValue = result; 467 identifier->value.identifierValue = result;
468 identifier->token = tokens[LSL_PARAMETER - lowestToken]; 468 identifier->toKen = tokens[LSL_PARAMETER - lowestToken];
469 identifier->left = type; 469 identifier->left = type;
470 if (type) 470 if (type)
471 { 471 {
472 identifier->basicType = type->basicType; 472 identifier->basicType = type->basicType;
473 result->value.basicType = type->basicType; 473 result->value.basicType = type->basicType;
474 result->value.token = type->token; // This is the LSL_TYPE_* token instead of the LSL_* token. Not sure if that's a problem. 474 result->value.toKen = type->toKen; // This is the LSL_TYPE_* toKen instead of the LSL_* toKen. Not sure if that's a problem.
475 } 475 }
476 } 476 }
477 return identifier; 477 return identifier;
@@ -529,7 +529,7 @@ LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
529 if (identifier) 529 if (identifier)
530 { 530 {
531 func->name = identifier->value.stringValue; 531 func->name = identifier->value.stringValue;
532 identifier->token = tokens[LSL_FUNCTION - lowestToken]; 532 identifier->toKen = tokens[LSL_FUNCTION - lowestToken];
533 identifier->value.functionValue = func; 533 identifier->value.functionValue = func;
534 func->type = type; 534 func->type = type;
535 if (type) 535 if (type)
@@ -567,7 +567,7 @@ LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Le
567 LSL_Leaf *func = findFunction(compiler, identifier->value.stringValue); 567 LSL_Leaf *func = findFunction(compiler, identifier->value.stringValue);
568 LSL_FunctionCall *call = calloc(1, sizeof(LSL_FunctionCall)); 568 LSL_FunctionCall *call = calloc(1, sizeof(LSL_FunctionCall));
569 569
570 identifier->token = tokens[LSL_UNKNOWN - lowestToken]; 570 identifier->toKen = tokens[LSL_UNKNOWN - lowestToken];
571 571
572 if (func) 572 if (func)
573 { 573 {
@@ -579,7 +579,7 @@ LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Le
579 } 579 }
580 identifier->value.functionCallValue = call; 580 identifier->value.functionCallValue = call;
581 // TODO - Put the params in call. 581 // TODO - Put the params in call.
582 identifier->token = tokens[LSL_FUNCTION_CALL - lowestToken]; 582 identifier->toKen = tokens[LSL_FUNCTION_CALL - lowestToken];
583 identifier->basicType = func->basicType; 583 identifier->basicType = func->basicType;
584 } 584 }
585 else 585 else
@@ -629,7 +629,7 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *blo
629 result->name = identifier->value.stringValue; 629 result->name = identifier->value.stringValue;
630 result->block = block; 630 result->block = block;
631 identifier->value.stateValue = result; 631 identifier->value.stateValue = result;
632 identifier->token = tokens[LSL_STATE - lowestToken]; 632 identifier->toKen = tokens[LSL_STATE - lowestToken];
633 eina_hash_add(compiler->script.states, result->name, identifier); 633 eina_hash_add(compiler->script.states, result->name, identifier);
634 } 634 }
635 635
@@ -756,10 +756,10 @@ LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *
756 if (type) 756 if (type)
757 lval->basicType = type->basicType; 757 lval->basicType = type->basicType;
758 // Actualy, at this point, type is no longer needed. 758 // Actualy, at this point, type is no longer needed.
759 lval->token = tokens[LSL_TYPECAST_OPEN - lowestToken]; 759 lval->toKen = tokens[LSL_TYPECAST_OPEN - lowestToken];
760 } 760 }
761// if (rval) 761// if (rval)
762// rval->token = tokens[LSL_TYPECAST_CLOSE - lowestToken]; 762// rval->toKen = tokens[LSL_TYPECAST_CLOSE - lowestToken];
763 763
764 return lval; 764 return lval;
765} 765}
@@ -771,7 +771,7 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
771 if ( (identifier) && (result)) 771 if ( (identifier) && (result))
772 { 772 {
773 result->name = identifier->value.stringValue; 773 result->name = identifier->value.stringValue;
774 result->value.token = tokens[LSL_UNKNOWN - lowestToken]; 774 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken];
775 identifier->value.identifierValue = result; 775 identifier->value.identifierValue = result;
776 identifier->left = type; 776 identifier->left = type;
777 identifier->right = assignment; 777 identifier->right = assignment;
@@ -781,7 +781,7 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
781 { 781 {
782 identifier->basicType = type->basicType; 782 identifier->basicType = type->basicType;
783 result->value.basicType = type->basicType; 783 result->value.basicType = type->basicType;
784 result->value.token = type->token; // This is the LSL_TYPE_* token instead of the LSL_* token. Not sure if that's a problem. 784 result->value.toKen = type->toKen; // This is the LSL_TYPE_* toKen instead of the LSL_* toKen. Not sure if that's a problem.
785 } 785 }
786 if (compiler->currentBlock) 786 if (compiler->currentBlock)
787 eina_hash_add(compiler->currentBlock->variables, result->name, identifier); 787 eina_hash_add(compiler->currentBlock->variables, result->name, identifier);
@@ -831,21 +831,21 @@ static LSL_Leaf *evaluateLeaf(LSL_Leaf *leaf, LSL_Leaf *left, LSL_Leaf *right)
831 LSL_Leaf *lresult = NULL; 831 LSL_Leaf *lresult = NULL;
832 LSL_Leaf *rresult = NULL; 832 LSL_Leaf *rresult = NULL;
833 833
834 if (LSL_RIGHT2LEFT & leaf->token->flags) 834 if (LSL_RIGHT2LEFT & leaf->toKen->flags)
835 { 835 {
836 rresult = evaluateLeaf(leaf->right, left, right); 836 rresult = evaluateLeaf(leaf->right, left, right);
837 if (!(LSL_UNARY & leaf->token->flags)) 837 if (!(LSL_UNARY & leaf->toKen->flags))
838 lresult = evaluateLeaf(leaf->left, left, right); 838 lresult = evaluateLeaf(leaf->left, left, right);
839 } 839 }
840 else // Assume left to right. 840 else // Assume left to right.
841 { 841 {
842 lresult = evaluateLeaf(leaf->left, left, right); 842 lresult = evaluateLeaf(leaf->left, left, right);
843 if (!(LSL_UNARY & leaf->token->flags)) 843 if (!(LSL_UNARY & leaf->toKen->flags))
844 rresult = evaluateLeaf(leaf->right, left, right); 844 rresult = evaluateLeaf(leaf->right, left, right);
845 } 845 }
846 846
847 if (leaf->token->evaluate) 847 if (leaf->toKen->evaluate)
848 result = leaf->token->evaluate(leaf, lresult, rresult); 848 result = leaf->toKen->evaluate(leaf, lresult, rresult);
849 else 849 else
850 { 850 {
851 result = newLeaf(LSL_UNKNOWN, NULL, NULL); 851 result = newLeaf(LSL_UNKNOWN, NULL, NULL);
@@ -964,7 +964,7 @@ static LSL_Leaf *evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L
964 if (content && result) 964 if (content && result)
965 { 965 {
966 if (LUASL_DEBUG) 966 if (LUASL_DEBUG)
967 printf(" [%s] ", content->token->token); 967 printf(" [%s] ", content->toKen->toKen);
968 968
969 memcpy(result, content, sizeof(LSL_Leaf)); 969 memcpy(result, content, sizeof(LSL_Leaf));
970 970
@@ -984,7 +984,7 @@ static LSL_Leaf *evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L
984 fright = right->value.integerValue; 984 fright = right->value.integerValue;
985 if (OT_intFloat == content->basicType) 985 if (OT_intFloat == content->basicType)
986 fleft = left->value.integerValue; 986 fleft = left->value.integerValue;
987 switch (result->token->type) 987 switch (result->toKen->type)
988 { 988 {
989 case LSL_COMMA : 989 case LSL_COMMA :
990 case LSL_INCREMENT_PRE : 990 case LSL_INCREMENT_PRE :
@@ -1023,7 +1023,7 @@ static LSL_Leaf *evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L
1023 1023
1024 case OT_integer : 1024 case OT_integer :
1025 { 1025 {
1026 switch (result->token->type) 1026 switch (result->toKen->type)
1027 { 1027 {
1028 case LSL_COMMA : 1028 case LSL_COMMA :
1029 case LSL_INCREMENT_PRE : 1029 case LSL_INCREMENT_PRE :
@@ -1175,13 +1175,13 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf)
1175 { 1175 {
1176 outputLeaf(file, mode, leaf->left); 1176 outputLeaf(file, mode, leaf->left);
1177#if LUASL_DIFF_CHECK 1177#if LUASL_DIFF_CHECK
1178 if ((!(LSL_NOIGNORE & leaf->token->flags)) && (leaf->ignorableText)) 1178 if ((!(LSL_NOIGNORE & leaf->toKen->flags)) && (leaf->ignorableText))
1179 fwrite(eina_strbuf_string_get(leaf->ignorableText), 1, eina_strbuf_length_get(leaf->ignorableText), file); 1179 fwrite(eina_strbuf_string_get(leaf->ignorableText), 1, eina_strbuf_length_get(leaf->ignorableText), file);
1180#endif 1180#endif
1181 if (leaf->token->output) 1181 if (leaf->toKen->output)
1182 leaf->token->output(file, mode, leaf); 1182 leaf->toKen->output(file, mode, leaf);
1183 else 1183 else
1184 fprintf(file, "%s", leaf->token->token); 1184 fprintf(file, "%s", leaf->toKen->toKen);
1185 outputLeaf(file, mode, leaf->right); 1185 outputLeaf(file, mode, leaf->right);
1186 } 1186 }
1187} 1187}
@@ -1315,45 +1315,45 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1315 } 1315 }
1316 case LSL_DO : 1316 case LSL_DO :
1317 { 1317 {
1318 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1318 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1319 break; 1319 break;
1320 } 1320 }
1321 case LSL_FOR : 1321 case LSL_FOR :
1322 { 1322 {
1323 isBlock = TRUE; 1323 isBlock = TRUE;
1324 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1324 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1325 break; 1325 break;
1326 } 1326 }
1327 case LSL_IF : 1327 case LSL_IF :
1328 { 1328 {
1329 isBlock = TRUE; 1329 isBlock = TRUE;
1330 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1330 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1331 break; 1331 break;
1332 } 1332 }
1333 case LSL_ELSE : 1333 case LSL_ELSE :
1334 { 1334 {
1335 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1335 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1336 break; 1336 break;
1337 } 1337 }
1338 case LSL_JUMP : 1338 case LSL_JUMP :
1339 { 1339 {
1340 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1340 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1341 break; 1341 break;
1342 } 1342 }
1343 case LSL_RETURN : 1343 case LSL_RETURN :
1344 { 1344 {
1345 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1345 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1346 break; 1346 break;
1347 } 1347 }
1348 case LSL_STATE_CHANGE : 1348 case LSL_STATE_CHANGE :
1349 { 1349 {
1350 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1350 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1351 break; 1351 break;
1352 } 1352 }
1353 case LSL_WHILE : 1353 case LSL_WHILE :
1354 { 1354 {
1355 isBlock = TRUE; 1355 isBlock = TRUE;
1356 fprintf(file, "%s", tokens[statement->type - lowestToken]->token); 1356 fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen);
1357 break; 1357 break;
1358 } 1358 }
1359 case LSL_IDENTIFIER : 1359 case LSL_IDENTIFIER :
@@ -1362,7 +1362,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1362 } 1362 }
1363 default : 1363 default :
1364 { 1364 {
1365 fprintf(file, "@@Should not be here %s.@@", tokens[statement->type - lowestToken]->token); 1365 fprintf(file, "@@Should not be here %s.@@", tokens[statement->type - lowestToken]->toKen);
1366 break; 1366 break;
1367 } 1367 }
1368 } 1368 }
@@ -1481,7 +1481,7 @@ boolean compilerSetup(gameGlobals *game)
1481 int i; 1481 int i;
1482 1482
1483 // Figure out what numbers lemon gave to our tokens. 1483 // Figure out what numbers lemon gave to our tokens.
1484 for (i = 0; LSL_Tokens[i].token != NULL; i++) 1484 for (i = 0; LSL_Tokens[i].toKen != NULL; i++)
1485 { 1485 {
1486 if (lowestToken > LSL_Tokens[i].type) 1486 if (lowestToken > LSL_Tokens[i].type)
1487 lowestToken = LSL_Tokens[i].type; 1487 lowestToken = LSL_Tokens[i].type;
@@ -1492,7 +1492,7 @@ boolean compilerSetup(gameGlobals *game)
1492 char buf[PATH_MAX]; 1492 char buf[PATH_MAX];
1493 1493
1494 // Sort the token table. 1494 // Sort the token table.
1495 for (i = 0; LSL_Tokens[i].token != NULL; i++) 1495 for (i = 0; LSL_Tokens[i].toKen != NULL; i++)
1496 { 1496 {
1497 int j = LSL_Tokens[i].type - lowestToken; 1497 int j = LSL_Tokens[i].type - lowestToken;
1498 1498
@@ -1583,7 +1583,7 @@ boolean compileLSL(gameGlobals *game, char *script, boolean doConstants)
1583 { 1583 {
1584 call->function = func->value.functionValue; 1584 call->function = func->value.functionValue;
1585 call->call->value.functionCallValue = call; 1585 call->call->value.functionCallValue = call;
1586 call->call->token = tokens[LSL_FUNCTION_CALL - lowestToken]; 1586 call->call->toKen = tokens[LSL_FUNCTION_CALL - lowestToken];
1587 call->call->basicType = func->basicType; 1587 call->call->basicType = func->basicType;
1588 } 1588 }
1589 else 1589 else
@@ -1689,7 +1689,7 @@ int main(int argc, char **argv)
1689 int i; 1689 int i;
1690 1690
1691 // Figure out what numbers yacc gave to our tokens. 1691 // Figure out what numbers yacc gave to our tokens.
1692 for (i = 0; LSL_Tokens[i].token != NULL; i++) 1692 for (i = 0; LSL_Tokens[i].toKen != NULL; i++)
1693 { 1693 {
1694 if (lowestToken > LSL_Tokens[i].type) 1694 if (lowestToken > LSL_Tokens[i].type)
1695 lowestToken = LSL_Tokens[i].type; 1695 lowestToken = LSL_Tokens[i].type;
@@ -1700,7 +1700,7 @@ int main(int argc, char **argv)
1700 LuaSL_yyparseParam param; 1700 LuaSL_yyparseParam param;
1701 1701
1702 // Sort the token table. 1702 // Sort the token table.
1703 for (i = 0; LSL_Tokens[i].token != NULL; i++) 1703 for (i = 0; LSL_Tokens[i].toKen != NULL; i++)
1704 { 1704 {
1705 int j = LSL_Tokens[i].type - lowestToken; 1705 int j = LSL_Tokens[i].type - lowestToken;
1706 1706
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 73ef673..125b384 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -67,23 +67,23 @@ statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); }
67 67
68%nonassoc LSL_DO LSL_FOR LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. 68%nonassoc LSL_DO LSL_FOR LSL_ELSE_IF LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE.
69%nonassoc LSL_ELSE. 69%nonassoc LSL_ELSE.
70statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, L, E, R, B, W); } 70statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, L, E, R, B, W); }
71statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->token->type, L, NULL, R, B, NULL); } // three expressions, two semi colons 71statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->toKen->type, L, E1, R, B, NULL); } // three expressions, two semi colons
72 72
73ifBlock ::= ifBlock LSL_ELSE block. 73ifBlock ::= ifBlock LSL_ELSE block.
74ifBlock ::= block. 74ifBlock ::= block.
75// The [LSL_ELSE] part causes a conflict. 75// The [LSL_ELSE] part causes a conflict.
76statement(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) ifBlock(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F->token->type, L, E, R, B, NULL); } // optional else, optional else if 76statement(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) ifBlock(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F->token->type, L, E, R, B, NULL); } // optional else, optional else if
77 77
78statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); } 78statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
79statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, E, NULL, NULL, NULL); } 79statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); }
80statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, NULL); } 80statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, NULL); }
81statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); } 81statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
82statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); } 82statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
83statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->token->type, L, E, R, B, NULL); } 83statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->toKen->type, L, E, R, B, NULL); }
84 84
85%nonassoc LSL_LABEL. 85%nonassoc LSL_LABEL.
86statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->token->type, NULL, NULL, NULL, NULL, I); } 86statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); }
87 87
88// This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them. 88// This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them.
89statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_EXPRESSION, NULL, E, NULL, NULL, NULL); } 89statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_EXPRESSION, NULL, E, NULL, NULL, NULL); }
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l
index 0a14c2b..c66a3a8 100644
--- a/LuaSL/src/LuaSL_lexer.l
+++ b/LuaSL/src/LuaSL_lexer.l
@@ -120,7 +120,7 @@ int common(YYSTYPE *lval, char *text, int len, LuaSL_compiler *compiler, boolean
120{ 120{
121 char *p; 121 char *p;
122 122
123 lval->token = tokens[type - lowestToken]; 123 lval->toKen = tokens[type - lowestToken];
124 lval->line = compiler->line; 124 lval->line = compiler->line;
125 lval->column = compiler->column; 125 lval->column = compiler->column;
126 lval->len = len; 126 lval->len = len;