diff options
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 2 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 88 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 34 |
3 files changed, 90 insertions, 34 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 931537c..dd46167 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -396,7 +396,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
396 | LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); | 396 | LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *newParam); |
397 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); | 397 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval); |
398 | LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifier, LSL_Leaf *block); | 398 | LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifier, LSL_Leaf *block); |
399 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier); | 399 | 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); |
400 | LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr); | 400 | LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr); |
401 | LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr); | 401 | LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr); |
402 | 402 | ||
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index dc2dd5c..00f41da 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -584,7 +584,7 @@ LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf | |||
584 | if (function) | 584 | if (function) |
585 | { | 585 | { |
586 | function->value.functionValue->block = block->value.blockValue; | 586 | function->value.functionValue->block = block->value.blockValue; |
587 | statement = addStatement(compiler, NULL, LSL_FUNCTION, NULL, function, NULL, NULL, NULL); | 587 | statement = addStatement(compiler, NULL, function, NULL, function, NULL, NULL, NULL); |
588 | } | 588 | } |
589 | 589 | ||
590 | return statement; | 590 | return statement; |
@@ -676,17 +676,18 @@ LSL_Leaf *addState(LuaSL_compiler *compiler, LSL_Leaf *state, LSL_Leaf *identifi | |||
676 | return identifier; | 676 | return identifier; |
677 | } | 677 | } |
678 | 678 | ||
679 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) | 679 | 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) |
680 | { | 680 | { |
681 | gameGlobals *game = compiler->game; | 681 | gameGlobals *game = compiler->game; |
682 | LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); | 682 | LSL_Statement *stat = calloc(1, sizeof(LSL_Statement)); |
683 | boolean justOne = FALSE; | ||
683 | 684 | ||
684 | if (NULL == lval) | 685 | if (NULL == lval) |
685 | lval = newLeaf(LSL_STATEMENT, NULL, NULL); | 686 | lval = newLeaf(LSL_STATEMENT, NULL, NULL); |
686 | 687 | ||
687 | if (stat) | 688 | if (stat) |
688 | { | 689 | { |
689 | stat->type = type; | 690 | stat->type = flow->toKen->type; |
690 | stat->expressions = expr; | 691 | stat->expressions = expr; |
691 | if (block) | 692 | if (block) |
692 | stat->block = block->value.blockValue; | 693 | stat->block = block->value.blockValue; |
@@ -701,17 +702,7 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type, | |||
701 | stat->parenthesis = parens->value.parenthesis; | 702 | stat->parenthesis = parens->value.parenthesis; |
702 | } | 703 | } |
703 | 704 | ||
704 | if (lval) | 705 | switch (stat->type) |
705 | { | ||
706 | #if LUASL_DIFF_CHECK | ||
707 | stat->ignorable = calloc(1, sizeof(Eina_Strbuf *)); | ||
708 | stat->ignorable[0] = lval->ignorable; | ||
709 | lval->ignorable = NULL; | ||
710 | #endif | ||
711 | lval->value.statementValue = stat; | ||
712 | } | ||
713 | |||
714 | switch (type) | ||
715 | { | 706 | { |
716 | case LSL_EXPRESSION : | 707 | case LSL_EXPRESSION : |
717 | { | 708 | { |
@@ -731,28 +722,37 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type, | |||
731 | } | 722 | } |
732 | case LSL_IF : | 723 | case LSL_IF : |
733 | { | 724 | { |
725 | justOne = TRUE; | ||
734 | break; | 726 | break; |
735 | } | 727 | } |
736 | case LSL_ELSE : | 728 | case LSL_ELSE : |
737 | { | 729 | { |
730 | justOne = TRUE; | ||
738 | break; | 731 | break; |
739 | } | 732 | } |
740 | case LSL_JUMP : | 733 | case LSL_JUMP : |
741 | { | 734 | { |
735 | justOne = TRUE; | ||
742 | break; | 736 | break; |
743 | } | 737 | } |
744 | case LSL_RETURN : | 738 | case LSL_RETURN : |
745 | { | 739 | { |
740 | justOne = TRUE; | ||
746 | break; | 741 | break; |
747 | } | 742 | } |
748 | case LSL_STATE_CHANGE : | 743 | case LSL_STATE_CHANGE : |
749 | { | 744 | { |
745 | justOne = TRUE; | ||
746 | break; | ||
747 | } | ||
748 | case LSL_STATEMENT : | ||
749 | { | ||
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | case LSL_WHILE : | 752 | case LSL_WHILE : |
753 | { | 753 | { |
754 | stat->identifier = NULL; | 754 | stat->identifier = NULL; |
755 | // TODO - need to stash the while's white space somewhere. | 755 | justOne = TRUE; |
756 | break; | 756 | break; |
757 | } | 757 | } |
758 | case LSL_IDENTIFIER : | 758 | case LSL_IDENTIFIER : |
@@ -765,11 +765,34 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Type type, | |||
765 | } | 765 | } |
766 | default : | 766 | default : |
767 | { | 767 | { |
768 | PE("Should not be here %d.", type); | 768 | PE("Should not be here %d.", stat->type); |
769 | break; | 769 | break; |
770 | } | 770 | } |
771 | } | 771 | } |
772 | 772 | ||
773 | if (justOne && (flow)) | ||
774 | { | ||
775 | stat->ignorable = calloc(2, sizeof(Eina_Strbuf *)); | ||
776 | if (stat->ignorable) | ||
777 | { | ||
778 | stat->ignorable[1] = flow->ignorable; | ||
779 | flow->ignorable = NULL; | ||
780 | } | ||
781 | } | ||
782 | |||
783 | if (lval) | ||
784 | { | ||
785 | #if LUASL_DIFF_CHECK | ||
786 | if (NULL == stat->ignorable) | ||
787 | stat->ignorable = calloc(1, sizeof(Eina_Strbuf *)); | ||
788 | if (stat->ignorable) | ||
789 | { | ||
790 | stat->ignorable[0] = lval->ignorable; | ||
791 | lval->ignorable = NULL; | ||
792 | } | ||
793 | #endif | ||
794 | lval->value.statementValue = stat; | ||
795 | } | ||
773 | } | 796 | } |
774 | 797 | ||
775 | return lval; | 798 | return lval; |
@@ -1195,6 +1218,11 @@ static LSL_Leaf *evaluateStatementToken(LSL_Leaf *content, LSL_Leaf *left, LSL_L | |||
1195 | { | 1218 | { |
1196 | break; | 1219 | break; |
1197 | } | 1220 | } |
1221 | case LSL_STATEMENT : | ||
1222 | { | ||
1223 | result = evaluateLeaf(content->value.statementValue->expressions, left, right); | ||
1224 | break; | ||
1225 | } | ||
1198 | case LSL_WHILE : | 1226 | case LSL_WHILE : |
1199 | { | 1227 | { |
1200 | break; | 1228 | break; |
@@ -1326,32 +1354,60 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1326 | case LSL_IF : | 1354 | case LSL_IF : |
1327 | { | 1355 | { |
1328 | isBlock = TRUE; | 1356 | isBlock = TRUE; |
1357 | #if LUASL_DIFF_CHECK | ||
1358 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1359 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1360 | #endif | ||
1329 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1361 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1330 | break; | 1362 | break; |
1331 | } | 1363 | } |
1332 | case LSL_ELSE : | 1364 | case LSL_ELSE : |
1333 | { | 1365 | { |
1366 | #if LUASL_DIFF_CHECK | ||
1367 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1368 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1369 | #endif | ||
1334 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1370 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1335 | break; | 1371 | break; |
1336 | } | 1372 | } |
1337 | case LSL_JUMP : | 1373 | case LSL_JUMP : |
1338 | { | 1374 | { |
1375 | #if LUASL_DIFF_CHECK | ||
1376 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1377 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1378 | #endif | ||
1339 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1379 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1340 | break; | 1380 | break; |
1341 | } | 1381 | } |
1342 | case LSL_RETURN : | 1382 | case LSL_RETURN : |
1343 | { | 1383 | { |
1384 | #if LUASL_DIFF_CHECK | ||
1385 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1386 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1387 | #endif | ||
1344 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1388 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1345 | break; | 1389 | break; |
1346 | } | 1390 | } |
1347 | case LSL_STATE_CHANGE : | 1391 | case LSL_STATE_CHANGE : |
1348 | { | 1392 | { |
1393 | #if LUASL_DIFF_CHECK | ||
1394 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1395 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1396 | #endif | ||
1349 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1397 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1350 | break; | 1398 | break; |
1351 | } | 1399 | } |
1400 | case LSL_STATEMENT : | ||
1401 | { | ||
1402 | break; | ||
1403 | } | ||
1352 | case LSL_WHILE : | 1404 | case LSL_WHILE : |
1353 | { | 1405 | { |
1354 | isBlock = TRUE; | 1406 | isBlock = TRUE; |
1407 | #if LUASL_DIFF_CHECK | ||
1408 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1409 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1410 | #endif | ||
1355 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1411 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1356 | break; | 1412 | break; |
1357 | } | 1413 | } |
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 6a489f3..bbc4939 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -43,7 +43,7 @@ functionList(A) ::= functionBody(C). { A = collectStatements(compiler, NULL | |||
43 | // No such thing as a function list with no functions. | 43 | // No such thing as a function list with no functions. |
44 | //functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } | 44 | //functionList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } |
45 | 45 | ||
46 | functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, LSL_FUNCTION, NULL, B, NULL, NULL); | 46 | functionBody(A) ::= function(F) block(B). { A = addFunctionBody(compiler, F, B); } // addFunctionBody has an implied addStatement(compiler, NULL, F, NULL, B, NULL, NULL); |
47 | 47 | ||
48 | parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } | 48 | parameterList(A) ::= parameterList(B) LSL_COMMA(C) parameter(D). { A = collectParameters(compiler, B, C, D); } |
49 | parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } | 49 | parameterList(A) ::= parameter(D). { A = collectParameters(compiler, NULL, NULL, D); } |
@@ -67,31 +67,31 @@ statementList(A) ::= . { A = collectStatements(compiler, NULL, NULL); } | |||
67 | 67 | ||
68 | %nonassoc LSL_DO LSL_FOR LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. | 68 | %nonassoc LSL_DO LSL_FOR LSL_IF LSL_JUMP LSL_RETURN LSL_STATE_CHANGE LSL_WHILE. |
69 | %nonassoc LSL_ELSE. | 69 | %nonassoc LSL_ELSE. |
70 | statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, L, E, R, B, W); } | 70 | statement(A) ::= LSL_DO(F) block(B) LSL_WHILE(W) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, L, E, R, B, W); } |
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->toKen->type, 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->toKen->type, 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 ::= ifBlock LSL_ELSE block. |
76 | ifBlock ::= ifBlock LSL_ELSE statement. | 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->toKen->type, L, E, R, B, NULL); } | 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); } |
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->toKen->type, L, E, R, NULL, 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); } |
79 | 79 | ||
80 | statement(A) ::= LSL_JUMP(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 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_RETURN(F) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, E, NULL, NULL, NULL); } | 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) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, NULL); } | 82 | statement(A) ::= LSL_RETURN(F) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, NULL); } |
83 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 83 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_DEFAULT(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } |
84 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 84 | statement(A) ::= LSL_STATE_CHANGE(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } |
85 | statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F->toKen->type, L, E, R, B, NULL); } | 85 | statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) block(B). { A = addStatement(compiler, NULL, F, L, E, R, B, NULL); } |
86 | statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F->toKen->type, L, E, R, NULL, NULL); } | 86 | statement(A) ::= LSL_WHILE(F) LSL_PARENTHESIS_OPEN(L) expr(E) LSL_PARENTHESIS_CLOSE(R) statement(S). { A = addStatement(compiler, S, F, L, E, R, NULL, NULL); } |
87 | 87 | ||
88 | %nonassoc LSL_LABEL. | 88 | %nonassoc LSL_LABEL. |
89 | statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F->toKen->type, NULL, NULL, NULL, NULL, I); } | 89 | statement(A) ::= LSL_LABEL(F) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, F, NULL, NULL, NULL, NULL, I); } |
90 | 90 | ||
91 | beginBlock(A) ::= LSL_BLOCK_OPEN(B). { A = beginBlock(compiler, B); } | 91 | beginBlock(A) ::= LSL_BLOCK_OPEN(B). { A = beginBlock(compiler, B); } |
92 | 92 | ||
93 | // This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them. | 93 | // This might be bogus, or might be valid LSL, but it lets us test the expression parser by evaluating them. |
94 | statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_EXPRESSION, NULL, E, NULL, NULL, NULL); } | 94 | statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, S, NULL, E, NULL, NULL, NULL); } |
95 | 95 | ||
96 | // Various forms of expression. | 96 | // Various forms of expression. |
97 | 97 | ||
@@ -177,8 +177,8 @@ expr(A) ::= identifier(B) LSL_ASSIGNMENT_PLAIN(C) expr(D). { A = addOperation(c | |||
177 | // Hmm think this can have commas seperating the assignment parts, or is that only in C?. If so, best to separate them when converting to Lua, as it uses that syntax for something else. | 177 | // Hmm think this can have commas seperating the assignment parts, or is that only in C?. If so, best to separate them when converting to Lua, as it uses that syntax for something else. |
178 | // Well, not in OpenSim at least, nor in SL. So we are safe. B-) | 178 | // Well, not in OpenSim at least, nor in SL. So we are safe. B-) |
179 | // On the other hand, it might be legal to have comma separated bits in a for loop - for ((i = 1), (j=1); ... | 179 | // On the other hand, it might be legal to have comma separated bits in a for loop - for ((i = 1), (j=1); ... |
180 | statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_IDENTIFIER, NULL, addVariable(compiler, T, I, D, E), NULL, NULL, I); } | 180 | statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(S). { A = addStatement(compiler, S, I, NULL, addVariable(compiler, T, I, D, E), NULL, NULL, I); } |
181 | statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, LSL_IDENTIFIER, NULL, addVariable(compiler, T, I, NULL, NULL), NULL, NULL, I); } | 181 | statement(A) ::= type(T) LSL_IDENTIFIER(I) LSL_STATEMENT(S). { A = addStatement(compiler, S, I, NULL, addVariable(compiler, T, I, NULL, NULL), NULL, NULL, I); } |
182 | 182 | ||
183 | %right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL LSL_VARIABLE. | 183 | %right LSL_DOT LSL_IDENTIFIER LSL_FUNCTION_CALL LSL_VARIABLE. |
184 | identifier(A) ::= identifier LSL_DOT LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); A->basicType = OT_float; } // Just a stub to get it to work for now. | 184 | identifier(A) ::= identifier LSL_DOT LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); A->basicType = OT_float; } // Just a stub to get it to work for now. |