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