BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
| Revision | 152 (tree) |
|---|---|
| Time | 2016-08-24 04:04:02 |
| Author | kmorimatsu |
Execute next_position() macro in nextCodeIs() function.
| @@ -78,6 +78,7 @@ | ||
| 78 | 78 | |
| 79 | 79 | int nextCodeIs(char* str){ |
| 80 | 80 | int len; |
| 81 | + next_position(); | |
| 81 | 82 | for(len=0;str[len];len++); |
| 82 | 83 | if (!strncmp(g_source+g_srcpos,str,len)) { |
| 83 | 84 | if ('A'<=str[len-1] && str[len-1]<='Z') { |
| @@ -139,6 +139,9 @@ | ||
| 139 | 139 | |
| 140 | 140 | static const char bastext[]= |
| 141 | 141 | "CLS\n" |
| 142 | +"WHILE 1\n" | |
| 143 | +" IF J THEN BREAK ELSE J=1\n" | |
| 144 | +" WEND\n" | |
| 142 | 145 | "\n"; |
| 143 | 146 | |
| 144 | 147 | /* |
| @@ -499,7 +499,6 @@ | ||
| 499 | 499 | // Check "THEN" |
| 500 | 500 | if (!nextCodeIs("THEN")) return ERR_SYNTAX; |
| 501 | 501 | // Check if statement follows after THEN statement |
| 502 | - next_position(); | |
| 503 | 502 | if (nextCodeIs("REM")) { |
| 504 | 503 | // If REM statement follows, skip comment words. |
| 505 | 504 | rem_statement(); |
| @@ -518,7 +517,6 @@ | ||
| 518 | 517 | g_object[g_objpos++]=0x30008000; // nop (see linker) |
| 519 | 518 | g_object[g_objpos++]=0x30000000; // nop (see linker) |
| 520 | 519 | // Check if statement follows after THEN statement |
| 521 | - next_position(); | |
| 522 | 520 | if (nextCodeIs("REM")) { |
| 523 | 521 | // If REM statement follows, skip comment words. |
| 524 | 522 | rem_statement(); |
| @@ -533,7 +531,6 @@ | ||
| 533 | 531 | g_object[g_objpos++]=0x30008000; // nop (see linker) |
| 534 | 532 | g_object[g_objpos++]=0x30008000; // nop (see linker) |
| 535 | 533 | // Check if statement follows after THEN statement |
| 536 | - next_position(); | |
| 537 | 534 | if (nextCodeIs("REM")) { |
| 538 | 535 | // If REM statement follows, skip comment words. |
| 539 | 536 | rem_statement(); |
| @@ -730,7 +727,6 @@ | ||
| 730 | 727 | err=let_statement(); |
| 731 | 728 | if (err) return err; |
| 732 | 729 | // Check if "TO" exists |
| 733 | - next_position(); | |
| 734 | 730 | if (!nextCodeIs("TO ")) return ERR_SYNTAX; |
| 735 | 731 | err=get_value(); |
| 736 | 732 | if (err) return err; |
| @@ -743,7 +739,6 @@ | ||
| 743 | 739 | g_object[g_objpos++]=0x0820FFF4; // addiu sp,sp,-12 (see linker) |
| 744 | 740 | g_object[g_objpos++]=0xAFA2000C; // sw v0,12(sp) |
| 745 | 741 | // Check if "STEP" exists |
| 746 | - next_position(); | |
| 747 | 742 | g_valueisconst=1; |
| 748 | 743 | if (nextCodeIs("STEP ")) { |
| 749 | 744 | // "STEP" exists. Get value |
| @@ -799,7 +794,6 @@ | ||
| 799 | 794 | g_object[g_objpos++]=0x0822FFFC;// addiu sp,sp,-4 (see linker) |
| 800 | 795 | // label1: |
| 801 | 796 | g_object[g_objpos++]=0xAFBF0004;// sw ra,4(sp) |
| 802 | - next_position(); | |
| 803 | 797 | if (nextCodeIs("WHILE ")) { |
| 804 | 798 | // DO WHILE |
| 805 | 799 | err=get_floatOrValue(); |
| @@ -827,7 +821,6 @@ | ||
| 827 | 821 | |
| 828 | 822 | char* loop_statement(){ |
| 829 | 823 | char* err; |
| 830 | - next_position(); | |
| 831 | 824 | if (nextCodeIs("WHILE ")) { |
| 832 | 825 | // LOOP WHILE |
| 833 | 826 | err=get_floatOrValue(); |
| @@ -1258,7 +1251,6 @@ | ||
| 1258 | 1251 | char* statement(void){ |
| 1259 | 1252 | char* err; |
| 1260 | 1253 | int prevpos; |
| 1261 | - next_position(); | |
| 1262 | 1254 | // Clear flag for temp area usage. |
| 1263 | 1255 | g_temp_area_used=0; |
| 1264 | 1256 | // Initialize stack handler used for value |