aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_compile.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-02 01:01:59 +1000
committerDavid Walter Seikel2012-02-02 01:01:59 +1000
commit8fcf003634156078c906846ae723599c8d45b6dc (patch)
treea334ce11f2172bcffe511a46b85ec6e9f73fa6f8 /LuaSL/src/LuaSL_compile.c
parentIgnore white space diffences for now. (diff)
downloadSledjHamr-8fcf003634156078c906846ae723599c8d45b6dc.zip
SledjHamr-8fcf003634156078c906846ae723599c8d45b6dc.tar.gz
SledjHamr-8fcf003634156078c906846ae723599c8d45b6dc.tar.bz2
SledjHamr-8fcf003634156078c906846ae723599c8d45b6dc.tar.xz
Output crements properly.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_compile.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 26efbd7..236b2a6 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -8,6 +8,7 @@ static LSL_Leaf *evaluateOperationToken(LSL_Leaf *content, LSL_Leaf *left, LSL_
8static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 8static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
9static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); 9static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right);
10static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content); 10static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content);
11static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content);
11static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content); 12static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content);
12static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content); 13static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content);
13static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *content); 14static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *content);
@@ -90,10 +91,10 @@ LSL_Token LSL_Tokens[] =
90 {LSL_ASSIGNMENT_DIVIDE, ST_ASSIGNMENT, "/=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, NULL, evaluateOperationToken}, 91 {LSL_ASSIGNMENT_DIVIDE, ST_ASSIGNMENT, "/=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, NULL, evaluateOperationToken},
91 {LSL_ASSIGNMENT_PLAIN, ST_CONCATENATION, "=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, NULL, evaluateOperationToken}, 92 {LSL_ASSIGNMENT_PLAIN, ST_CONCATENATION, "=", LSL_RIGHT2LEFT | LSL_ASSIGNMENT, NULL, evaluateOperationToken},
92 {LSL_DOT, ST_NONE, ".", LSL_RIGHT2LEFT, NULL, evaluateOperationToken}, 93 {LSL_DOT, ST_NONE, ".", LSL_RIGHT2LEFT, NULL, evaluateOperationToken},
93 {LSL_DECREMENT_POST, ST_NONE, "--", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, 94 {LSL_DECREMENT_POST, ST_NONE, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputCrementsToken, evaluateOperationToken},
94 {LSL_DECREMENT_PRE, ST_NONE, "--", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, 95 {LSL_DECREMENT_PRE, ST_NONE, "--", LSL_RIGHT2LEFT | LSL_UNARY, outputCrementsToken, evaluateOperationToken},
95 {LSL_INCREMENT_POST, ST_NONE, "++", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, 96 {LSL_INCREMENT_POST, ST_NONE, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputCrementsToken, evaluateOperationToken},
96 {LSL_INCREMENT_PRE, ST_NONE, "++", LSL_RIGHT2LEFT | LSL_UNARY, NULL, evaluateOperationToken}, 97 {LSL_INCREMENT_PRE, ST_NONE, "++", LSL_RIGHT2LEFT | LSL_UNARY, outputCrementsToken, evaluateOperationToken},
97 {LSL_COMMA, ST_NONE, ",", LSL_LEFT2RIGHT, NULL, evaluateOperationToken}, 98 {LSL_COMMA, ST_NONE, ",", LSL_LEFT2RIGHT, NULL, evaluateOperationToken},
98 99
99 {LSL_EXPRESSION, ST_NONE, "expression", LSL_NONE , NULL, NULL}, 100 {LSL_EXPRESSION, ST_NONE, "expression", LSL_NONE , NULL, NULL},
@@ -463,11 +464,13 @@ LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL
463 return lval; 464 return lval;
464} 465}
465 466
466LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement) 467LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement, LSL_Type type)
467{ 468{
468 if ((variable) && (crement)) 469 if ((variable) && (crement))
469 { 470 {
471 crement->value.identifierValue = variable->value.identifierValue;
470 crement->basicType = variable->basicType; 472 crement->basicType = variable->basicType;
473 crement->toKen = tokens[type - lowestToken];
471 } 474 }
472 475
473 return crement; 476 return crement;
@@ -1608,6 +1611,32 @@ static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content)
1608 outputRawBlock(file, mode, content->value.blockValue); 1611 outputRawBlock(file, mode, content->value.blockValue);
1609} 1612}
1610 1613
1614static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content)
1615{
1616 if (content)
1617 {
1618 switch (content->toKen->type)
1619 {
1620 case LSL_DECREMENT_PRE :
1621 case LSL_INCREMENT_PRE :
1622 {
1623 fprintf(file, "%s", content->toKen->toKen);
1624 outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags));
1625 break;
1626 }
1627 case LSL_DECREMENT_POST :
1628 case LSL_INCREMENT_POST :
1629 {
1630 outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags));
1631 fprintf(file, "%s", content->toKen->toKen);
1632 break;
1633 }
1634 default :
1635 break;
1636 }
1637 }
1638}
1639
1611static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content) 1640static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content)
1612{ 1641{
1613 if (content) 1642 if (content)