source: dev/trunk/abdev/BasicCompiler_Common/Intermediate_Step2.cpp@ 185

Last change on this file since 185 was 182, checked in by dai_9181, 17 years ago
File size: 17.3 KB
Line 
1#include <jenga/include/smoothie/Smoothie.h>
2#include <jenga/include/smoothie/LexicalAnalysis.h>
3
4#include "../BasicCompiler_Common/common.h"
5
6CONSTINFO *GetNewConstHash(char *name){
7 extern int cp;
8 CONSTINFO *pci;
9
10 int key;
11 key=hash_default(name);
12
13 extern CONSTINFO **ppConstHash;
14 if(ppConstHash[key]){
15 pci=ppConstHash[key];
16 while(1){
17 if(lstrcmp(pci->name,name)==0){
18 //重複エラー
19 SetError(15,name,cp);
20 return 0;
21 }
22
23 if(pci->pNextData==0){
24 pci->pNextData=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
25 break;
26 }
27 pci=pci->pNextData;
28 }
29 pci=pci->pNextData;
30 }
31 else{
32 ppConstHash[key]=(CONSTINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,sizeof(CONSTINFO));
33 pci=ppConstHash[key];
34 }
35
36 return pci;
37}
38
39// マクロ定数を追加するための関数
40void AddConstData(char *Command){
41 extern HANDLE hHeap;
42 extern int cp;
43 int i,i2;
44 char temporary[VN_SIZE];
45
46 for(i=0;;i++){
47 if(Command[i]=='\0'){
48 SetError(10,"Const",cp);
49 return;
50 }
51 if(Command[i]=='=' || Command[i] == 1 && Command[i+1] == ESC_AS ){
52 //定数定義は新しいクラスモジュール(CDBConst)へ移行
53 // ※この関数はマクロ定数のみを扱う
54 return;
55 }
56 if(Command[i]=='('){
57 temporary[i]=0;
58 break;
59 }
60 temporary[i]=Command[i];
61 }
62
63
64 /////////////////////////////////
65 // 格納位置を計算してpciにセット
66 /////////////////////////////////
67
68 CONSTINFO *pci;
69 pci=GetNewConstHash(temporary);
70 if(!pci) return;
71
72
73
74 ////////////////////
75 // 定数情報を取得
76 ////////////////////
77
78 //定数名
79 pci->name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
80 lstrcpy(pci->name,temporary);
81
82 if(Command[i]=='('){
83 pci->ppParm=(char **)HeapAlloc(hHeap,0,1);
84 pci->ParmNum=0;
85 for(i++,i2=0;;i++,i2++){
86 if(Command[i]=='\0'){
87 SetError(1,NULL,cp);
88 return;
89 }
90 if(Command[i]==','||Command[i]==')'){
91 temporary[i2]=0;
92 pci->ppParm=(char **)HeapReAlloc(hHeap,0,pci->ppParm,(pci->ParmNum+1)*sizeof(char *));
93 pci->ppParm[pci->ParmNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
94 lstrcpy(pci->ppParm[pci->ParmNum],temporary);
95 pci->ParmNum++;
96 if(Command[i]==')'){
97 i++;
98 if(Command[i]!='='){
99 SetError(1,NULL,cp);
100 return;
101 }
102 break;
103 }
104
105 i2=-1;
106 continue;
107 }
108 temporary[i2]=Command[i];
109 }
110 }
111 else pci->ParmNum=0;
112
113 //データ
114 lstrcpy(temporary,Command+i+1);
115 if(pci->ParmNum){
116 pci->StrValue=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
117 lstrcpy(pci->StrValue,temporary);
118 }
119 else if(temporary[0]=='\"'){
120 //文字列定数
121 RemoveStringQuotes(temporary);
122 i2=lstrlen(temporary);
123
124 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
125 memcpy(pci->StrValue,temporary,i2);
126 pci->StrValue[i2]=0;
127
128 pci->DblValue=(double)i2;
129
130 pci->type=DEF_STRING;
131 pci->lpIndex=-1;
132 }
133 else if((temporary[0]=='e'||temporary[0]=='E')&&
134 (temporary[1]=='x'||temporary[1]=='X')&&
135 temporary[2]=='\"'){
136 //文字列定数
137 RemoveStringQuotes(temporary+2);
138 i2=FormatString_EscapeSequence(temporary+2);
139 pci->StrValue=(char *)HeapAlloc(hHeap,0,i2+1);
140 memcpy(pci->StrValue,temporary+2,i2);
141 pci->StrValue[i2]=0;
142
143 pci->DblValue=(double)i2;
144
145 pci->type=DEF_STRING;
146 pci->lpIndex=-1;
147 }
148 else{
149 //数値定数
150 _int64 i64data;
151 Type resultType;
152 StaticCalculation(true, temporary,0,&i64data,resultType);
153 pci->type=resultType.GetBasicType();
154 if(IsRealNumberType(pci->type)){
155 //実数型
156 memcpy(&pci->DblValue,&i64data,sizeof(double));
157 }
158 else if(Is64Type(pci->type)){
159 //64ビット型
160 pci->i64Value=i64data;
161 }
162 else if(IsWholeNumberType(pci->type)){
163 //その他整数型
164 pci->DblValue=(double)i64data;
165 }
166
167 pci->StrValue=0;
168 }
169}
170void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){
171 extern int cp;
172 int i=0,i2;
173
174 if(!(buffer[i]==1&&buffer[i+1]==ESC_ENUM)) return;
175 i+=2;
176
177 //列挙体の名前を取得
178 char temporary[VN_SIZE];
179 for(i2=0;;i++,i2++){
180 if(IsCommandDelimitation(buffer[i])){
181 temporary[i2]=0;
182 break;
183 }
184 if(!IsVariableChar(buffer[i])){
185 SetError(1,NULL,i);
186 break;
187 }
188 temporary[i2]=buffer[i];
189 }
190
191 if(buffer[i]=='\0'){
192 SetError(22,"Enum",cp);
193 return;
194 }
195
196 int NextValue=0;
197 while(1){
198 i++;
199
200 if(buffer[i]==1&&buffer[i+1]==ESC_ENDENUM) break;
201
202 for(i2=0;;i2++,i++){
203 if(IsCommandDelimitation(buffer[i])){
204 temporary[i2]=0;
205 break;
206 }
207 if(buffer[i]=='='){
208 temporary[i2]=0;
209 break;
210 }
211 temporary[i2]=buffer[i];
212 }
213 if(temporary[0]=='\0'){
214 if(buffer[i]=='\0'){
215 SetError(22,"Enum",cp);
216 break;
217 }
218 continue;
219 }
220
221 if(buffer[i]!='='){
222 NextValue++;
223 }
224 else{
225 char temp2[VN_SIZE];
226 for(i++,i2=0;;i2++,i++){
227 if(IsCommandDelimitation(buffer[i])){
228 temp2[i2]=0;
229 break;
230 }
231 temp2[i2]=buffer[i];
232 }
233
234 _int64 i64data;
235 StaticCalculation(true, temp2,DEF_LONG,&i64data,Type());
236 NextValue=(int)i64data;
237 }
238
239 //定数を追加
240 CDBConst::obj.AddConst( namespaceScopes, temporary, NextValue);
241 }
242}
243bool GetConstInfo(void){
244 ////////////////////////////////////////////
245 // Const命令の情報を取得
246 ////////////////////////////////////////////
247
248 int i2;
249 char temporary[1024];
250
251 // 名前空間管理
252 NamespaceScopes &namespaceScopes = Smoothie::Temp::liveingNamespaceScopes;
253 namespaceScopes.clear();
254
255 //定数に関する情報
256 extern CONSTINFO **ppConstHash;
257 ppConstHash=(CONSTINFO **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(CONSTINFO *));
258
259 extern char *basbuf;
260 for(int i=0;;i++){
261 if( basbuf[i] == '\0' ) break;
262
263 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
264 for(i+=2,i2=0;;i2++,i++){
265 if( IsCommandDelimitation( basbuf[i] ) ){
266 temporary[i2]=0;
267 break;
268 }
269 temporary[i2]=basbuf[i];
270 }
271 namespaceScopes.push_back( temporary );
272
273 continue;
274 }
275 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
276 if( namespaceScopes.size() <= 0 ){
277 SetError(12, "End Namespace", i );
278 }
279 else{
280 namespaceScopes.pop_back();
281 }
282
283 i += 2;
284 continue;
285 }
286
287 if( basbuf[i] == 1 ){
288 if(basbuf[i]==1&&basbuf[i+1]==ESC_CONST){
289 i+=2;
290
291 extern int cp;
292 cp=i; //エラー用
293
294
295 if(basbuf[i]==1&&basbuf[i+1]==ESC_ENUM){
296 AddConstEnum( namespaceScopes, basbuf+i);
297 continue;
298 }
299
300 for(i2=0;;i++,i2++){
301 if(basbuf[i]=='\"'){
302 temporary[i2]=basbuf[i];
303 for(i++,i2++;;i++,i2++){
304 temporary[i2]=basbuf[i];
305 if(basbuf[i]=='\"') break;
306 }
307 continue;
308 }
309 if(IsCommandDelimitation(basbuf[i])){
310 temporary[i2]=0;
311 break;
312 }
313 temporary[i2]=basbuf[i];
314 }
315 CDBConst::obj.Add( namespaceScopes, temporary);
316 if(basbuf[i]=='\0') break;
317 }
318 else{
319 int result = JumpStatement( basbuf, i );
320 if( result == -1 ){
321 //エラー
322 return false;
323 }
324 else if( result == 1 ){
325 //ジャンプした場合
326 i--;
327 }
328 }
329 }
330 }
331 return true;
332}
333
334char ConstructorDestructorSchedule[MAX_PATH];
335void MakeConstructorAndDestructor(char *buffer,int nowLine,char *ClassName){
336 int i,i2;
337 char temporary[MAX_PATH],*pTemp;
338 BOOL bConstructor,bDestructor;
339
340 ConstructorDestructorSchedule[0]=0;
341 bConstructor=0;
342 bDestructor=0;
343
344 for(i=nowLine;;i++){
345 if(buffer[i]=='\0') break;
346 if(buffer[i]==1&&buffer[i+1]==ESC_ENDCLASS){
347 if((!bConstructor)||(!bDestructor)){
348 pTemp=ConstructorDestructorSchedule;
349
350 lstrcpy(pTemp,"Public:");
351
352 if(!bConstructor){
353 //コンストラクタが無いときは生成する
354 sprintf(pTemp+lstrlen(pTemp),"%c%c%s():%c%c:",
355 1,ESC_SUB,
356 ClassName,
357 1,ESC_ENDSUB);
358 }
359
360 if(!bDestructor){
361 //デストラクタが無いときは生成する
362 sprintf(pTemp+lstrlen(pTemp),"%c%c~%s():%c%c:",
363 1,ESC_SUB,
364 ClassName,
365 1,ESC_ENDSUB);
366 }
367 }
368 break;
369 }
370
371 if(buffer[i]==1&&(buffer[i+1]==ESC_SUB||buffer[i+1]==ESC_FUNCTION)){
372 i+=2;
373 while(IsBlank(buffer[i])) i++;
374 if(buffer[i]=='~'){
375 //デストラクタ
376 bDestructor=1;
377 }
378 else{
379 //コンストラクタかどうかをチェック
380 for(i2=0;;i++,i2++){
381 if(!IsVariableChar(buffer[i])){
382 temporary[i2]=0;
383 break;
384 }
385 temporary[i2]=buffer[i];
386 }
387 if(lstrcmp(temporary,ClassName)==0) bConstructor=1;
388 }
389 }
390 }
391}
392void ChangeCommand(char *buffer,int nowLine,char *Command){
393 int i,i2,IsStr;
394 unsigned _int16 ComNum;
395 char com[8192],pam[8192];
396
397 static int nCountOfNonGlobalScope = 0;
398
399 if(Command[0]==1){
400 switch(Command[1]){
401 case ESC_SELECTCASE:
402 case ESC_CASE:
403 KillStringSpaces(Command+2);
404 break;
405 case ESC_WITH:
406 KillStringSpaces(Command+2);
407 break;
408 case ESC_TYPEDEF:
409 KillStringSpaces(Command+2);
410 break;
411 case ESC_DECLARE:
412 KillStringSpaces(Command+2);
413 break;
414 case ESC_IF:
415 KillStringSpaces(Command+2);
416 break;
417
418 case ESC_CLASS:
419 KillStringSpaces(Command+2);
420 i2 = 2;
421 if( Command[i2] == 1 && Command[i2+1] == ESC_ENUM ){
422 i2 += 2;
423 }
424 else if( memicmp( Command + i2, "Blittable(", 10 ) == 0 ){
425 i2 += 10;
426 i2 = JumpStringInPare(Command,i2)+1;
427 }
428
429 //コンストラクタ、デストラクタを暗黙的に生成
430 MakeConstructorAndDestructor(buffer,nowLine,Command + i2);
431 break;
432 case ESC_INTERFACE:
433 KillStringSpaces(Command+2);
434 break;
435 case ESC_ENDCLASS:
436 if(ConstructorDestructorSchedule[0]){
437 //生成されたコンストラクタ、デストラクタを挿入
438 sprintf(Command,"%s%c%c",ConstructorDestructorSchedule,1,ESC_ENDCLASS);
439 }
440 break;
441
442 case ESC_TYPE:
443 KillStringSpaces(Command+2);
444 break;
445
446 case ESC_CONST:
447 KillStringSpaces(Command+2);
448 if( Command[2] == 1 && Command[3] == ESC_ENUM ){
449 nCountOfNonGlobalScope++;
450 }
451 break;
452
453 case ESC_ENUM:
454 nCountOfNonGlobalScope++;
455 KillStringSpaces(Command+2);
456 break;
457
458 case ESC_ENDENUM:
459 nCountOfNonGlobalScope--;
460 break;
461
462 case ESC_INHERITS:
463 case ESC_VIRTUAL:
464 case ESC_OVERRIDE:
465 case ESC_ABSTRACT:
466 case ESC_SUB:
467 case ESC_FUNCTION:
468 case ESC_MACRO:
469 case ESC_STATIC:
470 case ESC_NAMESPACE:
471 case ESC_IMPORTS:
472 KillStringSpaces(Command+2);
473 break;
474 }
475 return;
476 }
477
478 bool isPare = false;
479 for(i=0;;i++){
480 if(Command[i]==' '||Command[i]=='\t'||Command[i]=='('||Command[i]=='\"'||Command[i]=='@'||Command[i]=='-'){
481 com[i]=0;
482 while(Command[i]==' '||Command[i]=='\t') i++;
483 if( Command[i] == '(' ) isPare = true;
484 break;
485 }
486 if(Command[i]=='='){
487 KillStringSpaces(Command);
488 return;
489 }
490 com[i]=Command[i];
491 if(Command[i]=='\0') break;
492 }
493
494 //マクロによるコマンド
495 i2=1;
496 if( nCountOfNonGlobalScope == 0 ){
497 //グローバル
498 if(lstrcmpi(com,"Open")==0) ComOpen(Command+i,pam,nowLine);
499 else if(lstrcmpi(com,"Close")==0) ComClose(Command+i,pam);
500 else if(lstrcmpi(com,"Field")==0||
501 lstrcmpi(com,"Get")==0||
502 lstrcmpi(com,"Put")==0) ComField(Command+i,pam);
503 else if(lstrcmpi(com,"Line")==0) ComLine(Command+i,pam,nowLine);
504 else if(lstrcmpi(com,"Circle")==0) ComCircle(Command+i,pam,nowLine);
505 else if(lstrcmpi(com,"PSet")==0) ComPSet(Command+i,pam,nowLine);
506 else if(lstrcmpi(com,"Paint")==0) ComPaint(Command+i,pam,nowLine);
507
508 else if(
509 lstrcmpi(com,"EXEC")==0||
510 lstrcmpi(com,"INPUT")==0||
511 lstrcmpi(com,"PRINT")==0||
512 lstrcmpi(com,"RANDOMIZE")==0||
513 ( lstrcmpi(com,"WRITE")==0 && isPare == false )||
514 lstrcmpi(com,"MSGBOX")==0||
515 lstrcmpi(com,"WINDOW")==0||
516 lstrcmpi(com,"DELWND")==0||
517 lstrcmpi(com,"INSMENU")==0||
518 lstrcmpi(com,"CHDIR")==0||
519 lstrcmpi(com,"MKDIR")==0||
520 lstrcmpi(com,"KILL")==0||
521 lstrcmpi(com,"CLS")==0||
522 lstrcmpi(com,"COLOR")==0||
523 lstrcmpi(com,"LOCATE")==0
524 ){
525 KillSpaces(Command+i,pam);
526
527 //大文字に変換
528 CharUpper(com);
529
530 sprintf(Command,"%s(%s)",com,pam);
531 return;
532 }
533
534 else i2=0;
535 }
536 else i2=0;
537 if(i2){
538 //大文字に変換
539 CharUpper(com);
540
541 sprintf(Command,"%s(%s)",com,pam);
542 return;
543 }
544
545
546
547 //コンパイラに搭載されるコマンド
548 if(lstrcmpi(com,"Do")==0){
549 KillSpaces(Command+i,pam);
550 ComNum=COM_DO;
551 }
552 else if(lstrcmpi(com,"goto")==0){
553 KillSpaces(Command+i,pam);
554 ComNum=COM_GOTO;
555 }
556 else if(lstrcmpi(com,"gosub")==0){
557 KillSpaces(Command+i,pam);
558 ComNum=COM_GOSUB;
559 }
560 else if(lstrcmpi(com,"Loop")==0){
561 if((Command[i]=='w'||Command[i]=='W')&&(Command[i+1]=='h'||Command[i+1]=='H')&&(Command[i+2]=='i'||Command[i+2]=='I')&&(Command[i+3]=='l'||Command[i+3]=='L')&&(Command[i+4]=='e'||Command[i+4]=='E')){
562 lstrcpy(pam,"0,");
563 KillSpaces(Command+i+5,pam+2);
564 }
565 else if((Command[i]=='u'||Command[i]=='U')&&(Command[i+1]=='n'||Command[i+1]=='N')&&(Command[i+2]=='t'||Command[i+2]=='T')&&(Command[i+3]=='i'||Command[i+3]=='I')&&(Command[i+4]=='l'||Command[i+4]=='L')){
566 lstrcpy(pam,"1,");
567 KillSpaces(Command+i+5,pam+2);
568 }
569 else pam[0]=0;
570 ComNum=COM_LOOP;
571 }
572 else if(lstrcmpi(com,"For")==0){
573 for(i2=0,IsStr=0;;i++,i2++){
574 while(Command[i]==' '||Command[i]=='\t') i++;
575 if(Command[i]=='\"') IsStr^=1;
576 if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='t'||Command[i]=='T')&&(Command[i+1]=='o'||Command[i+1]=='O')&&(Command[i+2]==' '||Command[i+2]=='\t')&&IsStr==0){
577 pam[i2]=',';
578 break;
579 }
580 pam[i2]=Command[i];
581 if(Command[i]=='\0') break;
582 }
583 if(Command[i]){
584 for(i+=3,i2++,IsStr=0;;i++,i2++){
585 while(Command[i]==' '||Command[i]=='\t') i++;
586 if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='s'||Command[i]=='S')&&(Command[i+1]=='t'||Command[i+1]=='T')&&(Command[i+2]=='e'||Command[i+2]=='E')&&(Command[i+3]=='p'||Command[i+3]=='P')&&(Command[i+4]==' '||Command[i+4]=='\t')){
587 pam[i2]=',';
588 i+=4;
589 continue;
590 }
591 pam[i2]=Command[i];
592 if(Command[i]=='\0') break;
593 }
594 }
595 ComNum=COM_FOR;
596 }
597 else if(lstrcmpi(com,"Next")==0){
598 KillSpaces(Command+i,pam);
599 ComNum=COM_NEXT;
600 }
601 else if(lstrcmpi(com,"Return")==0){
602 KillSpaces(Command+i,pam);
603 ComNum=COM_RETURN;
604 }
605 else if(lstrcmpi(com,"While")==0){
606 KillSpaces(Command+i,pam);
607 ComNum=COM_WHILE;
608 }
609 else if(lstrcmpi(com,"Wend")==0){
610 pam[0]=0;
611 ComNum=COM_WEND;
612 }
613
614 //変数、データ操作
615 else if(lstrcmpi(com,"dim")==0){
616 KillSpaces(Command+i,pam);
617 ComNum=COM_DIM;
618 }
619 else if(lstrcmpi(com,"Delete")==0){
620 KillSpaces(Command+i,pam);
621 ComNum=COM_DELETE;
622 }
623 else if( lstrcmpi( com, "_System_SweepingDelete" ) == 0 ){
624 KillSpaces(Command+i,pam);
625 ComNum=COM_SWEEPINGDELETE;
626 }
627
628 //その他
629 else if(lstrcmpi(com,"Debug")==0){
630 pam[0]=0;
631 ComNum=COM_DEBUG;
632 }
633 else if(lstrcmpi(com,"let")==0){
634 KillSpaces(Command+i,pam);
635 ComNum=COM_LET;
636 }
637 else if(lstrcmpi(com,"rem")==0){
638 Command[0]=0;
639 return;
640 }
641
642 //ポインタ
643 else if(lstrcmpi(com,"SetDouble")==0){
644 KillSpaces(Command+i,pam);
645 ComNum=COM_SETDOUBLE;
646 }
647 else if(lstrcmpi(com,"SetSingle")==0){
648 KillSpaces(Command+i,pam);
649 ComNum=COM_SETSINGLE;
650 }
651 else if(lstrcmpi(com,"SetQWord")==0){
652 KillSpaces(Command+i,pam);
653 ComNum=COM_SETQWORD;
654 }
655 else if(lstrcmpi(com,"SetDWord")==0){
656 KillSpaces(Command+i,pam);
657 ComNum=COM_SETDWORD;
658 }
659 else if(lstrcmpi(com,"SetWord")==0){
660 KillSpaces(Command+i,pam);
661 ComNum=COM_SETWORD;
662 }
663 else if(lstrcmpi(com,"SetByte")==0){
664 KillSpaces(Command+i,pam);
665 ComNum=COM_SETBYTE;
666 }
667
668 else{
669 //その他のコマンド(一般コード)
670 lstrcpy(com,Command);
671 KillSpaces(com,Command);
672 return;
673 }
674
675 i=lstrlen(pam);
676 while(pam[i-1]==' '||pam[i-1]=='\t') i--;
677 pam[i]=0;
678 if(pam[0]) sprintf(Command,"%c%c%s",HIBYTE(ComNum),LOBYTE(ComNum),pam);
679 else sprintf(Command,"%c%c",HIBYTE(ComNum),LOBYTE(ComNum));
680
681 return;
682}
683
684void ChangeCommandToCode(char *buffer){
685 extern HANDLE hHeap;
686 int i,i2,i3,IsStr,CommandBufferSize;
687 char *temporary,*tempBase,temp2[VN_SIZE],*lpCommand;
688
689 tempBase=(char *)HeapAlloc(hHeap,0,(lstrlen(buffer)+1)*2+8192);
690 temporary=tempBase+1;
691 temporary[0]=0;
692 i=0;
693 i3=0;
694
695 CommandBufferSize=512;
696 lpCommand=(char *)HeapAlloc(hHeap,0,CommandBufferSize);
697
698 while(1){
699 i2=0;
700 while(buffer[i]==' '||buffer[i]=='\t') i++;
701 while(buffer[i]>='0'&&buffer[i]<='9'){
702 temp2[i2]=buffer[i];
703 i++;
704 i2++;
705 }
706 temp2[i2]=0;
707 while(buffer[i]==' '||buffer[i]=='\t') i++;
708 for(i2=0,IsStr=0;;i++,i2++){
709 if(i2>=CommandBufferSize){ //バッファ領域が足りなくなった場合はバッファを増量する
710 CommandBufferSize+=512;
711 lpCommand=(char *)HeapReAlloc(hHeap,0,lpCommand,CommandBufferSize);
712 }
713 if(buffer[i]=='\"') IsStr^=1;
714 if(buffer[i]=='\n'||(buffer[i]==':'&&IsStr==0)||buffer[i]=='\0'){
715 lpCommand[i2]=0;
716
717 if(temp2[0]){
718 //行番号ラベル
719 sprintf(temporary+i3,"%c%c%s,",1,ESC_LINENUM,temp2);
720 i3+=lstrlen(temporary+i3);
721
722 temp2[0]=0;
723 }
724
725 //命令コードへ変換
726 if(i2){
727 //エラー用
728 extern int cp;
729 cp=i;
730
731 ChangeCommand(buffer,i,lpCommand);
732
733 lstrcpy(temporary+i3,lpCommand);
734 i3+=lstrlen(temporary+i3);
735 }
736
737 if(!(lpCommand[0]=='\0'&&buffer[i]==':')){
738 temporary[i3++]=buffer[i];
739 temporary[i3]=0;
740 }
741
742 if(buffer[i]=='\n'){
743 i++;
744 break;
745 }
746 else if(buffer[i]==':'){
747 while(buffer[i+1]==' '||buffer[i+1]=='\t') i++;
748 }
749 if(buffer[i]=='\0') break;
750 i2=-1;
751 continue;
752 }
753 lpCommand[i2]=buffer[i];
754 }
755 if(buffer[i]=='\0') break;
756 }
757 HeapDefaultFree(lpCommand);
758 lstrcpy(buffer,temporary);
759
760 HeapDefaultFree(tempBase);
761}
Note: See TracBrowser for help on using the repository browser.