-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): fix autocasting augment assignment always using =
- Loading branch information
Showing
6 changed files
with
188 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
compiler/test_data/compiler_tests/auto_casting/autocastboolcount.yaka
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def main() -> int: | ||
a = 0 | ||
b = True | ||
for (x = 0; x < 10; x = x + 1): | ||
a += b | ||
println(a) | ||
0 |
154 changes: 154 additions & 0 deletions
154
compiler/test_data/compiler_tests/output/autocastboolcount.tokens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
[ | ||
["output.c",0,1,"//","INT_DIV"], | ||
["output.c",0,4,"YK","NAME"], | ||
["output.c",0,6,"\n","NEW_LINE"], | ||
["output.c",1,1,"include \"yk__lib.h\"","COMMENT"], | ||
["output.c",1,21,"\n","NEW_LINE"], | ||
["output.c",2,1,"//","INT_DIV"], | ||
["output.c",2,4,"-","SUB"], | ||
["output.c",2,5,"-","SUB"], | ||
["output.c",2,6,"forward","NAME"], | ||
["output.c",2,14,"declarations","NAME"], | ||
["output.c",2,26,"-","SUB"], | ||
["output.c",2,27,"-","SUB"], | ||
["output.c",2,29,"\n","NEW_LINE"], | ||
["output.c",3,1,"int32_t","NAME"], | ||
["output.c",3,9,"yy__main","NAME"], | ||
["output.c",3,17,"(","PAREN_OPEN"], | ||
["output.c",3,18,")","PAREN_CLOSE"], | ||
["output.c",3,19,";","SEMICOLON"], | ||
["output.c",3,20,"\n","NEW_LINE"], | ||
["output.c",4,1,"//","INT_DIV"], | ||
["output.c",4,4,"-","SUB"], | ||
["output.c",4,5,"-","SUB"], | ||
["output.c",4,6,"structs","NAME"], | ||
["output.c",4,13,"-","SUB"], | ||
["output.c",4,14,"-","SUB"], | ||
["output.c",4,16,"\n","NEW_LINE"], | ||
["output.c",5,1,"//","INT_DIV"], | ||
["output.c",5,4,"-","SUB"], | ||
["output.c",5,5,"-","SUB"], | ||
["output.c",5,6,"functions","NAME"], | ||
["output.c",5,15,"-","SUB"], | ||
["output.c",5,16,"-","SUB"], | ||
["output.c",5,18,"\n","NEW_LINE"], | ||
["output.c",6,1,"int32_t","NAME"], | ||
["output.c",6,9,"yy__main","NAME"], | ||
["output.c",6,17,"(","PAREN_OPEN"], | ||
["output.c",6,18,")","PAREN_CLOSE"], | ||
["output.c",6,20,"\n","NEW_LINE"], | ||
["output.c",7,1,"{","CURLY_BRACKET_OPEN"], | ||
["output.c",7,2,"\n","NEW_LINE"], | ||
["output.c",8,1," ","INDENT"], | ||
["output.c",8,5,"int32_t","NAME"], | ||
["output.c",8,13,"yy__a","NAME"], | ||
["output.c",8,19,"=","EQ"], | ||
["output.c",8,21,"INT32_C","NAME"], | ||
["output.c",8,28,"(","PAREN_OPEN"], | ||
["output.c",8,29,"0","INTEGER_DECIMAL"], | ||
["output.c",8,30,")","PAREN_CLOSE"], | ||
["output.c",8,31,";","SEMICOLON"], | ||
["output.c",8,32,"\n","NEW_LINE"], | ||
["output.c",9,1," ","INDENT"], | ||
["output.c",9,5,"bool","NAME"], | ||
["output.c",9,10,"yy__b","NAME"], | ||
["output.c",9,16,"=","EQ"], | ||
["output.c",9,18,"true","NAME"], | ||
["output.c",9,22,";","SEMICOLON"], | ||
["output.c",9,23,"\n","NEW_LINE"], | ||
["output.c",10,1," ","INDENT"], | ||
["output.c",10,5,"for","KEYWORD_FOR"], | ||
["output.c",10,9,"(","PAREN_OPEN"], | ||
["output.c",10,10,"int32_t","NAME"], | ||
["output.c",10,18,"yy__x","NAME"], | ||
["output.c",10,24,"=","EQ"], | ||
["output.c",10,26,"INT32_C","NAME"], | ||
["output.c",10,33,"(","PAREN_OPEN"], | ||
["output.c",10,34,"0","INTEGER_DECIMAL"], | ||
["output.c",10,35,")","PAREN_CLOSE"], | ||
["output.c",10,36,";","SEMICOLON"], | ||
["output.c",10,37,"(","PAREN_OPEN"], | ||
["output.c",10,38,"yy__x","NAME"], | ||
["output.c",10,44,"<","LESS"], | ||
["output.c",10,46,"INT32_C","NAME"], | ||
["output.c",10,53,"(","PAREN_OPEN"], | ||
["output.c",10,54,"10","INTEGER_DECIMAL"], | ||
["output.c",10,56,")","PAREN_CLOSE"], | ||
["output.c",10,57,")","PAREN_CLOSE"], | ||
["output.c",10,58,";","SEMICOLON"], | ||
["output.c",10,59,"yy__x","NAME"], | ||
["output.c",10,65,"=","EQ"], | ||
["output.c",10,67,"(","PAREN_OPEN"], | ||
["output.c",10,68,"yy__x","NAME"], | ||
["output.c",10,74,"+","PLUS"], | ||
["output.c",10,76,"INT32_C","NAME"], | ||
["output.c",10,83,"(","PAREN_OPEN"], | ||
["output.c",10,84,"1","INTEGER_DECIMAL"], | ||
["output.c",10,85,")","PAREN_CLOSE"], | ||
["output.c",10,86,")","PAREN_CLOSE"], | ||
["output.c",10,87,")","PAREN_CLOSE"], | ||
["output.c",10,88,"\n","NEW_LINE"], | ||
["output.c",11,1," ","INDENT"], | ||
["output.c",11,5,"{","CURLY_BRACKET_OPEN"], | ||
["output.c",11,6,"\n","NEW_LINE"], | ||
["output.c",12,1," ","INDENT"], | ||
["output.c",12,9,"yy__a","NAME"], | ||
["output.c",12,14,"+=","PLUS_EQ"], | ||
["output.c",12,16,"(","PAREN_OPEN"], | ||
["output.c",12,17,"(","PAREN_OPEN"], | ||
["output.c",12,18,"int32_t","NAME"], | ||
["output.c",12,25,")","PAREN_CLOSE"], | ||
["output.c",12,26,"(","PAREN_OPEN"], | ||
["output.c",12,27,"(","PAREN_OPEN"], | ||
["output.c",12,28,"(","PAREN_OPEN"], | ||
["output.c",12,29,"yy__b","NAME"], | ||
["output.c",12,34,")","PAREN_CLOSE"], | ||
["output.c",12,38,"1","INTEGER_DECIMAL"], | ||
["output.c",12,40,":","COLON"], | ||
["output.c",12,42,"0","INTEGER_DECIMAL"], | ||
["output.c",12,43,")","PAREN_CLOSE"], | ||
["output.c",12,44,")","PAREN_CLOSE"], | ||
["output.c",12,45,")","PAREN_CLOSE"], | ||
["output.c",12,46,";","SEMICOLON"], | ||
["output.c",12,47,"\n","NEW_LINE"], | ||
["output.c",13,1," ","INDENT"], | ||
["output.c",13,5,"}","CURLY_BRACKET_CLOSE"], | ||
["output.c",13,6,"\n","NEW_LINE"], | ||
["output.c",14,1," ","INDENT"], | ||
["output.c",14,5,"yk__printlnint","NAME"], | ||
["output.c",14,19,"(","PAREN_OPEN"], | ||
["output.c",14,20,"(","PAREN_OPEN"], | ||
["output.c",14,21,"intmax_t","NAME"], | ||
["output.c",14,29,")","PAREN_CLOSE"], | ||
["output.c",14,30,"yy__a","NAME"], | ||
["output.c",14,35,")","PAREN_CLOSE"], | ||
["output.c",14,36,";","SEMICOLON"], | ||
["output.c",14,37,"\n","NEW_LINE"], | ||
["output.c",15,1," ","INDENT"], | ||
["output.c",15,5,"return","KEYWORD_RETURN"], | ||
["output.c",15,12,"INT32_C","NAME"], | ||
["output.c",15,19,"(","PAREN_OPEN"], | ||
["output.c",15,20,"0","INTEGER_DECIMAL"], | ||
["output.c",15,21,")","PAREN_CLOSE"], | ||
["output.c",15,22,";","SEMICOLON"], | ||
["output.c",15,23,"\n","NEW_LINE"], | ||
["output.c",16,1,"}","CURLY_BRACKET_CLOSE"], | ||
["output.c",16,2,"\n","NEW_LINE"], | ||
["output.c",17,1,"if defined(YK__MINIMAL_MAIN)","COMMENT"], | ||
["output.c",17,30,"\n","NEW_LINE"], | ||
["output.c",18,1,"int","NAME"], | ||
["output.c",18,5,"main","NAME"], | ||
["output.c",18,9,"(","PAREN_OPEN"], | ||
["output.c",18,10,"void","NAME"], | ||
["output.c",18,14,")","PAREN_CLOSE"], | ||
["output.c",18,16,"{","CURLY_BRACKET_OPEN"], | ||
["output.c",18,18,"return","KEYWORD_RETURN"], | ||
["output.c",18,25,"yy__main","NAME"], | ||
["output.c",18,33,"(","PAREN_OPEN"], | ||
["output.c",18,34,")","PAREN_CLOSE"], | ||
["output.c",18,35,";","SEMICOLON"], | ||
["output.c",18,37,"}","CURLY_BRACKET_CLOSE"], | ||
["output.c",18,38,"\n","NEW_LINE"], | ||
["output.c",19,1,"endif","COMMENT"], | ||
["output.c",19,8,"","END_OF_FILE"] | ||
] |
20 changes: 20 additions & 0 deletions
20
compiler/test_data/compiler_tests/output/autocastboolcount.yaka.output.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// YK | ||
#include "yk__lib.h" | ||
// --forward declarations-- | ||
int32_t yy__main(); | ||
// --structs-- | ||
// --functions-- | ||
int32_t yy__main() | ||
{ | ||
int32_t yy__a = INT32_C(0); | ||
bool yy__b = true; | ||
for (int32_t yy__x = INT32_C(0);(yy__x < INT32_C(10));yy__x = (yy__x + INT32_C(1))) | ||
{ | ||
yy__a+=((int32_t)(((yy__b) ? 1 : 0))); | ||
} | ||
yk__printlnint((intmax_t)yy__a); | ||
return INT32_C(0); | ||
} | ||
#if defined(YK__MINIMAL_MAIN) | ||
int main(void) { return yy__main(); } | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters