aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-14 15:54:44 +1000
committerDavid Walter Seikel2014-05-14 15:54:44 +1000
commit859839dd9a93af045f95189c039b17191ab9f988 (patch)
treeaa428e470606b2266add9bd2223e1b06b83fa3f2 /src/LuaSL
parentComment out some excess compiler warnings. (diff)
downloadSledjHamr-859839dd9a93af045f95189c039b17191ab9f988.zip
SledjHamr-859839dd9a93af045f95189c039b17191ab9f988.tar.gz
SledjHamr-859839dd9a93af045f95189c039b17191ab9f988.tar.bz2
SledjHamr-859839dd9a93af045f95189c039b17191ab9f988.tar.xz
Get list appending and adding to work.
Diffstat (limited to 'src/LuaSL')
-rw-r--r--src/LuaSL/LuaSL_compile.c56
-rw-r--r--src/LuaSL/LuaSL_lemon_yaccer.y2
2 files changed, 55 insertions, 3 deletions
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index bab94f3..f2fa37e 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -145,6 +145,10 @@ LSL_Token LSL_Tokens[] =
145 {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken}, 145 {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken},
146 {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL}, 146 {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL},
147 147
148 {LSL_LIST_CONCAT, ST_CONCATENATION,"listconcat", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, NULL},
149 {LSL_LIST_ADD, ST_ADD, "listadd", LSL_LEFT2RIGHT, NULL},
150 {LSL_LIST_ADD_LIST, ST_ADD, "listaddlist", LSL_LEFT2RIGHT, NULL},
151
148 {LSL_UNKNOWN, ST_NONE, "unknown", LSL_NONE, NULL}, 152 {LSL_UNKNOWN, ST_NONE, "unknown", LSL_NONE, NULL},
149 153
150 // A sentinal. 154 // A sentinal.
@@ -472,6 +476,28 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
472 lval->basicType = OT_vector; 476 lval->basicType = OT_vector;
473 } 477 }
474 break; 478 break;
479
480 case ST_ADD :
481 // TODO - This doesn't work if the right side has been cast to a list.
482 if (OT_listList == lval->basicType)
483 {
484 lval->basicType = OT_list;
485 lval->toKen = tokens[LSL_LIST_ADD_LIST - lowestToken];
486 }
487 else if (OT_list == lType)
488 {
489 lval->basicType = OT_list;
490 lval->toKen = tokens[LSL_LIST_ADD - lowestToken];
491 }
492 break;
493
494 case ST_CONCATENATION :
495 if ((OT_list == lType) && (OT_list != rType))
496 {
497 lval->basicType = OT_list;
498 lval->toKen = tokens[LSL_LIST_CONCAT - lowestToken];
499 }
500 break;
475 default : 501 default :
476 break; 502 break;
477 } 503 }
@@ -1349,7 +1375,7 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf)
1349{ 1375{
1350 if (leaf) 1376 if (leaf)
1351 { 1377 {
1352 if ((OM_LUA == mode) &&(ST_BITWISE != leaf->toKen->subType)) 1378 if ((OM_LUA == mode) && (ST_BITWISE != leaf->toKen->subType) && (LSL_LIST_ADD != leaf->toKen->type) && (LSL_LIST_ADD_LIST != leaf->toKen->type))
1353 outputLeaf(file, mode, leaf->left); 1379 outputLeaf(file, mode, leaf->left);
1354#if LUASL_DIFF_CHECK 1380#if LUASL_DIFF_CHECK
1355 if ((!(LSL_NOIGNORE & leaf->toKen->flags)) && (leaf->ignorable)) 1381 if ((!(LSL_NOIGNORE & leaf->toKen->flags)) && (leaf->ignorable))
@@ -1375,7 +1401,15 @@ else
1375 } 1401 }
1376 if ((LSL_ASSIGNMENT & leaf->toKen->flags) && (LSL_ASSIGNMENT_PLAIN != leaf->toKen->type)) 1402 if ((LSL_ASSIGNMENT & leaf->toKen->flags) && (LSL_ASSIGNMENT_PLAIN != leaf->toKen->type))
1377 { 1403 {
1378 if (leaf->left->value.identifierValue->sub) 1404 if (LSL_LIST_CONCAT == leaf->toKen->type)
1405 {
1406 fprintf(file, " = _LSL.listConcat(");
1407 outputLeaf(file, mode, leaf->left);
1408 fprintf(file, ", ");
1409 outputLeaf(file, mode, leaf->right);
1410 fprintf(file, ") ");
1411 }
1412 else if (leaf->left->value.identifierValue->sub)
1379 fprintf(file, " --[[%s]] = %s.%s %.1s ", leaf->toKen->toKen, leaf->left->value.identifierValue->name.text, leaf->left->value.identifierValue->sub, leaf->toKen->toKen); 1413 fprintf(file, " --[[%s]] = %s.%s %.1s ", leaf->toKen->toKen, leaf->left->value.identifierValue->name.text, leaf->left->value.identifierValue->sub, leaf->toKen->toKen);
1380 else 1414 else
1381 fprintf(file, " --[[%s]] = %s %.1s ", leaf->toKen->toKen, leaf->left->value.identifierValue->name.text, leaf->toKen->toKen); 1415 fprintf(file, " --[[%s]] = %s %.1s ", leaf->toKen->toKen, leaf->left->value.identifierValue->name.text, leaf->toKen->toKen);
@@ -1396,13 +1430,29 @@ else
1396 fprintf(file, " .. "); 1430 fprintf(file, " .. ");
1397 else if (LSL_NOT_EQUAL == leaf->toKen->type) 1431 else if (LSL_NOT_EQUAL == leaf->toKen->type)
1398 fprintf(file, " ~= "); 1432 fprintf(file, " ~= ");
1433 else if (LSL_LIST_ADD == leaf->toKen->type)
1434 {
1435 fprintf(file, " _LSL.listAdd(");
1436 outputLeaf(file, mode, leaf->left);
1437 fprintf(file, ", ");
1438 outputLeaf(file, mode, leaf->right);
1439 fprintf(file, ") ");
1440 }
1441 else if (LSL_LIST_ADD_LIST == leaf->toKen->type)
1442 {
1443 fprintf(file, " _LSL.listAddList(");
1444 outputLeaf(file, mode, leaf->left);
1445 fprintf(file, ", ");
1446 outputLeaf(file, mode, leaf->right);
1447 fprintf(file, ") ");
1448 }
1399 else 1449 else
1400 fprintf(file, "%s", leaf->toKen->toKen); 1450 fprintf(file, "%s", leaf->toKen->toKen);
1401 } 1451 }
1402 else 1452 else
1403 fprintf(file, "%s", leaf->toKen->toKen); 1453 fprintf(file, "%s", leaf->toKen->toKen);
1404 } 1454 }
1405 if ((OM_LUA == mode) &&(ST_BITWISE != leaf->toKen->subType)) 1455 if ((OM_LUA == mode) && (ST_BITWISE != leaf->toKen->subType) && (LSL_LIST_ADD != leaf->toKen->type) && (LSL_LIST_CONCAT != leaf->toKen->type) && (LSL_LIST_ADD_LIST != leaf->toKen->type))
1406 outputLeaf(file, mode, leaf->right); 1456 outputLeaf(file, mode, leaf->right);
1407 } 1457 }
1408} 1458}
diff --git a/src/LuaSL/LuaSL_lemon_yaccer.y b/src/LuaSL/LuaSL_lemon_yaccer.y
index 72c4479..f03837e 100644
--- a/src/LuaSL/LuaSL_lemon_yaccer.y
+++ b/src/LuaSL/LuaSL_lemon_yaccer.y
@@ -165,6 +165,8 @@ expr(A) ::= LSL_BIT_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C
165expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); } 165expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); }
166expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(compiler, NULL, B, C); } 166expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(compiler, NULL, B, C); }
167 167
168%left LSL_LIST_CONCAT LSL_LIST_ADD LSL_LIST_ADD_LIST.
169
168// Types, typecasts, and expression reordering. 170// Types, typecasts, and expression reordering.
169 171
170%right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE. 172%right LSL_TYPECAST_OPEN LSL_TYPECAST_CLOSE.