BASIC compiler/interpreter for PIC32MX/MZ-80K
修订版 | 12c7d76ebddb2f37529ea015d97bd070ac79ddf4 (tree) |
---|---|
时间 | 2019-04-01 05:05:01 |
作者 | Katsumi <kmorimatsu@sour...> |
Commiter | Katsumi |
OPTION NOLINENUM for Zoea ver 1.2
@@ -160,8 +160,10 @@ char* compile_line(void){ | ||
160 | 160 | printstr(resolve_label(g_line)); |
161 | 161 | return ERR_MULTIPLE_LABEL; |
162 | 162 | } |
163 | - check_obj_space(1); | |
164 | - g_object[g_objpos++]=0x34160000|g_line; //ori s6,zero,xxxx; | |
163 | + if (!g_nolinenum) { | |
164 | + check_obj_space(1); | |
165 | + g_object[g_objpos++]=0x34160000|g_line; //ori s6,zero,xxxx; | |
166 | + } | |
165 | 167 | } |
166 | 168 | while(g_source[g_srcpos]!=0x0D && g_source[g_srcpos]!=0x0A){ |
167 | 169 | err=statement(); |
@@ -213,6 +213,7 @@ extern int g_var_mem[ALLOC_BLOCK_NUM]; | ||
213 | 213 | extern unsigned short g_var_pointer[ALLOC_BLOCK_NUM]; |
214 | 214 | extern unsigned short g_var_size[ALLOC_BLOCK_NUM]; |
215 | 215 | extern char g_temp_area_used; |
216 | +extern char g_nolinenum; | |
216 | 217 | extern int* g_heap_mem; |
217 | 218 | extern int g_max_mem; |
218 | 219 | extern char g_disable_break; |
@@ -228,13 +228,13 @@ static const char initext[]= | ||
228 | 228 | "#PRINT\n"; |
229 | 229 | |
230 | 230 | static const char bastext[]= |
231 | -"print getdir$()\n" | |
232 | -"end\n" | |
233 | -"\n" | |
234 | -"\n" | |
235 | -"\n" | |
231 | +"REM 1\n" | |
232 | +"REM 2\n" | |
233 | +"REM 3\n" | |
236 | 234 | "\n" |
235 | +"CLS\n" | |
237 | 236 | "\n" |
237 | +"LABEL TST:PRINT\n" | |
238 | 238 | "\n"; |
239 | 239 | |
240 | 240 | static const char class1text[]= |
@@ -122,7 +122,10 @@ int compile_and_link_file(char* buff,char* appname){ | ||
122 | 122 | printchar('\n'); |
123 | 123 | return -1; |
124 | 124 | } |
125 | - | |
125 | + | |
126 | + // Option initialization(s) | |
127 | + g_nolinenum=0; | |
128 | + | |
126 | 129 | // Compile the file |
127 | 130 | err=compile_file(); |
128 | 131 | close_file(); |
@@ -55,6 +55,9 @@ unsigned short g_var_size[ALLOC_BLOCK_NUM]; | ||
55 | 55 | // Flag to use temporary area when compiling |
56 | 56 | char g_temp_area_used; |
57 | 57 | |
58 | +// Flag to use option nolinenum | |
59 | +char g_nolinenum; | |
60 | + | |
58 | 61 | // Heap area |
59 | 62 | int* g_heap_mem; |
60 | 63 | int g_max_mem; |
@@ -1550,6 +1550,24 @@ char* setdir_statement(){ | ||
1550 | 1550 | return 0; |
1551 | 1551 | } |
1552 | 1552 | |
1553 | +char* option_statement(){ | |
1554 | + while(1){ | |
1555 | + next_position(); | |
1556 | + if (nextCodeIs("NOLINENUM")) { | |
1557 | + g_nolinenum=1; | |
1558 | + } else { | |
1559 | + return ERR_SYNTAX; | |
1560 | + } | |
1561 | + next_position(); | |
1562 | + if (g_source[g_srcpos]==',') { | |
1563 | + g_srcpos++; | |
1564 | + } else { | |
1565 | + break; | |
1566 | + } | |
1567 | + } | |
1568 | + return 0; | |
1569 | +} | |
1570 | + | |
1553 | 1571 | #ifdef __DEBUG |
1554 | 1572 | char* debug_statement(){ |
1555 | 1573 | call_lib_code(LIB_DEBUG); |
@@ -1698,6 +1716,7 @@ static const void* statement_list[]={ | ||
1698 | 1716 | "CALL ",call_statement, |
1699 | 1717 | "STATIC ",static_statement, |
1700 | 1718 | "SETDIR ",setdir_statement, |
1719 | + "OPTION ",option_statement, | |
1701 | 1720 | // List of additional statements follows |
1702 | 1721 | ADDITIONAL_STATEMENTS |
1703 | 1722 | }; |
@@ -91,6 +91,7 @@ static const int reserved_var_names[]={ | ||
91 | 91 | 0x000b4321, /*NEXT*/ |
92 | 92 | 0x000148f8, /*NEW*/ |
93 | 93 | 0x00014a5d, /*NOT*/ |
94 | + 0x38a658d7, /*OPTION*/ | |
94 | 95 | 0x000152c0, /*PCG*/ |
95 | 96 | 0x000cacec, /*PEEK*/ |
96 | 97 | 0x3b1c6aea, /*PEEK16*/ |