aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r--LuaSL/src/LuaSL_compile.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index a9cc733..772f01a 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -117,6 +117,7 @@ LSL_Token LSL_Tokens[] =
117 // Then the rest of the syntax tokens. 117 // Then the rest of the syntax tokens.
118 {LSL_FUNCTION_CALL, ST_NONE, "funccall", LSL_NONE, outputFunctionCallToken, NULL}, 118 {LSL_FUNCTION_CALL, ST_NONE, "funccall", LSL_NONE, outputFunctionCallToken, NULL},
119 {LSL_IDENTIFIER, ST_NONE, "identifier", LSL_NONE, outputIdentifierToken, NULL}, 119 {LSL_IDENTIFIER, ST_NONE, "identifier", LSL_NONE, outputIdentifierToken, NULL},
120 {LSL_VARIABLE, ST_NONE, "variable", LSL_NONE, outputIdentifierToken, NULL},
120 121
121 {LSL_LABEL, ST_NONE, "@", LSL_NONE, NULL, NULL}, 122 {LSL_LABEL, ST_NONE, "@", LSL_NONE, NULL, NULL},
122 123
@@ -470,6 +471,7 @@ LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *ident
470 { 471 {
471 result->name.text = identifier->value.stringValue; 472 result->name.text = identifier->value.stringValue;
472 result->name.ignorableText = identifier->ignorableText; 473 result->name.ignorableText = identifier->ignorableText;
474 identifier->ignorableText = NULL;
473 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken]; 475 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken];
474 identifier->value.identifierValue = result; 476 identifier->value.identifierValue = result;
475 identifier->toKen = tokens[LSL_PARAMETER - lowestToken]; 477 identifier->toKen = tokens[LSL_PARAMETER - lowestToken];
@@ -537,12 +539,14 @@ LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
537 { 539 {
538 func->name.text = identifier->value.stringValue; 540 func->name.text = identifier->value.stringValue;
539 func->name.ignorableText = identifier->ignorableText; 541 func->name.ignorableText = identifier->ignorableText;
542 identifier->ignorableText = NULL;
540 identifier->toKen = tokens[LSL_FUNCTION - lowestToken]; 543 identifier->toKen = tokens[LSL_FUNCTION - lowestToken];
541 identifier->value.functionValue = func; 544 identifier->value.functionValue = func;
542 if (type) 545 if (type)
543 { 546 {
544 func->type.text = type->toKen->toKen; 547 func->type.text = type->toKen->toKen;
545 func->type.ignorableText = type->ignorableText; 548 func->type.ignorableText = type->ignorableText;
549 type->ignorableText = NULL;
546 identifier->basicType = type->basicType; 550 identifier->basicType = type->basicType;
547 } 551 }
548 else 552 else
@@ -638,6 +642,7 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi
638 { 642 {
639 result->name.text = identifier->value.stringValue; 643 result->name.text = identifier->value.stringValue;
640 result->name.ignorableText = identifier->ignorableText; 644 result->name.ignorableText = identifier->ignorableText;
645 identifier->ignorableText = NULL;
641 result->block = block->value.blockValue; 646 result->block = block->value.blockValue;
642 if (state) 647 if (state)
643 { 648 {
@@ -725,6 +730,10 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type,
725 { 730 {
726 break; 731 break;
727 } 732 }
733 case LSL_VARIABLE :
734 {
735 break;
736 }
728 default : 737 default :
729 { 738 {
730 PE("Should not be here %d.", type); 739 PE("Should not be here %d.", type);
@@ -792,8 +801,10 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
792 { 801 {
793 result->name.text = identifier->value.stringValue; 802 result->name.text = identifier->value.stringValue;
794 result->name.ignorableText = identifier->ignorableText; 803 result->name.ignorableText = identifier->ignorableText;
804 identifier->ignorableText = NULL;
795 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken]; 805 result->value.toKen = tokens[LSL_UNKNOWN - lowestToken];
796 identifier->value.identifierValue = result; 806 identifier->value.identifierValue = result;
807 identifier->toKen = tokens[LSL_VARIABLE - lowestToken];
797 identifier->left = type; 808 identifier->left = type;
798 identifier->right = assignment; 809 identifier->right = assignment;
799 if (assignment) 810 if (assignment)
@@ -1162,6 +1173,10 @@ static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L
1162 { 1173 {
1163 break; 1174 break;
1164 } 1175 }
1176 case LSL_VARIABLE :
1177 {
1178 break;
1179 }
1165 default : 1180 default :
1166 { 1181 {
1167// PE("Should not be here %d.", type); 1182// PE("Should not be here %d.", type);
@@ -1310,6 +1325,10 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state
1310 { 1325 {
1311 break; 1326 break;
1312 } 1327 }
1328 case LSL_VARIABLE :
1329 {
1330 break;
1331 }
1313 default : 1332 default :
1314 { 1333 {
1315 fprintf(file, "@@Should not be here %s.@@", tokens[statement->type - lowestToken]->toKen); 1334 fprintf(file, "@@Should not be here %s.@@", tokens[statement->type - lowestToken]->toKen);
@@ -1386,8 +1405,9 @@ static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *conte
1386 if (content) 1405 if (content)
1387 { 1406 {
1388 LSL_FunctionCall *call = content->value.functionCallValue; 1407 LSL_FunctionCall *call = content->value.functionCallValue;
1389 LSL_Function *func = call->function; 1408
1390 outputText(file, &(func->name), !(LSL_NOIGNORE & content->toKen->flags)); 1409 // TODO - should output it's own ignorable here.
1410 outputText(file, &(call->function->name), FALSE); // Don't output the function definitions ignorable.
1391 fprintf(file, "("); 1411 fprintf(file, "(");
1392 // TODO - print params here. 1412 // TODO - print params here.
1393 fprintf(file, ")"); 1413 fprintf(file, ")");
@@ -1403,7 +1423,12 @@ static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content)
1403static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content) 1423static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content)
1404{ 1424{
1405 if (content) 1425 if (content)
1406 outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); 1426 {
1427 if (LSL_IDENTIFIER == content->toKen->type)
1428 outputText(file, &(content->value.identifierValue->name), FALSE);
1429 else
1430 outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags));
1431 }
1407} 1432}
1408 1433
1409static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) 1434static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content)
@@ -1434,7 +1459,6 @@ static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content)
1434 } 1459 }
1435} 1460}
1436 1461
1437
1438static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content) 1462static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content)
1439{ 1463{
1440 if (content) 1464 if (content)