[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[199] | 3 | #include <Compiler.h>
|
---|
[195] | 4 |
|
---|
[4] | 5 | #include "../BasicCompiler_Common/common.h"
|
---|
| 6 |
|
---|
| 7 |
|
---|
[103] | 8 | void AddConstEnum( const NamespaceScopes &namespaceScopes, char *buffer){
|
---|
[4] | 9 | extern int cp;
|
---|
| 10 | int i=0,i2;
|
---|
| 11 |
|
---|
| 12 | if(!(buffer[i]==1&&buffer[i+1]==ESC_ENUM)) return;
|
---|
| 13 | i+=2;
|
---|
| 14 |
|
---|
| 15 | //列挙体の名前を取得
|
---|
| 16 | char temporary[VN_SIZE];
|
---|
| 17 | for(i2=0;;i++,i2++){
|
---|
| 18 | if(IsCommandDelimitation(buffer[i])){
|
---|
| 19 | temporary[i2]=0;
|
---|
| 20 | break;
|
---|
| 21 | }
|
---|
| 22 | if(!IsVariableChar(buffer[i])){
|
---|
[465] | 23 | compiler.errorMessenger.Output(1,NULL,i);
|
---|
[4] | 24 | break;
|
---|
| 25 | }
|
---|
| 26 | temporary[i2]=buffer[i];
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | if(buffer[i]=='\0'){
|
---|
[465] | 30 | compiler.errorMessenger.Output(22,"Enum",cp);
|
---|
[4] | 31 | return;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | int NextValue=0;
|
---|
| 35 | while(1){
|
---|
| 36 | i++;
|
---|
| 37 |
|
---|
| 38 | if(buffer[i]==1&&buffer[i+1]==ESC_ENDENUM) break;
|
---|
| 39 |
|
---|
| 40 | for(i2=0;;i2++,i++){
|
---|
| 41 | if(IsCommandDelimitation(buffer[i])){
|
---|
| 42 | temporary[i2]=0;
|
---|
| 43 | break;
|
---|
| 44 | }
|
---|
| 45 | if(buffer[i]=='='){
|
---|
| 46 | temporary[i2]=0;
|
---|
| 47 | break;
|
---|
| 48 | }
|
---|
| 49 | temporary[i2]=buffer[i];
|
---|
| 50 | }
|
---|
| 51 | if(temporary[0]=='\0'){
|
---|
| 52 | if(buffer[i]=='\0'){
|
---|
[465] | 53 | compiler.errorMessenger.Output(22,"Enum",cp);
|
---|
[4] | 54 | break;
|
---|
| 55 | }
|
---|
| 56 | continue;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | if(buffer[i]!='='){
|
---|
| 60 | NextValue++;
|
---|
| 61 | }
|
---|
| 62 | else{
|
---|
| 63 | char temp2[VN_SIZE];
|
---|
| 64 | for(i++,i2=0;;i2++,i++){
|
---|
| 65 | if(IsCommandDelimitation(buffer[i])){
|
---|
| 66 | temp2[i2]=0;
|
---|
| 67 | break;
|
---|
| 68 | }
|
---|
| 69 | temp2[i2]=buffer[i];
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | _int64 i64data;
|
---|
[75] | 73 | StaticCalculation(true, temp2,DEF_LONG,&i64data,Type());
|
---|
[4] | 74 | NextValue=(int)i64data;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | //定数を追加
|
---|
[265] | 78 | compiler.GetObjectModule().meta.GetGlobalConsts().Add( namespaceScopes, temporary, NextValue);
|
---|
[4] | 79 | }
|
---|
| 80 | }
|
---|
[16] | 81 | bool GetConstInfo(void){
|
---|
[4] | 82 | ////////////////////////////////////////////
|
---|
| 83 | // Const命令の情報を取得
|
---|
| 84 | ////////////////////////////////////////////
|
---|
| 85 |
|
---|
[103] | 86 | int i2;
|
---|
[4] | 87 | char temporary[1024];
|
---|
| 88 |
|
---|
[103] | 89 | // 名前空間管理
|
---|
[199] | 90 | NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
|
---|
[103] | 91 | namespaceScopes.clear();
|
---|
| 92 |
|
---|
[4] | 93 | extern char *basbuf;
|
---|
[103] | 94 | for(int i=0;;i++){
|
---|
[16] | 95 | if( basbuf[i] == '\0' ) break;
|
---|
[103] | 96 |
|
---|
| 97 | if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){
|
---|
| 98 | for(i+=2,i2=0;;i2++,i++){
|
---|
| 99 | if( IsCommandDelimitation( basbuf[i] ) ){
|
---|
| 100 | temporary[i2]=0;
|
---|
| 101 | break;
|
---|
| 102 | }
|
---|
| 103 | temporary[i2]=basbuf[i];
|
---|
| 104 | }
|
---|
| 105 | namespaceScopes.push_back( temporary );
|
---|
| 106 |
|
---|
| 107 | continue;
|
---|
| 108 | }
|
---|
| 109 | else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){
|
---|
| 110 | if( namespaceScopes.size() <= 0 ){
|
---|
[465] | 111 | compiler.errorMessenger.Output(12, "End Namespace", i );
|
---|
[103] | 112 | }
|
---|
| 113 | else{
|
---|
| 114 | namespaceScopes.pop_back();
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | i += 2;
|
---|
| 118 | continue;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[16] | 121 | if( basbuf[i] == 1 ){
|
---|
| 122 | if(basbuf[i]==1&&basbuf[i+1]==ESC_CONST){
|
---|
| 123 | i+=2;
|
---|
[4] | 124 |
|
---|
[16] | 125 | extern int cp;
|
---|
| 126 | cp=i; //エラー用
|
---|
[4] | 127 |
|
---|
| 128 |
|
---|
[16] | 129 | if(basbuf[i]==1&&basbuf[i+1]==ESC_ENUM){
|
---|
[103] | 130 | AddConstEnum( namespaceScopes, basbuf+i);
|
---|
[16] | 131 | continue;
|
---|
| 132 | }
|
---|
[4] | 133 |
|
---|
[16] | 134 | for(i2=0;;i++,i2++){
|
---|
| 135 | if(basbuf[i]=='\"'){
|
---|
[4] | 136 | temporary[i2]=basbuf[i];
|
---|
[16] | 137 | for(i++,i2++;;i++,i2++){
|
---|
| 138 | temporary[i2]=basbuf[i];
|
---|
| 139 | if(basbuf[i]=='\"') break;
|
---|
| 140 | }
|
---|
| 141 | continue;
|
---|
[4] | 142 | }
|
---|
[16] | 143 | if(IsCommandDelimitation(basbuf[i])){
|
---|
| 144 | temporary[i2]=0;
|
---|
| 145 | break;
|
---|
| 146 | }
|
---|
| 147 | temporary[i2]=basbuf[i];
|
---|
[4] | 148 | }
|
---|
[206] | 149 | AddConst( namespaceScopes, temporary);
|
---|
[16] | 150 | if(basbuf[i]=='\0') break;
|
---|
| 151 | }
|
---|
| 152 | else{
|
---|
| 153 | int result = JumpStatement( basbuf, i );
|
---|
| 154 | if( result == -1 ){
|
---|
| 155 | //エラー
|
---|
| 156 | return false;
|
---|
[4] | 157 | }
|
---|
[16] | 158 | else if( result == 1 ){
|
---|
| 159 | //ジャンプした場合
|
---|
| 160 | i--;
|
---|
| 161 | }
|
---|
[4] | 162 | }
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
[206] | 165 |
|
---|
| 166 | // イテレータを初期化
|
---|
[265] | 167 | compiler.GetObjectModule().meta.GetGlobalConsts().Iterator_Init();
|
---|
| 168 | compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init();
|
---|
[206] | 169 |
|
---|
[16] | 170 | return true;
|
---|
[4] | 171 | }
|
---|
| 172 |
|
---|
| 173 | char ConstructorDestructorSchedule[MAX_PATH];
|
---|
[75] | 174 | void MakeConstructorAndDestructor(char *buffer,int nowLine,char *ClassName){
|
---|
[4] | 175 | int i,i2;
|
---|
| 176 | char temporary[MAX_PATH],*pTemp;
|
---|
| 177 | BOOL bConstructor,bDestructor;
|
---|
| 178 |
|
---|
| 179 | ConstructorDestructorSchedule[0]=0;
|
---|
| 180 | bConstructor=0;
|
---|
| 181 | bDestructor=0;
|
---|
| 182 |
|
---|
[75] | 183 | for(i=nowLine;;i++){
|
---|
[4] | 184 | if(buffer[i]=='\0') break;
|
---|
| 185 | if(buffer[i]==1&&buffer[i+1]==ESC_ENDCLASS){
|
---|
| 186 | if((!bConstructor)||(!bDestructor)){
|
---|
| 187 | pTemp=ConstructorDestructorSchedule;
|
---|
| 188 |
|
---|
| 189 | lstrcpy(pTemp,"Public:");
|
---|
| 190 |
|
---|
| 191 | if(!bConstructor){
|
---|
| 192 | //コンストラクタが無いときは生成する
|
---|
| 193 | sprintf(pTemp+lstrlen(pTemp),"%c%c%s():%c%c:",
|
---|
| 194 | 1,ESC_SUB,
|
---|
| 195 | ClassName,
|
---|
| 196 | 1,ESC_ENDSUB);
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | if(!bDestructor){
|
---|
| 200 | //デストラクタが無いときは生成する
|
---|
| 201 | sprintf(pTemp+lstrlen(pTemp),"%c%c~%s():%c%c:",
|
---|
| 202 | 1,ESC_SUB,
|
---|
| 203 | ClassName,
|
---|
| 204 | 1,ESC_ENDSUB);
|
---|
| 205 | }
|
---|
| 206 | }
|
---|
| 207 | break;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | if(buffer[i]==1&&(buffer[i+1]==ESC_SUB||buffer[i+1]==ESC_FUNCTION)){
|
---|
| 211 | i+=2;
|
---|
| 212 | while(IsBlank(buffer[i])) i++;
|
---|
| 213 | if(buffer[i]=='~'){
|
---|
| 214 | //デストラクタ
|
---|
| 215 | bDestructor=1;
|
---|
| 216 | }
|
---|
| 217 | else{
|
---|
| 218 | //コンストラクタかどうかをチェック
|
---|
| 219 | for(i2=0;;i++,i2++){
|
---|
| 220 | if(!IsVariableChar(buffer[i])){
|
---|
| 221 | temporary[i2]=0;
|
---|
| 222 | break;
|
---|
| 223 | }
|
---|
| 224 | temporary[i2]=buffer[i];
|
---|
| 225 | }
|
---|
| 226 | if(lstrcmp(temporary,ClassName)==0) bConstructor=1;
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 | }
|
---|
| 230 | }
|
---|
[75] | 231 | void ChangeCommand(char *buffer,int nowLine,char *Command){
|
---|
[4] | 232 | int i,i2,IsStr;
|
---|
| 233 | unsigned _int16 ComNum;
|
---|
| 234 | char com[8192],pam[8192];
|
---|
| 235 |
|
---|
[42] | 236 | static int nCountOfNonGlobalScope = 0;
|
---|
| 237 |
|
---|
[4] | 238 | if(Command[0]==1){
|
---|
| 239 | switch(Command[1]){
|
---|
| 240 | case ESC_SELECTCASE:
|
---|
| 241 | case ESC_CASE:
|
---|
| 242 | KillStringSpaces(Command+2);
|
---|
| 243 | break;
|
---|
| 244 | case ESC_WITH:
|
---|
| 245 | KillStringSpaces(Command+2);
|
---|
| 246 | break;
|
---|
| 247 | case ESC_TYPEDEF:
|
---|
| 248 | KillStringSpaces(Command+2);
|
---|
| 249 | break;
|
---|
| 250 | case ESC_DECLARE:
|
---|
| 251 | KillStringSpaces(Command+2);
|
---|
| 252 | break;
|
---|
| 253 | case ESC_IF:
|
---|
| 254 | KillStringSpaces(Command+2);
|
---|
| 255 | break;
|
---|
| 256 |
|
---|
| 257 | case ESC_CLASS:
|
---|
| 258 | KillStringSpaces(Command+2);
|
---|
[92] | 259 | i2 = 2;
|
---|
[322] | 260 | if( Command[i2] == 1 && Command[i2+1] == ESC_ENUM )
|
---|
| 261 | {
|
---|
[92] | 262 | i2 += 2;
|
---|
| 263 | }
|
---|
[322] | 264 | else if( Command[i2] == 1 && Command[i2+1] == ESC_DELEGATE )
|
---|
| 265 | {
|
---|
| 266 | i2 += 2;
|
---|
| 267 | }
|
---|
| 268 | else if( memicmp( Command + i2, "Blittable(", 10 ) == 0 )
|
---|
| 269 | {
|
---|
[128] | 270 | i2 += 10;
|
---|
| 271 | i2 = JumpStringInPare(Command,i2)+1;
|
---|
| 272 | }
|
---|
[4] | 273 |
|
---|
[290] | 274 | // クラス名を取得
|
---|
| 275 | char className[VN_SIZE];
|
---|
| 276 | GetIdentifierToken( className, Command, i2 );
|
---|
| 277 |
|
---|
[4] | 278 | //コンストラクタ、デストラクタを暗黙的に生成
|
---|
[290] | 279 | MakeConstructorAndDestructor(buffer,nowLine,className);
|
---|
[4] | 280 | break;
|
---|
| 281 | case ESC_INTERFACE:
|
---|
| 282 | KillStringSpaces(Command+2);
|
---|
| 283 | break;
|
---|
| 284 | case ESC_ENDCLASS:
|
---|
| 285 | if(ConstructorDestructorSchedule[0]){
|
---|
| 286 | //生成されたコンストラクタ、デストラクタを挿入
|
---|
| 287 | sprintf(Command,"%s%c%c",ConstructorDestructorSchedule,1,ESC_ENDCLASS);
|
---|
| 288 | }
|
---|
| 289 | break;
|
---|
| 290 |
|
---|
| 291 | case ESC_TYPE:
|
---|
| 292 | KillStringSpaces(Command+2);
|
---|
| 293 | break;
|
---|
[42] | 294 |
|
---|
[43] | 295 | case ESC_CONST:
|
---|
| 296 | KillStringSpaces(Command+2);
|
---|
| 297 | if( Command[2] == 1 && Command[3] == ESC_ENUM ){
|
---|
| 298 | nCountOfNonGlobalScope++;
|
---|
| 299 | }
|
---|
| 300 | break;
|
---|
| 301 |
|
---|
[4] | 302 | case ESC_ENUM:
|
---|
[42] | 303 | nCountOfNonGlobalScope++;
|
---|
| 304 | KillStringSpaces(Command+2);
|
---|
| 305 | break;
|
---|
| 306 |
|
---|
| 307 | case ESC_ENDENUM:
|
---|
| 308 | nCountOfNonGlobalScope--;
|
---|
| 309 | break;
|
---|
| 310 |
|
---|
[4] | 311 | case ESC_INHERITS:
|
---|
[340] | 312 | case ESC_IMPLEMENTS:
|
---|
[4] | 313 | case ESC_VIRTUAL:
|
---|
| 314 | case ESC_OVERRIDE:
|
---|
| 315 | case ESC_ABSTRACT:
|
---|
| 316 | case ESC_SUB:
|
---|
| 317 | case ESC_FUNCTION:
|
---|
| 318 | case ESC_MACRO:
|
---|
| 319 | case ESC_STATIC:
|
---|
[100] | 320 | case ESC_NAMESPACE:
|
---|
[107] | 321 | case ESC_IMPORTS:
|
---|
[322] | 322 | case ESC_DELEGATE:
|
---|
[361] | 323 | case ESC_CATCH:
|
---|
| 324 | case ESC_THROW:
|
---|
[4] | 325 | KillStringSpaces(Command+2);
|
---|
| 326 | break;
|
---|
| 327 | }
|
---|
| 328 | return;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
[37] | 331 | bool isPare = false;
|
---|
[4] | 332 | for(i=0;;i++){
|
---|
| 333 | if(Command[i]==' '||Command[i]=='\t'||Command[i]=='('||Command[i]=='\"'||Command[i]=='@'||Command[i]=='-'){
|
---|
| 334 | com[i]=0;
|
---|
| 335 | while(Command[i]==' '||Command[i]=='\t') i++;
|
---|
[37] | 336 | if( Command[i] == '(' ) isPare = true;
|
---|
[4] | 337 | break;
|
---|
| 338 | }
|
---|
| 339 | if(Command[i]=='='){
|
---|
| 340 | KillStringSpaces(Command);
|
---|
| 341 | return;
|
---|
| 342 | }
|
---|
| 343 | com[i]=Command[i];
|
---|
| 344 | if(Command[i]=='\0') break;
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | //マクロによるコマンド
|
---|
| 348 | i2=1;
|
---|
[42] | 349 | if( nCountOfNonGlobalScope == 0 ){
|
---|
| 350 | //グローバル
|
---|
[75] | 351 | if(lstrcmpi(com,"Open")==0) ComOpen(Command+i,pam,nowLine);
|
---|
[42] | 352 | else if(lstrcmpi(com,"Close")==0) ComClose(Command+i,pam);
|
---|
| 353 | else if(lstrcmpi(com,"Field")==0||
|
---|
| 354 | lstrcmpi(com,"Get")==0||
|
---|
| 355 | lstrcmpi(com,"Put")==0) ComField(Command+i,pam);
|
---|
[75] | 356 | else if(lstrcmpi(com,"Line")==0) ComLine(Command+i,pam,nowLine);
|
---|
| 357 | else if(lstrcmpi(com,"Circle")==0) ComCircle(Command+i,pam,nowLine);
|
---|
| 358 | else if(lstrcmpi(com,"PSet")==0) ComPSet(Command+i,pam,nowLine);
|
---|
| 359 | else if(lstrcmpi(com,"Paint")==0) ComPaint(Command+i,pam,nowLine);
|
---|
[4] | 360 |
|
---|
[42] | 361 | else if(
|
---|
| 362 | lstrcmpi(com,"EXEC")==0||
|
---|
| 363 | lstrcmpi(com,"INPUT")==0||
|
---|
| 364 | lstrcmpi(com,"PRINT")==0||
|
---|
| 365 | lstrcmpi(com,"RANDOMIZE")==0||
|
---|
| 366 | ( lstrcmpi(com,"WRITE")==0 && isPare == false )||
|
---|
| 367 | lstrcmpi(com,"MSGBOX")==0||
|
---|
| 368 | lstrcmpi(com,"WINDOW")==0||
|
---|
| 369 | lstrcmpi(com,"DELWND")==0||
|
---|
| 370 | lstrcmpi(com,"INSMENU")==0||
|
---|
| 371 | lstrcmpi(com,"CHDIR")==0||
|
---|
| 372 | lstrcmpi(com,"MKDIR")==0||
|
---|
| 373 | lstrcmpi(com,"KILL")==0||
|
---|
| 374 | lstrcmpi(com,"CLS")==0||
|
---|
| 375 | lstrcmpi(com,"COLOR")==0||
|
---|
| 376 | lstrcmpi(com,"LOCATE")==0
|
---|
| 377 | ){
|
---|
| 378 | KillSpaces(Command+i,pam);
|
---|
[4] | 379 |
|
---|
[42] | 380 | //大文字に変換
|
---|
| 381 | CharUpper(com);
|
---|
[4] | 382 |
|
---|
[42] | 383 | sprintf(Command,"%s(%s)",com,pam);
|
---|
| 384 | return;
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | else i2=0;
|
---|
[4] | 388 | }
|
---|
| 389 | else i2=0;
|
---|
| 390 | if(i2){
|
---|
| 391 | //大文字に変換
|
---|
| 392 | CharUpper(com);
|
---|
| 393 |
|
---|
| 394 | sprintf(Command,"%s(%s)",com,pam);
|
---|
| 395 | return;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 |
|
---|
| 399 |
|
---|
| 400 | //コンパイラに搭載されるコマンド
|
---|
| 401 | if(lstrcmpi(com,"Do")==0){
|
---|
| 402 | KillSpaces(Command+i,pam);
|
---|
| 403 | ComNum=COM_DO;
|
---|
| 404 | }
|
---|
| 405 | else if(lstrcmpi(com,"goto")==0){
|
---|
| 406 | KillSpaces(Command+i,pam);
|
---|
| 407 | ComNum=COM_GOTO;
|
---|
| 408 | }
|
---|
| 409 | else if(lstrcmpi(com,"gosub")==0){
|
---|
| 410 | KillSpaces(Command+i,pam);
|
---|
| 411 | ComNum=COM_GOSUB;
|
---|
| 412 | }
|
---|
| 413 | else if(lstrcmpi(com,"Loop")==0){
|
---|
| 414 | 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')){
|
---|
| 415 | lstrcpy(pam,"0,");
|
---|
| 416 | KillSpaces(Command+i+5,pam+2);
|
---|
| 417 | }
|
---|
| 418 | 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')){
|
---|
| 419 | lstrcpy(pam,"1,");
|
---|
| 420 | KillSpaces(Command+i+5,pam+2);
|
---|
| 421 | }
|
---|
| 422 | else pam[0]=0;
|
---|
| 423 | ComNum=COM_LOOP;
|
---|
| 424 | }
|
---|
| 425 | else if(lstrcmpi(com,"For")==0){
|
---|
| 426 | for(i2=0,IsStr=0;;i++,i2++){
|
---|
| 427 | while(Command[i]==' '||Command[i]=='\t') i++;
|
---|
| 428 | if(Command[i]=='\"') IsStr^=1;
|
---|
| 429 | 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){
|
---|
| 430 | pam[i2]=',';
|
---|
| 431 | break;
|
---|
| 432 | }
|
---|
| 433 | pam[i2]=Command[i];
|
---|
| 434 | if(Command[i]=='\0') break;
|
---|
| 435 | }
|
---|
| 436 | if(Command[i]){
|
---|
| 437 | for(i+=3,i2++,IsStr=0;;i++,i2++){
|
---|
| 438 | while(Command[i]==' '||Command[i]=='\t') i++;
|
---|
| 439 | 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')){
|
---|
| 440 | pam[i2]=',';
|
---|
| 441 | i+=4;
|
---|
| 442 | continue;
|
---|
| 443 | }
|
---|
| 444 | pam[i2]=Command[i];
|
---|
| 445 | if(Command[i]=='\0') break;
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | ComNum=COM_FOR;
|
---|
| 449 | }
|
---|
[381] | 450 | else if(lstrcmpi(com,"Foreach")==0)
|
---|
| 451 | {
|
---|
| 452 | for(i2=0,IsStr=0;;i++,i2++)
|
---|
| 453 | {
|
---|
| 454 | while(Command[i]==' '||Command[i]=='\t') i++;
|
---|
| 455 | if(Command[i]=='\"') IsStr^=1;
|
---|
| 456 | if((Command[i-1]==' '||Command[i-1]=='\t')&&(Command[i]=='i'||Command[i]=='I')&&(Command[i+1]=='n'||Command[i+1]=='N')&&(Command[i+2]==' '||Command[i+2]=='\t')&&IsStr==0){
|
---|
| 457 | pam[i2++] = 1;
|
---|
| 458 | pam[i2] = ESC_IN;
|
---|
| 459 | break;
|
---|
| 460 | }
|
---|
| 461 | pam[i2]=Command[i];
|
---|
| 462 | if(Command[i]=='\0') break;
|
---|
| 463 | }
|
---|
| 464 | if(Command[i])
|
---|
| 465 | {
|
---|
| 466 | lstrcpy( pam + i2 + 1, Command + i + 3 );
|
---|
| 467 | }
|
---|
[372] | 468 | ComNum=COM_FOREACH;
|
---|
| 469 | }
|
---|
[4] | 470 | else if(lstrcmpi(com,"Next")==0){
|
---|
| 471 | KillSpaces(Command+i,pam);
|
---|
| 472 | ComNum=COM_NEXT;
|
---|
| 473 | }
|
---|
| 474 | else if(lstrcmpi(com,"Return")==0){
|
---|
| 475 | KillSpaces(Command+i,pam);
|
---|
| 476 | ComNum=COM_RETURN;
|
---|
| 477 | }
|
---|
| 478 | else if(lstrcmpi(com,"While")==0){
|
---|
| 479 | KillSpaces(Command+i,pam);
|
---|
| 480 | ComNum=COM_WHILE;
|
---|
| 481 | }
|
---|
| 482 | else if(lstrcmpi(com,"Wend")==0){
|
---|
| 483 | pam[0]=0;
|
---|
| 484 | ComNum=COM_WEND;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 | //変数、データ操作
|
---|
| 488 | else if(lstrcmpi(com,"dim")==0){
|
---|
| 489 | KillSpaces(Command+i,pam);
|
---|
| 490 | ComNum=COM_DIM;
|
---|
| 491 | }
|
---|
| 492 | else if(lstrcmpi(com,"Delete")==0){
|
---|
| 493 | KillSpaces(Command+i,pam);
|
---|
| 494 | ComNum=COM_DELETE;
|
---|
| 495 | }
|
---|
[64] | 496 | else if( lstrcmpi( com, "_System_SweepingDelete" ) == 0 ){
|
---|
| 497 | KillSpaces(Command+i,pam);
|
---|
| 498 | ComNum=COM_SWEEPINGDELETE;
|
---|
| 499 | }
|
---|
[4] | 500 |
|
---|
| 501 | //その他
|
---|
| 502 | else if(lstrcmpi(com,"Debug")==0){
|
---|
| 503 | pam[0]=0;
|
---|
| 504 | ComNum=COM_DEBUG;
|
---|
| 505 | }
|
---|
| 506 | else if(lstrcmpi(com,"let")==0){
|
---|
| 507 | KillSpaces(Command+i,pam);
|
---|
| 508 | ComNum=COM_LET;
|
---|
| 509 | }
|
---|
| 510 | else if(lstrcmpi(com,"rem")==0){
|
---|
| 511 | Command[0]=0;
|
---|
| 512 | return;
|
---|
| 513 | }
|
---|
| 514 |
|
---|
| 515 | //ポインタ
|
---|
| 516 | else if(lstrcmpi(com,"SetDouble")==0){
|
---|
| 517 | KillSpaces(Command+i,pam);
|
---|
| 518 | ComNum=COM_SETDOUBLE;
|
---|
| 519 | }
|
---|
| 520 | else if(lstrcmpi(com,"SetSingle")==0){
|
---|
| 521 | KillSpaces(Command+i,pam);
|
---|
| 522 | ComNum=COM_SETSINGLE;
|
---|
| 523 | }
|
---|
| 524 | else if(lstrcmpi(com,"SetQWord")==0){
|
---|
| 525 | KillSpaces(Command+i,pam);
|
---|
| 526 | ComNum=COM_SETQWORD;
|
---|
| 527 | }
|
---|
| 528 | else if(lstrcmpi(com,"SetDWord")==0){
|
---|
| 529 | KillSpaces(Command+i,pam);
|
---|
| 530 | ComNum=COM_SETDWORD;
|
---|
| 531 | }
|
---|
| 532 | else if(lstrcmpi(com,"SetWord")==0){
|
---|
| 533 | KillSpaces(Command+i,pam);
|
---|
| 534 | ComNum=COM_SETWORD;
|
---|
| 535 | }
|
---|
| 536 | else if(lstrcmpi(com,"SetByte")==0){
|
---|
| 537 | KillSpaces(Command+i,pam);
|
---|
| 538 | ComNum=COM_SETBYTE;
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 | else{
|
---|
| 542 | //その他のコマンド(一般コード)
|
---|
| 543 | lstrcpy(com,Command);
|
---|
| 544 | KillSpaces(com,Command);
|
---|
| 545 | return;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | i=lstrlen(pam);
|
---|
| 549 | while(pam[i-1]==' '||pam[i-1]=='\t') i--;
|
---|
| 550 | pam[i]=0;
|
---|
| 551 | if(pam[0]) sprintf(Command,"%c%c%s",HIBYTE(ComNum),LOBYTE(ComNum),pam);
|
---|
| 552 | else sprintf(Command,"%c%c",HIBYTE(ComNum),LOBYTE(ComNum));
|
---|
| 553 |
|
---|
| 554 | return;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | void ChangeCommandToCode(char *buffer){
|
---|
| 558 | extern HANDLE hHeap;
|
---|
| 559 | int i,i2,i3,IsStr,CommandBufferSize;
|
---|
| 560 | char *temporary,*tempBase,temp2[VN_SIZE],*lpCommand;
|
---|
| 561 |
|
---|
| 562 | tempBase=(char *)HeapAlloc(hHeap,0,(lstrlen(buffer)+1)*2+8192);
|
---|
| 563 | temporary=tempBase+1;
|
---|
| 564 | temporary[0]=0;
|
---|
| 565 | i=0;
|
---|
| 566 | i3=0;
|
---|
| 567 |
|
---|
| 568 | CommandBufferSize=512;
|
---|
| 569 | lpCommand=(char *)HeapAlloc(hHeap,0,CommandBufferSize);
|
---|
| 570 |
|
---|
| 571 | while(1){
|
---|
| 572 | i2=0;
|
---|
| 573 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
| 574 | while(buffer[i]>='0'&&buffer[i]<='9'){
|
---|
| 575 | temp2[i2]=buffer[i];
|
---|
| 576 | i++;
|
---|
| 577 | i2++;
|
---|
| 578 | }
|
---|
| 579 | temp2[i2]=0;
|
---|
| 580 | while(buffer[i]==' '||buffer[i]=='\t') i++;
|
---|
| 581 | for(i2=0,IsStr=0;;i++,i2++){
|
---|
| 582 | if(i2>=CommandBufferSize){ //バッファ領域が足りなくなった場合はバッファを増量する
|
---|
| 583 | CommandBufferSize+=512;
|
---|
| 584 | lpCommand=(char *)HeapReAlloc(hHeap,0,lpCommand,CommandBufferSize);
|
---|
| 585 | }
|
---|
| 586 | if(buffer[i]=='\"') IsStr^=1;
|
---|
| 587 | if(buffer[i]=='\n'||(buffer[i]==':'&&IsStr==0)||buffer[i]=='\0'){
|
---|
| 588 | lpCommand[i2]=0;
|
---|
| 589 |
|
---|
| 590 | if(temp2[0]){
|
---|
| 591 | //行番号ラベル
|
---|
| 592 | sprintf(temporary+i3,"%c%c%s,",1,ESC_LINENUM,temp2);
|
---|
| 593 | i3+=lstrlen(temporary+i3);
|
---|
| 594 |
|
---|
| 595 | temp2[0]=0;
|
---|
| 596 | }
|
---|
| 597 |
|
---|
| 598 | //命令コードへ変換
|
---|
| 599 | if(i2){
|
---|
| 600 | //エラー用
|
---|
| 601 | extern int cp;
|
---|
| 602 | cp=i;
|
---|
| 603 |
|
---|
| 604 | ChangeCommand(buffer,i,lpCommand);
|
---|
| 605 |
|
---|
| 606 | lstrcpy(temporary+i3,lpCommand);
|
---|
| 607 | i3+=lstrlen(temporary+i3);
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | if(!(lpCommand[0]=='\0'&&buffer[i]==':')){
|
---|
| 611 | temporary[i3++]=buffer[i];
|
---|
| 612 | temporary[i3]=0;
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | if(buffer[i]=='\n'){
|
---|
| 616 | i++;
|
---|
| 617 | break;
|
---|
| 618 | }
|
---|
| 619 | else if(buffer[i]==':'){
|
---|
| 620 | while(buffer[i+1]==' '||buffer[i+1]=='\t') i++;
|
---|
| 621 | }
|
---|
| 622 | if(buffer[i]=='\0') break;
|
---|
| 623 | i2=-1;
|
---|
| 624 | continue;
|
---|
| 625 | }
|
---|
| 626 | lpCommand[i2]=buffer[i];
|
---|
| 627 | }
|
---|
| 628 | if(buffer[i]=='\0') break;
|
---|
| 629 | }
|
---|
| 630 | HeapDefaultFree(lpCommand);
|
---|
| 631 | lstrcpy(buffer,temporary);
|
---|
| 632 |
|
---|
| 633 | HeapDefaultFree(tempBase);
|
---|
| 634 | }
|
---|