1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | #include <Compiler.h>
|
---|
4 |
|
---|
5 | #include "../BasicCompiler_Common/common.h"
|
---|
6 |
|
---|
7 | void ChangeReturnCode(char *buffer)
|
---|
8 | {
|
---|
9 | bool isMustChange = false;
|
---|
10 | for( int i=0; ; i++ ){
|
---|
11 | if( buffer[i] == '\0' ){
|
---|
12 | break;
|
---|
13 | }
|
---|
14 | if( buffer[i]=='\n' )
|
---|
15 | {
|
---|
16 | if( i>0 )
|
---|
17 | {
|
---|
18 | if( buffer[i-1] == '\r' )
|
---|
19 | {
|
---|
20 | isMustChange = true;
|
---|
21 | }
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | if( !isMustChange )
|
---|
27 | {
|
---|
28 | // 改行コードの変換は必要ない
|
---|
29 | return;
|
---|
30 | }
|
---|
31 |
|
---|
32 | #ifdef _DEBUG
|
---|
33 | //改行コードの整合性チェック
|
---|
34 | for( int i=0; ; i++ ){
|
---|
35 | if( buffer[i] == '\0' ){
|
---|
36 | break;
|
---|
37 | }
|
---|
38 | if( buffer[i]!='\r' && buffer[i+1]=='\n'
|
---|
39 | || buffer[i]=='\r' && buffer[i+1]!='\n' ){
|
---|
40 | char temporary[255];
|
---|
41 | strncpy( temporary, buffer + i-100, 130 );
|
---|
42 | temporary[130] = 0;
|
---|
43 | for(int i2=0; ;i2++){
|
---|
44 | if(temporary[i2]=='\r') temporary[i2]='A';
|
---|
45 | if(temporary[i2]=='\n') temporary[i2]='B';
|
---|
46 | if(temporary[i2]=='\0') break;
|
---|
47 | }
|
---|
48 | MessageBox( hOwnerEditor, temporary, "改行コードの整合性チェック", MB_OK | MB_ICONEXCLAMATION );
|
---|
49 | }
|
---|
50 | }
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | ChangeReturnCodeImpl(buffer);
|
---|
54 | }
|
---|
55 | void DeleteComment(char *buffer){ //注釈「'」の取り除き
|
---|
56 | int i,i2,i3,IsStr;
|
---|
57 | char *temporary=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,lstrlen(buffer)+1);
|
---|
58 | for(i=0,i2=0,i3=0,IsStr=0;;i++,i2++){
|
---|
59 | if(buffer[i]=='\"') IsStr^=1;
|
---|
60 | if(buffer[i]=='\n'||buffer[i]=='\0'){
|
---|
61 | if(i2 > 0){
|
---|
62 | i2--;
|
---|
63 | while(temporary[i2]==' '||temporary[i2]=='\t') i2--;
|
---|
64 | i2++;
|
---|
65 | }
|
---|
66 |
|
---|
67 | if(i3){
|
---|
68 | //複数行に渡る注釈文の中に改行が存在するとき
|
---|
69 | memset(temporary+i2,'\n',i3);
|
---|
70 | i2+=i3;
|
---|
71 | i3=0;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | if(buffer[i]=='\''&&IsStr==0){
|
---|
75 | //注釈文
|
---|
76 | i2--;
|
---|
77 | while(temporary[i2]==' '||temporary[i2]=='\t') i2--;
|
---|
78 | i2++;
|
---|
79 | while(buffer[i]!='\n'&&buffer[i]!='\0') i++;
|
---|
80 | }
|
---|
81 | if(buffer[i]=='/'&&buffer[i+1]=='*'&&IsStr==0){
|
---|
82 | //注釈文(複数行)
|
---|
83 | i+=2;
|
---|
84 | i3=0;
|
---|
85 | while(!(buffer[i]=='*'&&buffer[i+1]=='/')){
|
---|
86 | if(buffer[i]=='\n') i3++;
|
---|
87 | if(buffer[i]=='\0') break;
|
---|
88 | i++;
|
---|
89 | }
|
---|
90 | if(buffer[i]){
|
---|
91 | i+=2;
|
---|
92 | }
|
---|
93 | i--;
|
---|
94 | i2--;
|
---|
95 | continue;
|
---|
96 | }
|
---|
97 | temporary[i2]=buffer[i];
|
---|
98 | if(buffer[i]=='\0') break;
|
---|
99 | }
|
---|
100 | lstrcpy(buffer,temporary);
|
---|
101 | HeapDefaultFree(temporary);
|
---|
102 | }
|
---|
103 | void CheckParenthesis(char *buffer){
|
---|
104 | int i,IsStr,PareNum,sw;
|
---|
105 | _int8 bracket[1024];
|
---|
106 |
|
---|
107 | for(i=0,IsStr=0,PareNum=0,sw=0;;i++){
|
---|
108 | if(buffer[i]=='\"'){
|
---|
109 | IsStr^=1;
|
---|
110 | continue;
|
---|
111 | }
|
---|
112 |
|
---|
113 | else if(buffer[i]=='('&&IsStr==0){
|
---|
114 | bracket[PareNum]=0;
|
---|
115 | PareNum++;
|
---|
116 | }
|
---|
117 | else if(buffer[i]=='['&&IsStr==0){
|
---|
118 | bracket[PareNum]=1;
|
---|
119 | PareNum++;
|
---|
120 | }
|
---|
121 |
|
---|
122 | else if(buffer[i]==')'&&IsStr==0){
|
---|
123 | PareNum--;
|
---|
124 | if(bracket[PareNum]!=0||PareNum<0){
|
---|
125 | //"カッコ \'( )\'"
|
---|
126 | compiler.errorMessenger.Output(4,STRING_PARENTHESIS,i);
|
---|
127 | return;
|
---|
128 | }
|
---|
129 | }
|
---|
130 | else if(buffer[i]==']'&&IsStr==0){
|
---|
131 | PareNum--;
|
---|
132 | if(bracket[PareNum]!=1||PareNum<0){
|
---|
133 | //"カッコ \'( )\'"
|
---|
134 | compiler.errorMessenger.Output(4,STRING_PARENTHESIS,i);
|
---|
135 | return;
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | else if(buffer[i]=='\n'||buffer[i]=='\0'){
|
---|
140 |
|
---|
141 | //"カッコ \'( )\'"
|
---|
142 | if(PareNum!=0) compiler.errorMessenger.Output(4,STRING_PARENTHESIS,i);
|
---|
143 |
|
---|
144 | if(IsStr!=0) compiler.errorMessenger.Output(5,NULL,i);
|
---|
145 | if(buffer[i]=='\0') break;
|
---|
146 | PareNum=0;
|
---|
147 | IsStr=0;
|
---|
148 |
|
---|
149 | sw=0;
|
---|
150 | }
|
---|
151 |
|
---|
152 | else if((IsDBCSLeadByte(buffer[i])||buffer[i]==1)&&IsStr==0){
|
---|
153 | //不正な文字コード
|
---|
154 | if(sw==0){
|
---|
155 | //全角スペース
|
---|
156 | if(buffer[i]==(char)0x81&&buffer[i+1]==(char)0x40)
|
---|
157 | compiler.errorMessenger.Output(20,NULL,i);
|
---|
158 |
|
---|
159 | //その他の全角文字
|
---|
160 | else compiler.errorMessenger.Output(8,NULL,i);
|
---|
161 | sw=1;
|
---|
162 | }
|
---|
163 | }
|
---|
164 | }
|
---|
165 | }
|
---|
166 | BOOL CheckParenthesis2(char *buffer){
|
---|
167 | int i,IsStr,PareNum,sw;
|
---|
168 | _int8 bracket[1024];
|
---|
169 |
|
---|
170 | for(i=0,IsStr=0,PareNum=0,sw=0;;i++){
|
---|
171 | if(buffer[i]=='\"'){
|
---|
172 | IsStr^=1;
|
---|
173 | continue;
|
---|
174 | }
|
---|
175 |
|
---|
176 | else if(buffer[i]=='('&&IsStr==0){
|
---|
177 | bracket[PareNum]=0;
|
---|
178 | PareNum++;
|
---|
179 | }
|
---|
180 | else if(buffer[i]=='['&&IsStr==0){
|
---|
181 | bracket[PareNum]=1;
|
---|
182 | PareNum++;
|
---|
183 | }
|
---|
184 |
|
---|
185 | else if(buffer[i]==')'&&IsStr==0){
|
---|
186 | PareNum--;
|
---|
187 | if(bracket[PareNum]!=0||PareNum<0){
|
---|
188 | //"カッコ \'( )\'"
|
---|
189 | return 0;
|
---|
190 | }
|
---|
191 | }
|
---|
192 | else if(buffer[i]==']'&&IsStr==0){
|
---|
193 | PareNum--;
|
---|
194 | if(bracket[PareNum]!=1||PareNum<0){
|
---|
195 | //"カッコ \'( )\'"
|
---|
196 | return 0;
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | else if(buffer[i]=='\n'||buffer[i]=='\0'){
|
---|
201 |
|
---|
202 | //"カッコ \'( )\'"
|
---|
203 | if(PareNum!=0){
|
---|
204 | return 0;
|
---|
205 | }
|
---|
206 |
|
---|
207 | if(IsStr!=0){
|
---|
208 | return 0;
|
---|
209 | }
|
---|
210 | if(buffer[i]=='\0') break;
|
---|
211 | PareNum=0;
|
---|
212 | IsStr=0;
|
---|
213 |
|
---|
214 | sw=0;
|
---|
215 | }
|
---|
216 |
|
---|
217 | else if((IsDBCSLeadByte(buffer[i])||buffer[i]==1)&&IsStr==0){
|
---|
218 | //不正な文字コード
|
---|
219 | if(sw==0){
|
---|
220 | //全角スペース
|
---|
221 | if(buffer[i]==(char)0x81&&buffer[i+1]==(char)0x40){
|
---|
222 | return 0;
|
---|
223 | }
|
---|
224 |
|
---|
225 | //その他の全角文字
|
---|
226 | else return 0;
|
---|
227 | sw=1;
|
---|
228 | }
|
---|
229 | }
|
---|
230 | }
|
---|
231 | return 1;
|
---|
232 | }
|
---|
233 |
|
---|
234 | inline int FindLineEnd(char const *basbuf, int i2){
|
---|
235 | for(;;i2++){
|
---|
236 | if(basbuf[i2]=='\n'||basbuf[i2]=='\0') break;
|
---|
237 | }
|
---|
238 | return i2;
|
---|
239 | }
|
---|
240 |
|
---|
241 | void DirectiveCheck(void){
|
---|
242 | extern char *basbuf;
|
---|
243 | extern char BasicCurDir[MAX_PATH];
|
---|
244 | int i,i2,i3;
|
---|
245 | char temporary[VN_SIZE];
|
---|
246 |
|
---|
247 | for(i=0;;i++){
|
---|
248 | if(basbuf[i]=='\0') break;
|
---|
249 | if(((basbuf[i-2]==0&&basbuf[i-1]==-1)||basbuf[i-1]=='\n')&&
|
---|
250 | basbuf[i]=='#'){
|
---|
251 | for(i2=i+1,i3=0;;i2++,i3++){
|
---|
252 | if(!IsVariableChar(basbuf[i2])){
|
---|
253 | temporary[i3]=0;
|
---|
254 | break;
|
---|
255 | }
|
---|
256 | temporary[i3]=basbuf[i2];
|
---|
257 | }
|
---|
258 | if( lstrcmp( temporary, "static_link" ) == 0 )
|
---|
259 | {
|
---|
260 | // 静的リンクライブラリ
|
---|
261 | while(basbuf[i2]==' '||basbuf[i2]=='\t') i2++;
|
---|
262 | if(basbuf[i2]!='\"'){
|
---|
263 | compiler.errorMessenger.Output(1,NULL,i2);
|
---|
264 | return;
|
---|
265 | }
|
---|
266 | for(i3=0,i2++;;i2++,i3++){
|
---|
267 | if(basbuf[i2]=='\"'){
|
---|
268 | temporary[i3]=0;
|
---|
269 | break;
|
---|
270 | }
|
---|
271 | temporary[i3]=basbuf[i2];
|
---|
272 | }
|
---|
273 | GetFullPath(temporary,BasicCurDir);
|
---|
274 |
|
---|
275 | compiler.staticLibraryFilePaths.push_back( temporary );
|
---|
276 |
|
---|
277 | i2 = FindLineEnd(basbuf, i2);
|
---|
278 | SlideString(basbuf+i2,i-i2);
|
---|
279 | }
|
---|
280 | else if( lstrcmpi( temporary, "_core" ) == 0 )
|
---|
281 | {
|
---|
282 | // #_core
|
---|
283 | // コアモジュール
|
---|
284 | compiler.SetCoreMark( true );
|
---|
285 |
|
---|
286 | i2 = FindLineEnd(basbuf, i2);
|
---|
287 | SlideString(basbuf+i2,i-i2);
|
---|
288 | }
|
---|
289 | else if(lstrcmpi(temporary,"noprompt")==0){
|
---|
290 | //#noprompt
|
---|
291 | //旧機能なので、無視
|
---|
292 | i2 = FindLineEnd(basbuf, i2);
|
---|
293 | SlideString(basbuf+i2,i-i2);
|
---|
294 | }
|
---|
295 | else if(lstrcmpi(temporary,"strict")==0){
|
---|
296 | //#strict
|
---|
297 | //旧機能なので、無視
|
---|
298 | i2 = FindLineEnd(basbuf, i2);
|
---|
299 | SlideString(basbuf+i2,i-i2);
|
---|
300 | }
|
---|
301 | else if(lstrcmpi(temporary,"struct")==0){
|
---|
302 | //#struct code
|
---|
303 | //旧機能なので、無視
|
---|
304 | i2 = FindLineEnd(basbuf, i2);
|
---|
305 | SlideString(basbuf+i2,i-i2);
|
---|
306 | }
|
---|
307 | else if(lstrcmpi(temporary,"resource")==0){
|
---|
308 | //#resource
|
---|
309 | while(basbuf[i2]==' '||basbuf[i2]=='\t') i2++;
|
---|
310 | if(basbuf[i2]!='\"'){
|
---|
311 | compiler.errorMessenger.Output(1,NULL,i2);
|
---|
312 | return;
|
---|
313 | }
|
---|
314 | for(i3=0,i2++;;i2++,i3++){
|
---|
315 | if(basbuf[i2]=='\"'){
|
---|
316 | temporary[i3]=0;
|
---|
317 | break;
|
---|
318 | }
|
---|
319 | temporary[i3]=basbuf[i2];
|
---|
320 | }
|
---|
321 | GetFullPath(temporary,BasicCurDir);
|
---|
322 |
|
---|
323 | extern char ResourceFileName[MAX_PATH];
|
---|
324 | lstrcpy(ResourceFileName,temporary);
|
---|
325 |
|
---|
326 | i2 = FindLineEnd(basbuf, i2);
|
---|
327 | SlideString(basbuf+i2,i-i2);
|
---|
328 | }
|
---|
329 | }
|
---|
330 | }
|
---|
331 | }
|
---|
332 | void NextCommandFormat(char *buffer){
|
---|
333 | int i,i2,i3;
|
---|
334 | char temporary[255];
|
---|
335 |
|
---|
336 | //Next命令語のフォーマット
|
---|
337 | for(i=0;;i++){
|
---|
338 | if(buffer[i]=='\n'||buffer[i]==':'||i==0){
|
---|
339 | if(buffer[i]=='\n'||buffer[i]==':') i++;
|
---|
340 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
341 | while(buffer[i]>='0'&&buffer[i]<='9') i++;
|
---|
342 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
343 | if((buffer[i]=='n'||buffer[i]=='N')&&(buffer[i+1]=='e'||buffer[i+1]=='E')&&(buffer[i+2]=='x'||buffer[i+2]=='X')&&(buffer[i+3]=='t'||buffer[i+3]=='T')&&
|
---|
344 | (buffer[i+4]==' '||buffer[i+4]=='\t')){
|
---|
345 | i2=i+5;
|
---|
346 | while(buffer[i2]==' '||buffer[i2]=='\t') i2++;
|
---|
347 | if(buffer[i2]!='\n'){
|
---|
348 | lstrcpy(temporary,"NEXT");
|
---|
349 | for(i3=0;;i2++){
|
---|
350 | if(buffer[i2]=='\n'||buffer[i2]==':'||buffer[i2]=='\0') break;
|
---|
351 | if(buffer[i2]==','){
|
---|
352 | lstrcat(temporary,":NEXT");
|
---|
353 | i3=1;
|
---|
354 | }
|
---|
355 | }
|
---|
356 | if(i3){
|
---|
357 | i3=lstrlen(temporary);
|
---|
358 | SlideString(buffer+i2,i-i2+i3);
|
---|
359 | memcpy(buffer+i,temporary,i3);
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 | }
|
---|
364 | if(buffer[i]=='\0') break;
|
---|
365 | }
|
---|
366 | }
|
---|
367 | void SetEscapeSequenceFormat(char *buffer){
|
---|
368 | /*「MOD」「AND」「OR」
|
---|
369 | その他制御文字をエスケープシーケンスを使用した記号へ変換 */
|
---|
370 | int i,i2,i3,i4,i5,i6,sw1,IsStr;
|
---|
371 | char *temporary,temp2[VN_SIZE];
|
---|
372 |
|
---|
373 | bool isBeforeCharDelimitation = true;
|
---|
374 | temporary=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,(lstrlen(buffer)+255)*2);
|
---|
375 | for(i=0,i2=0,IsStr=0;;i++,i2++){
|
---|
376 | if(buffer[i]=='\"') IsStr^=1;
|
---|
377 | if(buffer[i]=='-'&&buffer[i+1]=='>'&&IsStr==0){
|
---|
378 | buffer[i]=1;
|
---|
379 | buffer[i+1]=ESC_PSMEM;
|
---|
380 | }
|
---|
381 |
|
---|
382 | if( buffer[i] && IsCommandDelimitation( buffer[i] ) ){
|
---|
383 | isBeforeCharDelimitation = true;
|
---|
384 |
|
---|
385 | temporary[i2]=buffer[i];
|
---|
386 | continue;
|
---|
387 | }
|
---|
388 |
|
---|
389 | if(IsVariableChar(buffer[i])&&IsStr==0){
|
---|
390 |
|
---|
391 | i3=i2;
|
---|
392 | for(;;i++,i2++){
|
---|
393 | if(!IsVariableChar(buffer[i])){
|
---|
394 | temporary[i2]=0;
|
---|
395 | break;
|
---|
396 | }
|
---|
397 | temporary[i2]=buffer[i];
|
---|
398 | }
|
---|
399 |
|
---|
400 | bool isAfterCharBlank = false;
|
---|
401 | if( IsBlank( buffer[i] ) ){
|
---|
402 | isAfterCharBlank = true;
|
---|
403 | }
|
---|
404 |
|
---|
405 | if(lstrcmpi(temporary+i3,"End")==0) i6=1;
|
---|
406 | else if(lstrcmpi(temporary+i3,"Exit")==0) i6=2;
|
---|
407 | else if(lstrcmpi(temporary+i3,"Select")==0) i6=3;
|
---|
408 | else if(lstrcmpi(temporary+i3,"Case")==0) i6=4;
|
---|
409 | else if(lstrcmpi(temporary+i3,"Else")==0) i6=5;
|
---|
410 | else i6=0;
|
---|
411 | if(i6){
|
---|
412 | i4=i;
|
---|
413 | while(buffer[i4]==' '||buffer[i4]=='\t') i4++;
|
---|
414 | for(i5=0;;i4++,i5++){
|
---|
415 | if(!IsVariableChar(buffer[i4])){
|
---|
416 | temp2[i5]=0;
|
---|
417 | break;
|
---|
418 | }
|
---|
419 | temp2[i5]=buffer[i4];
|
---|
420 | }
|
---|
421 | sw1=0;
|
---|
422 | if(i6==3){
|
---|
423 | //Select~
|
---|
424 | if(lstrcmpi(temp2,"Case")==0) sw1=1;
|
---|
425 | }
|
---|
426 | else if(i6==4){
|
---|
427 | //Case~
|
---|
428 | if(lstrcmpi(temp2,"Else")==0) sw1=1;
|
---|
429 | }
|
---|
430 | else if(i6==5){
|
---|
431 | //Else If
|
---|
432 | if(lstrcmpi(temp2,"If")==0) sw1=1;
|
---|
433 | }
|
---|
434 | else if(i6==1){
|
---|
435 | //End~
|
---|
436 | switch(temp2[0]){
|
---|
437 | case 'c':
|
---|
438 | case 'C':
|
---|
439 | if(lstrcmpi(temp2,"Class")==0) sw1=1;
|
---|
440 | break;
|
---|
441 | case 'e':
|
---|
442 | case 'E':
|
---|
443 | if(lstrcmpi(temp2,"Enum")==0) sw1=1;
|
---|
444 | break;
|
---|
445 | case 'i':
|
---|
446 | case 'I':
|
---|
447 | if(lstrcmpi(temp2,"If")==0) sw1=1;
|
---|
448 | else if(lstrcmpi(temp2,"Interface")==0) sw1=1;
|
---|
449 | break;
|
---|
450 | case 'f':
|
---|
451 | case 'F':
|
---|
452 | if(lstrcmpi(temp2,"Function")==0) sw1=1;
|
---|
453 | break;
|
---|
454 | case 'm':
|
---|
455 | case 'M':
|
---|
456 | if(lstrcmpi(temp2,"Macro")==0) sw1=1;
|
---|
457 | break;
|
---|
458 | case 'n':
|
---|
459 | case 'N':
|
---|
460 | if(lstrcmpi(temp2,"Namespace")==0) sw1=1;
|
---|
461 | break;
|
---|
462 | case 's':
|
---|
463 | case 'S':
|
---|
464 | if(lstrcmpi(temp2,"Sub")==0) sw1=1;
|
---|
465 | else if(lstrcmpi(temp2,"Select")==0) sw1=1;
|
---|
466 | break;
|
---|
467 | case 't':
|
---|
468 | case 'T':
|
---|
469 | if(lstrcmpi(temp2,"Try")==0) sw1=1;
|
---|
470 | else if(lstrcmpi(temp2,"Type")==0) sw1=1;
|
---|
471 | break;
|
---|
472 | case 'w':
|
---|
473 | case 'W':
|
---|
474 | if(lstrcmpi(temp2,"With")==0) sw1=1;
|
---|
475 | break;
|
---|
476 | }
|
---|
477 | }
|
---|
478 | else if(i6==2){
|
---|
479 | //Exit~
|
---|
480 | if(
|
---|
481 | lstrcmpi(temp2,"For")==0||
|
---|
482 | lstrcmpi(temp2,"While")==0||
|
---|
483 | lstrcmpi(temp2,"Do")==0||
|
---|
484 | lstrcmpi(temp2,"Function")==0||
|
---|
485 | lstrcmpi(temp2,"Sub")==0||
|
---|
486 | lstrcmpi(temp2,"Macro")==0
|
---|
487 | ) sw1=1;
|
---|
488 | }
|
---|
489 |
|
---|
490 | if(sw1){
|
---|
491 | i=i4;
|
---|
492 | memcpy(temporary+i2,temp2,i5);
|
---|
493 | i2+=i5;
|
---|
494 | temporary[i2]=0;
|
---|
495 | }
|
---|
496 | }
|
---|
497 | i--;
|
---|
498 | i2--;
|
---|
499 |
|
---|
500 | switch(temporary[i3]){
|
---|
501 | case '_':
|
---|
502 | if(lstrcmpi(temporary+i3,"_ClearNamespaceImported")==0){
|
---|
503 | i2=i3;
|
---|
504 | temporary[i2++]=1;
|
---|
505 | temporary[i2]=ESC_CLEARNAMESPACEIMPORTED;
|
---|
506 | }
|
---|
507 | if(lstrcmpi(temporary+i3,"_System_Static_New")==0){
|
---|
508 | i2=i3;
|
---|
509 | temporary[i2++]=1;
|
---|
510 | temporary[i2]=ESC_SYSTEM_STATIC_NEW;
|
---|
511 | }
|
---|
512 | break;
|
---|
513 | case 'a':
|
---|
514 | case 'A':
|
---|
515 | if(lstrcmpi(temporary+i3,"And")==0){
|
---|
516 | i2=i3;
|
---|
517 | temporary[i2++]=1;
|
---|
518 | temporary[i2]=ESC_AND;
|
---|
519 | }
|
---|
520 | else if(lstrcmpi(temporary+i3,"Abstract")==0){
|
---|
521 | i2=i3;
|
---|
522 | temporary[i2++]=1;
|
---|
523 | temporary[i2]=ESC_ABSTRACT;
|
---|
524 | }
|
---|
525 | else if(lstrcmpi(temporary+i3,"As")==0){
|
---|
526 | i2=i3;
|
---|
527 | temporary[i2++]=1;
|
---|
528 | temporary[i2]=ESC_AS;
|
---|
529 | }
|
---|
530 | break;
|
---|
531 | case 'b':
|
---|
532 | case 'B':
|
---|
533 | if(lstrcmpi(temporary+i3,"ByVal")==0){
|
---|
534 | i2=i3;
|
---|
535 | temporary[i2++]=1;
|
---|
536 | temporary[i2]=ESC_BYVAL;
|
---|
537 | }
|
---|
538 | else if(lstrcmpi(temporary+i3,"ByRef")==0){
|
---|
539 | i2=i3;
|
---|
540 | temporary[i2++]=1;
|
---|
541 | temporary[i2]=ESC_BYREF;
|
---|
542 | }
|
---|
543 | break;
|
---|
544 | case 'c':
|
---|
545 | case 'C':
|
---|
546 | if(lstrcmpi(temporary+i3,"Catch")==0){
|
---|
547 | i2=i3;
|
---|
548 | temporary[i2++]=1;
|
---|
549 | temporary[i2]=ESC_CATCH;
|
---|
550 | }
|
---|
551 | else if(lstrcmpi(temporary+i3,"Continue")==0){
|
---|
552 | i2=i3;
|
---|
553 | temporary[i2++]=1;
|
---|
554 | temporary[i2]=ESC_CONTINUE;
|
---|
555 | }
|
---|
556 | else if(lstrcmpi(temporary+i3,"cdecl")==0){
|
---|
557 | i2=i3;
|
---|
558 | temporary[i2++]=1;
|
---|
559 | temporary[i2]=ESC_CDECL;
|
---|
560 | }
|
---|
561 | else if(lstrcmpi(temporary+i3,"Case")==0){
|
---|
562 | i2=i3;
|
---|
563 | temporary[i2++]=1;
|
---|
564 | temporary[i2]=ESC_CASE;
|
---|
565 | }
|
---|
566 | else if(lstrcmpi(temporary+i3,"CaseElse")==0){
|
---|
567 | i2=i3;
|
---|
568 | temporary[i2++]=1;
|
---|
569 | temporary[i2]=ESC_CASEELSE;
|
---|
570 | }
|
---|
571 | else if(lstrcmpi(temporary+i3,"Const")==0){
|
---|
572 | i2=i3;
|
---|
573 | temporary[i2++]=1;
|
---|
574 | temporary[i2]=ESC_CONST;
|
---|
575 | }
|
---|
576 | else if(lstrcmpi(temporary+i3,"Class")==0){
|
---|
577 | i2=i3;
|
---|
578 | temporary[i2++]=1;
|
---|
579 | temporary[i2]=ESC_CLASS;
|
---|
580 | }
|
---|
581 | break;
|
---|
582 | case 'd':
|
---|
583 | case 'D':
|
---|
584 | if(lstrcmpi(temporary+i3,"Declare")==0){
|
---|
585 | i2=i3;
|
---|
586 | int i9=i2;
|
---|
587 | temporary[i2]=1;
|
---|
588 | temporary[++i2]=ESC_DECLARE;
|
---|
589 | i++;
|
---|
590 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
591 |
|
---|
592 | // Sub/Function
|
---|
593 | for(i4=0;;i++,i4++){
|
---|
594 | if(!IsVariableChar(buffer[i])){
|
---|
595 | temp2[i4]=0;
|
---|
596 | break;
|
---|
597 | }
|
---|
598 | temp2[i4]=buffer[i];
|
---|
599 | }
|
---|
600 | if(lstrcmpi(temp2,"Sub")==0) temporary[++i2]=ESC_SUB;
|
---|
601 | else if(lstrcmpi(temp2,"Function")==0) temporary[++i2]=ESC_FUNCTION;
|
---|
602 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
603 |
|
---|
604 | // 関数名
|
---|
605 | for(i2++;;i++,i2++){
|
---|
606 | if(!IsVariableChar(buffer[i])){
|
---|
607 | i2--;
|
---|
608 | break;
|
---|
609 | }
|
---|
610 | temporary[i2]=buffer[i];
|
---|
611 | }
|
---|
612 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
613 |
|
---|
614 | for(i4=0;;i++,i4++){
|
---|
615 | if(!IsVariableChar(buffer[i])){
|
---|
616 | temp2[i4]=0;
|
---|
617 | break;
|
---|
618 | }
|
---|
619 | temp2[i4]=buffer[i];
|
---|
620 | }
|
---|
621 | if(lstrcmpi(temp2,"cdecl")==0){
|
---|
622 | temporary[++i2]=1;
|
---|
623 | temporary[++i2]=ESC_CDECL;
|
---|
624 |
|
---|
625 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
626 | for(i4=0;;i++,i4++){
|
---|
627 | if(!IsVariableChar(buffer[i])){
|
---|
628 | temp2[i4]=0;
|
---|
629 | break;
|
---|
630 | }
|
---|
631 | temp2[i4]=buffer[i];
|
---|
632 | }
|
---|
633 | }
|
---|
634 | if(lstrcmpi(temp2,"Lib")==0) temporary[++i2]=',';
|
---|
635 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
636 |
|
---|
637 | if(buffer[i]=='\"'){
|
---|
638 | temporary[++i2]=buffer[i];
|
---|
639 | for(i++,i2++;;i++,i2++){
|
---|
640 | temporary[i2]=buffer[i];
|
---|
641 | if(buffer[i]=='\"'){
|
---|
642 | i++;
|
---|
643 | break;
|
---|
644 | }
|
---|
645 | if(buffer[i]=='\0') break;
|
---|
646 | }
|
---|
647 | }
|
---|
648 | else{
|
---|
649 | for(i2++;;i++,i2++){
|
---|
650 | if(!IsVariableChar(buffer[i])){
|
---|
651 | i2--;
|
---|
652 | break;
|
---|
653 | }
|
---|
654 | temporary[i2]=buffer[i];
|
---|
655 | }
|
---|
656 | }
|
---|
657 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
658 |
|
---|
659 | temporary[++i2]=',';
|
---|
660 |
|
---|
661 | if( memicmp( buffer + i, "Alias", 5 ) ==0 ){
|
---|
662 | i+=5;
|
---|
663 | for(i++,i2++;;i++,i2++){
|
---|
664 | temporary[i2]=buffer[i];
|
---|
665 | if(buffer[i]=='('){
|
---|
666 | i2--;
|
---|
667 | break;
|
---|
668 | }
|
---|
669 | if(buffer[i]=='\0') break;
|
---|
670 | }
|
---|
671 | }
|
---|
672 |
|
---|
673 | temporary[++i2]=',';
|
---|
674 |
|
---|
675 | i--;
|
---|
676 | }
|
---|
677 | else if(lstrcmpi(temporary+i3,"Def")==0){
|
---|
678 | i2=i3;
|
---|
679 | temporary[i2++]=1;
|
---|
680 | temporary[i2]=ESC_DEF;
|
---|
681 | }
|
---|
682 | else if( lstrcmpi(temporary+i3,"Delegate")==0 )
|
---|
683 | {
|
---|
684 | i2=i3;
|
---|
685 | temporary[i2++]=1;
|
---|
686 | temporary[i2]=ESC_DELEGATE;
|
---|
687 | }
|
---|
688 | break;
|
---|
689 | case 'e':
|
---|
690 | case 'E':
|
---|
691 | if(lstrcmpi(temporary+i3,"ElseIf")==0){
|
---|
692 | i2=i3;
|
---|
693 | temporary[i2++]=1;
|
---|
694 | temporary[i2]=ESC_ELSEIF;
|
---|
695 | }
|
---|
696 | else if(lstrcmpi(temporary+i3,"Else")==0){
|
---|
697 | i2=i3;
|
---|
698 | temporary[i2++]=1;
|
---|
699 | temporary[i2]=ESC_ELSE;
|
---|
700 | }
|
---|
701 | else if(lstrcmpi(temporary+i3,"Export")==0){
|
---|
702 | i2=i3;
|
---|
703 | temporary[i2++]=1;
|
---|
704 | temporary[i2]=ESC_EXPORT;
|
---|
705 | }
|
---|
706 | else if(lstrcmpi(temporary+i3,"Enum")==0){
|
---|
707 | i2=i3;
|
---|
708 | temporary[i2++]=1;
|
---|
709 | temporary[i2]=ESC_ENUM;
|
---|
710 | }
|
---|
711 |
|
---|
712 | else if(temporary[i3+1]=='n'||temporary[i3+1]=='N'){
|
---|
713 | //終了記述
|
---|
714 | if(lstrcmpi(temporary+i3,"EndIf")==0){
|
---|
715 | i2=i3;
|
---|
716 | temporary[i2++]=1;
|
---|
717 | temporary[i2]=ESC_ENDIF;
|
---|
718 | }
|
---|
719 | else if(lstrcmpi(temporary+i3,"EndFunction")==0){
|
---|
720 | i2=i3;
|
---|
721 | temporary[i2++]=1;
|
---|
722 | temporary[i2]=ESC_ENDFUNCTION;
|
---|
723 | }
|
---|
724 | else if(lstrcmpi(temporary+i3,"EndSub")==0){
|
---|
725 | i2=i3;
|
---|
726 | temporary[i2++]=1;
|
---|
727 | temporary[i2]=ESC_ENDSUB;
|
---|
728 | }
|
---|
729 | else if(lstrcmpi(temporary+i3,"EndMacro")==0){
|
---|
730 | i2=i3;
|
---|
731 | temporary[i2++]=1;
|
---|
732 | temporary[i2]=ESC_ENDMACRO;
|
---|
733 | }
|
---|
734 | else if(lstrcmpi(temporary+i3,"EndNamespace")==0){
|
---|
735 | i2=i3;
|
---|
736 | temporary[i2++]=1;
|
---|
737 | temporary[i2]=ESC_ENDNAMESPACE;
|
---|
738 | }
|
---|
739 | else if(lstrcmpi(temporary+i3,"EndClass")==0){
|
---|
740 | i2=i3;
|
---|
741 | temporary[i2++]=1;
|
---|
742 | temporary[i2]=ESC_ENDCLASS;
|
---|
743 | }
|
---|
744 | else if(lstrcmpi(temporary+i3,"EndInterface")==0){
|
---|
745 | i2=i3;
|
---|
746 | temporary[i2++]=1;
|
---|
747 | temporary[i2]=ESC_ENDINTERFACE;
|
---|
748 | }
|
---|
749 | else if(lstrcmpi(temporary+i3,"EndTry")==0){
|
---|
750 | i2=i3;
|
---|
751 | temporary[i2++]=1;
|
---|
752 | temporary[i2]=ESC_ENDTRY;
|
---|
753 | }
|
---|
754 | else if(lstrcmpi(temporary+i3,"EndType")==0){
|
---|
755 | i2=i3;
|
---|
756 | temporary[i2++]=1;
|
---|
757 | temporary[i2]=ESC_ENDTYPE;
|
---|
758 | }
|
---|
759 | else if(lstrcmpi(temporary+i3,"EndEnum")==0){
|
---|
760 | i2=i3;
|
---|
761 | temporary[i2++]=1;
|
---|
762 | temporary[i2]=ESC_ENDENUM;
|
---|
763 | }
|
---|
764 | else if(lstrcmpi(temporary+i3,"EndSelect")==0){
|
---|
765 | i2=i3;
|
---|
766 | temporary[i2++]=1;
|
---|
767 | temporary[i2]=ESC_ENDSELECT;
|
---|
768 | }
|
---|
769 | else if(lstrcmpi(temporary+i3,"EndWith")==0){
|
---|
770 | i2=i3;
|
---|
771 | temporary[i2++]=1;
|
---|
772 | temporary[i2]=ESC_ENDWITH;
|
---|
773 | }
|
---|
774 | }
|
---|
775 | else if(temporary[i3+1]=='x'||temporary[i3+1]=='X'){
|
---|
776 | if(lstrcmpi(temporary+i3,"ExitFor")==0){
|
---|
777 | i2=i3;
|
---|
778 | temporary[i2++]=1;
|
---|
779 | temporary[i2]=ESC_EXITFOR;
|
---|
780 | }
|
---|
781 | else if(lstrcmpi(temporary+i3,"ExitWhile")==0){
|
---|
782 | i2=i3;
|
---|
783 | temporary[i2++]=1;
|
---|
784 | temporary[i2]=ESC_EXITWHILE;
|
---|
785 | }
|
---|
786 | else if(lstrcmpi(temporary+i3,"ExitDo")==0){
|
---|
787 | i2=i3;
|
---|
788 | temporary[i2++]=1;
|
---|
789 | temporary[i2]=ESC_EXITDO;
|
---|
790 | }
|
---|
791 | else if(lstrcmpi(temporary+i3,"ExitFunction")==0){
|
---|
792 | i2=i3;
|
---|
793 | temporary[i2++]=1;
|
---|
794 | temporary[i2]=ESC_EXITFUNCTION;
|
---|
795 | }
|
---|
796 | else if(lstrcmpi(temporary+i3,"ExitSub")==0){
|
---|
797 | i2=i3;
|
---|
798 | temporary[i2++]=1;
|
---|
799 | temporary[i2]=ESC_EXITSUB;
|
---|
800 | }
|
---|
801 | else if(lstrcmpi(temporary+i3,"ExitMacro")==0){
|
---|
802 | i2=i3;
|
---|
803 | temporary[i2++]=1;
|
---|
804 | temporary[i2]=ESC_EXITMACRO;
|
---|
805 | }
|
---|
806 | }
|
---|
807 | break;
|
---|
808 | case 'f':
|
---|
809 | case 'F':
|
---|
810 | if(lstrcmpi(temporary+i3,"Finally")==0){
|
---|
811 | i2=i3;
|
---|
812 | temporary[i2++]=1;
|
---|
813 | temporary[i2]=ESC_FINALLY;
|
---|
814 | }
|
---|
815 | else if(lstrcmpi(temporary+i3,"Function")==0){
|
---|
816 | i2=i3;
|
---|
817 | temporary[i2++]=1;
|
---|
818 | temporary[i2]=ESC_FUNCTION;
|
---|
819 | }
|
---|
820 | break;
|
---|
821 | case 'i':
|
---|
822 | case 'I':
|
---|
823 | if(lstrcmpi(temporary+i3,"If")==0){
|
---|
824 | i2=i3;
|
---|
825 | temporary[i2++]=1;
|
---|
826 | temporary[i2]=ESC_IF;
|
---|
827 | }
|
---|
828 | else if(lstrcmpi(temporary+i3,"Imports")==0){
|
---|
829 | i2=i3;
|
---|
830 | temporary[i2++]=1;
|
---|
831 | temporary[i2]=ESC_IMPORTS;
|
---|
832 | }
|
---|
833 | else if(lstrcmpi(temporary+i3,"Inherits")==0){
|
---|
834 | i2=i3;
|
---|
835 | temporary[i2++]=1;
|
---|
836 | temporary[i2]=ESC_INHERITS;
|
---|
837 | }
|
---|
838 | else if( lstrcmpi( temporary + i3, "Implements" ) == 0 )
|
---|
839 | {
|
---|
840 | i2 = i3;
|
---|
841 | temporary[i2++] = 1;
|
---|
842 | temporary[i2] = ESC_IMPLEMENTS;
|
---|
843 | }
|
---|
844 | else if(lstrcmpi(temporary+i3,"Interface")==0){
|
---|
845 | i2=i3;
|
---|
846 | temporary[i2++]=1;
|
---|
847 | temporary[i2]=ESC_INTERFACE;
|
---|
848 | }
|
---|
849 | break;
|
---|
850 | case 'm':
|
---|
851 | case 'M':
|
---|
852 | if(lstrcmpi(temporary+i3,"Mod")==0){
|
---|
853 | i2=i3;
|
---|
854 | temporary[i2++]=1;
|
---|
855 | temporary[i2]=ESC_MOD;
|
---|
856 | }
|
---|
857 | else if(lstrcmpi(temporary+i3,"Macro")==0){
|
---|
858 | i2=i3;
|
---|
859 | temporary[i2++]=1;
|
---|
860 | temporary[i2]=ESC_MACRO;
|
---|
861 | }
|
---|
862 | break;
|
---|
863 | case 'n':
|
---|
864 | case 'N':
|
---|
865 | if(isBeforeCharDelimitation
|
---|
866 | && lstrcmpi(temporary+i3,"Namespace")==0
|
---|
867 | && isAfterCharBlank ){
|
---|
868 | i2=i3;
|
---|
869 | temporary[i2++]=1;
|
---|
870 | temporary[i2]=ESC_NAMESPACE;
|
---|
871 | }
|
---|
872 | else if(lstrcmpi(temporary+i3,"New")==0){
|
---|
873 | i2=i3;
|
---|
874 | temporary[i2++]=1;
|
---|
875 | temporary[i2]=ESC_NEW;
|
---|
876 | }
|
---|
877 | else if(lstrcmpi(temporary+i3,"Not")==0){
|
---|
878 | i2=i3;
|
---|
879 | temporary[i2++]=1;
|
---|
880 | temporary[i2]=ESC_NOT;
|
---|
881 | }
|
---|
882 | break;
|
---|
883 | case 'o':
|
---|
884 | case 'O':
|
---|
885 | if(lstrcmpi(temporary+i3,"Or")==0){
|
---|
886 | i2=i3;
|
---|
887 | temporary[i2++]=1;
|
---|
888 | temporary[i2]=ESC_OR;
|
---|
889 | }
|
---|
890 | else if(lstrcmpi(temporary+i3,"Override")==0){
|
---|
891 | i2=i3;
|
---|
892 | temporary[i2++]=1;
|
---|
893 | temporary[i2]=ESC_OVERRIDE;
|
---|
894 | }
|
---|
895 | else if(lstrcmpi(temporary+i3,"Operator")==0){
|
---|
896 | i2=i3;
|
---|
897 | temporary[i2++]=1;
|
---|
898 | temporary[i2]=ESC_OPERATOR;
|
---|
899 | }
|
---|
900 | break;
|
---|
901 | case 's':
|
---|
902 | case 'S':
|
---|
903 | if(lstrcmpi(temporary+i3,"Sub")==0){
|
---|
904 | i2=i3;
|
---|
905 | temporary[i2++]=1;
|
---|
906 | temporary[i2]=ESC_SUB;
|
---|
907 | }
|
---|
908 | else if(lstrcmpi(temporary+i3,"SelectCase")==0){
|
---|
909 | i2=i3;
|
---|
910 | temporary[i2++]=1;
|
---|
911 | temporary[i2]=ESC_SELECTCASE;
|
---|
912 | }
|
---|
913 | else if(lstrcmpi(temporary+i3,"Static")==0){
|
---|
914 | i2=i3;
|
---|
915 | temporary[i2++]=1;
|
---|
916 | temporary[i2]=ESC_STATIC;
|
---|
917 | }
|
---|
918 | break;
|
---|
919 | case 't':
|
---|
920 | case 'T':
|
---|
921 | if(lstrcmpi(temporary+i3,"Then")==0){
|
---|
922 | i2=i3;
|
---|
923 | temporary[i2++]=1;
|
---|
924 | temporary[i2]=ESC_THEN;
|
---|
925 | }
|
---|
926 | else if(lstrcmpi(temporary+i3,"Throw")==0){
|
---|
927 | i2=i3;
|
---|
928 | temporary[i2++]=1;
|
---|
929 | temporary[i2]=ESC_THROW;
|
---|
930 | }
|
---|
931 | else if(lstrcmpi(temporary+i3,"Try")==0){
|
---|
932 | i2=i3;
|
---|
933 | temporary[i2++]=1;
|
---|
934 | temporary[i2]=ESC_TRY;
|
---|
935 | }
|
---|
936 | else if(lstrcmpi(temporary+i3,"Type")==0){
|
---|
937 | i2=i3;
|
---|
938 | temporary[i2++]=1;
|
---|
939 | temporary[i2]=ESC_TYPE;
|
---|
940 | }
|
---|
941 | else if(lstrcmpi(temporary+i3,"TypeDef")==0){
|
---|
942 | i2=i3;
|
---|
943 | temporary[i2++]=1;
|
---|
944 | temporary[i2]=ESC_TYPEDEF;
|
---|
945 | }
|
---|
946 | break;
|
---|
947 | case 'u':
|
---|
948 | case 'U':
|
---|
949 | if(lstrcmpi(temporary+i3,"Using")==0){
|
---|
950 | i2=i3;
|
---|
951 | temporary[i2++]=1;
|
---|
952 | temporary[i2]=ESC_USING;
|
---|
953 | }
|
---|
954 | break;
|
---|
955 | case 'v':
|
---|
956 | case 'V':
|
---|
957 | if(lstrcmpi(temporary+i3,"Virtual")==0){
|
---|
958 | i2=i3;
|
---|
959 | temporary[i2++]=1;
|
---|
960 | temporary[i2]=ESC_VIRTUAL;
|
---|
961 | }
|
---|
962 | break;
|
---|
963 | case 'w':
|
---|
964 | case 'W':
|
---|
965 | if(lstrcmpi(temporary+i3,"With")==0){
|
---|
966 | i2=i3;
|
---|
967 | temporary[i2++]=1;
|
---|
968 | temporary[i2]=ESC_WITH;
|
---|
969 | }
|
---|
970 | break;
|
---|
971 | case 'x':
|
---|
972 | case 'X':
|
---|
973 | if(lstrcmpi(temporary+i3,"Xor")==0){
|
---|
974 | i2=i3;
|
---|
975 | temporary[i2++]=1;
|
---|
976 | temporary[i2]=ESC_XOR;
|
---|
977 | }
|
---|
978 | break;
|
---|
979 | }
|
---|
980 |
|
---|
981 | continue;
|
---|
982 | }
|
---|
983 |
|
---|
984 | if( !IsBlank( buffer[i] ) ){
|
---|
985 | isBeforeCharDelimitation = false;
|
---|
986 | }
|
---|
987 |
|
---|
988 | temporary[i2]=buffer[i];
|
---|
989 | if(buffer[i]=='\0') break;
|
---|
990 | }
|
---|
991 | lstrcpy(buffer,temporary);
|
---|
992 | HeapDefaultFree(temporary);
|
---|
993 | }
|
---|
994 | void DefCommandFormat(char *buffer){
|
---|
995 | int i,i2,PareNum;
|
---|
996 | char temporary[255];
|
---|
997 |
|
---|
998 | //Def命令語からFunction命令語へ
|
---|
999 | for(i=0;;i++){
|
---|
1000 | if(buffer[i]==1&&buffer[i+1]==ESC_DEF){
|
---|
1001 | buffer[i+1]=ESC_FUNCTION;
|
---|
1002 | i+=2;
|
---|
1003 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
1004 | for(i2=0;;i++,i2++){
|
---|
1005 | if(!IsVariableChar(buffer[i])){
|
---|
1006 | temporary[i2]=0;
|
---|
1007 | break;
|
---|
1008 | }
|
---|
1009 | temporary[i2]=buffer[i];
|
---|
1010 | }
|
---|
1011 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
1012 | if(buffer[i]!='('){
|
---|
1013 | compiler.errorMessenger.Output(1,NULL,i);
|
---|
1014 | return;
|
---|
1015 | }
|
---|
1016 | i++;
|
---|
1017 | while(1){
|
---|
1018 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
1019 | if(buffer[i]==')') break;
|
---|
1020 | SlideString(buffer+i,2);
|
---|
1021 | buffer[i]=1;
|
---|
1022 | buffer[i+1]=ESC_BYVAL;
|
---|
1023 | i+=2;
|
---|
1024 | PareNum=0;
|
---|
1025 | for(;;i++){
|
---|
1026 | if(buffer[i]=='(') PareNum++;
|
---|
1027 | if(buffer[i]==')'){
|
---|
1028 | PareNum--;
|
---|
1029 | if(PareNum<0) break;
|
---|
1030 | }
|
---|
1031 | if(buffer[i]==','&&PareNum==0) break;
|
---|
1032 | }
|
---|
1033 | if(buffer[i]==')') break;
|
---|
1034 | i++;
|
---|
1035 | }
|
---|
1036 | i++;
|
---|
1037 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
1038 | if(buffer[i]!='='){
|
---|
1039 | compiler.errorMessenger.Output(1,NULL,i);
|
---|
1040 | break;
|
---|
1041 | }
|
---|
1042 | i2=lstrlen(temporary);
|
---|
1043 | SlideString(buffer+i,i2+1);
|
---|
1044 | buffer[i]=':';
|
---|
1045 | i++;
|
---|
1046 | memcpy(buffer+i,temporary,i2);
|
---|
1047 | i+=i2;
|
---|
1048 | while(!IsCommandDelimitation(buffer[i])) i++;
|
---|
1049 | SlideString(buffer+i,3);
|
---|
1050 | buffer[i]=':';
|
---|
1051 | buffer[i+1]=1;
|
---|
1052 | buffer[i+2]=ESC_ENDFUNCTION;
|
---|
1053 | }
|
---|
1054 | if(buffer[i]=='\0') break;
|
---|
1055 | }
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | void ChangeOneIf(char *write,int &wp,char *read,int &rp){
|
---|
1059 | int IsStr,sw;
|
---|
1060 |
|
---|
1061 | //ブロック形式でないときはThenの後に区切り文字を入れる
|
---|
1062 | for(IsStr=0,sw=0;;wp++,rp++){
|
---|
1063 | if(read[rp]=='\"') IsStr^=1;
|
---|
1064 |
|
---|
1065 | write[wp]=read[rp];
|
---|
1066 |
|
---|
1067 | if(IsCommandDelimitation(read[rp])&&IsStr==0) return;
|
---|
1068 | if(read[rp]==1&&read[rp+1]==ESC_THEN&&
|
---|
1069 | (read[rp+2]==' '||read[rp+2]=='\t')){
|
---|
1070 | write[wp+1]=read[rp+1];
|
---|
1071 | write[wp+2]=':';
|
---|
1072 | rp+=3;
|
---|
1073 | wp+=3;
|
---|
1074 | while(read[rp]==' '||read[rp]=='\t') rp++;
|
---|
1075 | if((read[rp]>='0'&&read[rp]<='9')||read[rp]=='*'){
|
---|
1076 | memcpy(write+wp,"Goto ",5);
|
---|
1077 | wp+=5;
|
---|
1078 | }
|
---|
1079 | break;
|
---|
1080 | }
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | //Elseの後に区切り文字を入れる
|
---|
1084 | for(IsStr=0;;wp++,rp++){
|
---|
1085 | if(read[rp]=='\"') IsStr^=1;
|
---|
1086 |
|
---|
1087 | write[wp]=read[rp];
|
---|
1088 |
|
---|
1089 | if(read[rp]=='\n'||read[rp]=='\0') break;
|
---|
1090 | if(read[rp]==1&&read[rp+1]==ESC_IF){
|
---|
1091 | write[wp+1]=read[rp+1];
|
---|
1092 | wp+=2;
|
---|
1093 | rp+=2;
|
---|
1094 | ChangeOneIf(write,wp,read,rp);
|
---|
1095 | wp--;
|
---|
1096 | rp--;
|
---|
1097 | continue;
|
---|
1098 | }
|
---|
1099 | if(read[rp]==1&&read[rp+1]==ESC_ELSE){
|
---|
1100 | write[wp++]=':';
|
---|
1101 |
|
---|
1102 | write[wp]=read[rp];
|
---|
1103 | write[wp+1]=read[rp+1];
|
---|
1104 | wp+=2;
|
---|
1105 | rp+=2;
|
---|
1106 |
|
---|
1107 | write[wp++]=':';
|
---|
1108 |
|
---|
1109 | while(read[rp]==' '||read[rp]=='\t') rp++;
|
---|
1110 | if((read[rp]>='0'&&read[rp]<='9')||read[rp]=='*'){
|
---|
1111 | memcpy(write+wp,"Goto ",5);
|
---|
1112 | wp+=5;
|
---|
1113 | }
|
---|
1114 | break;
|
---|
1115 | }
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | //"End If" を付加
|
---|
1119 | for(;;rp++,wp++){
|
---|
1120 | if(read[rp]=='\n'||read[rp]=='\0') break;
|
---|
1121 |
|
---|
1122 | if(read[rp]==1&&read[rp+1]==ESC_IF){
|
---|
1123 | write[wp+1]=read[rp+1];
|
---|
1124 | wp+=2;
|
---|
1125 | rp+=2;
|
---|
1126 | ChangeOneIf(write,wp,read,rp);
|
---|
1127 | wp--;
|
---|
1128 | rp--;
|
---|
1129 | continue;
|
---|
1130 | }
|
---|
1131 | if(read[rp]==1&&read[rp+1]==ESC_ELSE) break;
|
---|
1132 |
|
---|
1133 | write[wp]=read[rp];
|
---|
1134 | }
|
---|
1135 | write[wp]=':';
|
---|
1136 | write[wp+1]=1;
|
---|
1137 | write[wp+2]=ESC_ENDIF;
|
---|
1138 | wp+=3;
|
---|
1139 | }
|
---|
1140 | void OutsideIfFormat(char *write,int &wp,char *read,int &rp){
|
---|
1141 | int ElseCount=1;
|
---|
1142 |
|
---|
1143 | for(;;rp++,wp++){
|
---|
1144 | if(read[rp]==1){
|
---|
1145 | if(read[rp+1]==ESC_IF){
|
---|
1146 | write[wp++]=read[rp++];
|
---|
1147 | write[wp++]=read[rp++];
|
---|
1148 | OutsideIfFormat(write,wp,read,rp);
|
---|
1149 | wp--,rp--;
|
---|
1150 | continue;
|
---|
1151 | }
|
---|
1152 | if(read[rp+1]==ESC_ENDIF){
|
---|
1153 | for(;ElseCount>0;wp+=3,ElseCount--){
|
---|
1154 | write[wp]=1;
|
---|
1155 | write[wp+1]=ESC_ENDIF;
|
---|
1156 | write[wp+2]=':';
|
---|
1157 | }
|
---|
1158 | rp+=2;
|
---|
1159 | break;
|
---|
1160 | }
|
---|
1161 | if(read[rp+1]==ESC_ELSEIF){
|
---|
1162 | write[wp]=1;
|
---|
1163 | write[wp+1]=ESC_ELSE;
|
---|
1164 | write[wp+2]=':';
|
---|
1165 |
|
---|
1166 | write[wp+3]=1;
|
---|
1167 | write[wp+4]=ESC_IF;
|
---|
1168 |
|
---|
1169 | wp+=4;
|
---|
1170 | rp++;
|
---|
1171 |
|
---|
1172 | ElseCount++;
|
---|
1173 | continue;
|
---|
1174 | }
|
---|
1175 | }
|
---|
1176 |
|
---|
1177 | write[wp]=read[rp];
|
---|
1178 | if(read[rp]=='\0') break;
|
---|
1179 | }
|
---|
1180 | }
|
---|
1181 | void IfCommandFormat(char *buffer){
|
---|
1182 | int i,i2;
|
---|
1183 |
|
---|
1184 | char *temporary;
|
---|
1185 | temporary=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)*2+1024);
|
---|
1186 |
|
---|
1187 | //1行Ifをブロック形式にする
|
---|
1188 | for(i=0,i2=0;;i++,i2++){
|
---|
1189 | if(buffer[i]==1&&buffer[i+1]==ESC_IF){
|
---|
1190 | temporary[i2++]=buffer[i++];
|
---|
1191 | temporary[i2++]=buffer[i++];
|
---|
1192 | ChangeOneIf(temporary,i2,buffer,i);
|
---|
1193 | i2--,i--;
|
---|
1194 | continue;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | temporary[i2]=buffer[i];
|
---|
1198 | if(buffer[i]=='\0') break;
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 | //ElseIfを入れ子構造に変更する
|
---|
1202 | for(i=0,i2=0;;i++,i2++){
|
---|
1203 | if(temporary[i]==1&&temporary[i+1]==ESC_IF){
|
---|
1204 | buffer[i2++]=temporary[i++];
|
---|
1205 | buffer[i2++]=temporary[i++];
|
---|
1206 | OutsideIfFormat(buffer,i2,temporary,i);
|
---|
1207 | i2--,i--;
|
---|
1208 | continue;
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | buffer[i2]=temporary[i];
|
---|
1212 | if(temporary[i]=='\0') break;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | HeapDefaultFree(temporary);
|
---|
1216 | }
|
---|
1217 | void CheckPareCommand(void){
|
---|
1218 | extern char *basbuf;
|
---|
1219 | int i2,i3;
|
---|
1220 |
|
---|
1221 | int FuncNum=0;
|
---|
1222 | int FuncType=0;
|
---|
1223 | int FuncPtr=-1;
|
---|
1224 | for(i2=0;;i2++){
|
---|
1225 | if(basbuf[i2]=='\0') break;
|
---|
1226 | if(IsCommandDelimitation(basbuf[i2])){
|
---|
1227 | if(basbuf[i2+1]==1){
|
---|
1228 | i2++;
|
---|
1229 | switch(basbuf[i2+1]){
|
---|
1230 | case ESC_FUNCTION:
|
---|
1231 | case ESC_SUB:
|
---|
1232 | case ESC_MACRO:
|
---|
1233 | if(FuncNum!=0){
|
---|
1234 | if(FuncType==ESC_FUNCTION)
|
---|
1235 | compiler.errorMessenger.Output(54,"End Function",FuncPtr);
|
---|
1236 | else if(FuncType==ESC_SUB)
|
---|
1237 | compiler.errorMessenger.Output(54,"End Sub",FuncPtr);
|
---|
1238 | else if(FuncType==ESC_MACRO)
|
---|
1239 | compiler.errorMessenger.Output(54,"End Macro",FuncPtr);
|
---|
1240 | return;
|
---|
1241 | }
|
---|
1242 | FuncType=basbuf[i2+1];
|
---|
1243 | FuncNum++;
|
---|
1244 | FuncPtr=i2;
|
---|
1245 | break;
|
---|
1246 | case ESC_ENDFUNCTION:
|
---|
1247 | case ESC_ENDSUB:
|
---|
1248 | case ESC_ENDMACRO:
|
---|
1249 | if(basbuf[i2+1]==ESC_ENDFUNCTION) i3=ESC_FUNCTION;
|
---|
1250 | else if(basbuf[i2+1]==ESC_ENDSUB) i3=ESC_SUB;
|
---|
1251 | else if(basbuf[i2+1]==ESC_ENDMACRO) i3=ESC_MACRO;
|
---|
1252 |
|
---|
1253 | FuncNum--;
|
---|
1254 |
|
---|
1255 | if(FuncNum!=0||i3!=FuncType){
|
---|
1256 | if(basbuf[i2+1]==ESC_ENDFUNCTION)
|
---|
1257 | compiler.errorMessenger.Output(12,"End Function",i2);
|
---|
1258 | else if(basbuf[i2+1]==ESC_ENDSUB)
|
---|
1259 | compiler.errorMessenger.Output(12,"End Sub",i2);
|
---|
1260 | else if(basbuf[i2+1]==ESC_ENDMACRO)
|
---|
1261 | compiler.errorMessenger.Output(12,"End Macro",i2);
|
---|
1262 | return;
|
---|
1263 | }
|
---|
1264 | break;
|
---|
1265 | }
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 |
|
---|
1269 | }
|
---|
1270 | }
|
---|
1271 | }
|
---|