diff options
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 2 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 39 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 8 |
3 files changed, 39 insertions, 10 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index cff2bab..931b6b9 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -394,7 +394,7 @@ typedef struct | |||
394 | 394 | ||
395 | void burnLeaf(void *data); | 395 | void burnLeaf(void *data); |
396 | LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); | 396 | LSL_Leaf *addBlock(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); |
397 | LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement); | 397 | LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement, LSL_Type type); |
398 | LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr0, LSL_Leaf *stat0, LSL_Leaf *expr1, LSL_Leaf *stat1, LSL_Leaf *expr2, LSL_Leaf *right, LSL_Leaf *block); | 398 | LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr0, LSL_Leaf *stat0, LSL_Leaf *expr1, LSL_Leaf *stat1, LSL_Leaf *expr2, LSL_Leaf *right, LSL_Leaf *block); |
399 | LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); | 399 | LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); |
400 | LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); | 400 | LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); |
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_ | |||
8 | static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 8 | static LSL_Leaf *eveluateParenthesisToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
9 | static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 9 | static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
10 | static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content); | 10 | static void outputBlockToken(FILE *file, outputMode mode, LSL_Leaf *content); |
11 | static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content); | ||
11 | static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content); | 12 | static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content); |
12 | static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content); | 13 | static void outputFunctionToken(FILE *file, outputMode mode, LSL_Leaf *content); |
13 | static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *content); | 14 | static 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 | ||
466 | LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement) | 467 | LSL_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 | ||
1614 | static 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 | |||
1611 | static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content) | 1640 | static void outputFloatToken(FILE *file, outputMode mode, LSL_Leaf *content) |
1612 | { | 1641 | { |
1613 | if (content) | 1642 | if (content) |
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index ba32692..b45c7d2 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -186,10 +186,10 @@ identifier(A) ::= identifier LSL_DOT LSL_IDENTIFIER(B). { A = checkVariable( | |||
186 | identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); } | 186 | identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); } |
187 | 187 | ||
188 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. | 188 | %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. |
189 | expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C); } | 189 | expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_DECREMENT_POST); } |
190 | expr(A) ::= identifier(B) LSL_INCREMENT_PRE(C). { A = addCrement(compiler, B, C); } | 190 | expr(A) ::= identifier(B) LSL_INCREMENT_PRE(C). { A = addCrement(compiler, B, C, LSL_INCREMENT_POST); } |
191 | expr(A) ::= LSL_DECREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C); } | 191 | expr(A) ::= LSL_DECREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_DECREMENT_PRE); } |
192 | expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C); } | 192 | expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C, LSL_INCREMENT_PRE); } |
193 | 193 | ||
194 | %nonassoc LSL_COMMA. | 194 | %nonassoc LSL_COMMA. |
195 | 195 | ||