diff options
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 2 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 10 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 7 |
3 files changed, 16 insertions, 3 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 87d1af0..b5dff7a 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -221,6 +221,7 @@ struct _LSL_Statement | |||
221 | LSL_Parenthesis *parenthesis; | 221 | LSL_Parenthesis *parenthesis; |
222 | LSL_Leaf *expressions; // A for statement will have three expressions, everything else has zero or one. | 222 | LSL_Leaf *expressions; // A for statement will have three expressions, everything else has zero or one. |
223 | LSL_Block *block; | 223 | LSL_Block *block; |
224 | LSL_Statement *elseBlock; | ||
224 | LSL_Type type; // Expression type. | 225 | LSL_Type type; // Expression type. |
225 | #if LUASL_DIFF_CHECK | 226 | #if LUASL_DIFF_CHECK |
226 | Eina_Strbuf **ignorable; // Can be up to five of these I think. | 227 | Eina_Strbuf **ignorable; // Can be up to five of these I think. |
@@ -397,6 +398,7 @@ LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *cre | |||
397 | LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); | 398 | LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); |
398 | LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); | 399 | LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); |
399 | LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); | 400 | LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); |
401 | LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock); | ||
400 | LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); | 402 | LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); |
401 | LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); | 403 | LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); |
402 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); | 404 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); |
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 9c86f97..eada67f 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -727,6 +727,12 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi | |||
727 | return identifier; | 727 | return identifier; |
728 | } | 728 | } |
729 | 729 | ||
730 | LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseBlock) | ||
731 | { | ||
732 | ifBlock->value.statementValue->elseBlock = elseBlock->value.statementValue; | ||
733 | return ifBlock; | ||
734 | } | ||
735 | |||
730 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) | 736 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) |
731 | { | 737 | { |
732 | gameGlobals *game = compiler->game; | 738 | gameGlobals *game = compiler->game; |
@@ -1427,6 +1433,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1427 | } | 1433 | } |
1428 | case LSL_ELSE : | 1434 | case LSL_ELSE : |
1429 | { | 1435 | { |
1436 | isBlock = TRUE; | ||
1430 | #if LUASL_DIFF_CHECK | 1437 | #if LUASL_DIFF_CHECK |
1431 | if ((statement->ignorable) && (statement->ignorable[1])) | 1438 | if ((statement->ignorable) && (statement->ignorable[1])) |
1432 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | 1439 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); |
@@ -1509,6 +1516,9 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1509 | if (!LUASL_DIFF_CHECK) | 1516 | if (!LUASL_DIFF_CHECK) |
1510 | fprintf(file, "\n"); | 1517 | fprintf(file, "\n"); |
1511 | } | 1518 | } |
1519 | |||
1520 | if (statement->elseBlock) | ||
1521 | outputRawStatement(file, mode, statement->elseBlock); | ||
1512 | } | 1522 | } |
1513 | } | 1523 | } |
1514 | 1524 | ||
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 828cf12..72d328c 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -71,11 +71,12 @@ statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) | |||
71 | statement(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, L, E1, R, B, NULL); } // three expressions, two semi colons | 71 | statement(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, L, E1, R, B, NULL); } // three expressions, two semi colons |
72 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F, L, E1, R, NULL, NULL); } // three expressions, two semi colons | 72 | statement(A) ::= LSL_FOR(F) LSL_PARENTHESIS_OPEN(L) expr(E0) LSL_STATEMENT(S0) expr(E1) LSL_STATEMENT(S1) expr(E2) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F, L, E1, R, NULL, NULL); } // three expressions, two semi colons |
73 | 73 | ||
74 | statement(A) ::= ifBlock(B). { A = B; } | 74 | statement(A) ::= ifBlock(B). { A = B; } |
75 | ifBlock ::= ifBlock LSL_ELSE block. | 75 | ifBlock(A) ::= ifBlock(B) elseBlock(E). { A = addIfElse(compiler, B, E); } |
76 | ifBlock ::= ifBlock LSL_ELSE statement. | ||
77 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } | 76 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). [LSL_ELSE] { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } |
78 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, S, F, L, E, R, NULL, NULL); } | 77 | ifBlock(A) ::= LSL_IF(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). [LSL_ELSE] { A = addStatement(compiler, S, F, L, E, R, NULL, NULL); } |
78 | elseBlock(A) ::= LSL_ELSE(F) block(B). { A = addStatement(compiler, NULL, F, NULL, NULL, NULL, B, NULL); } | ||
79 | elseBlock(A) ::= LSL_ELSE(F) statement(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, NULL); } | ||
79 | 80 | ||
80 | statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } | 81 | statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } |
81 | statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, E, NULL, NULL, NULL); } | 82 | statement(A) ::= LSL_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, E, NULL, NULL, NULL); } |