Changeset 542 in dev for trunk/ab5.0/abdev/BasicCompiler_Common
- Timestamp:
- May 4, 2008, 1:09:11 AM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/MakeExe.cpp
r541 r542 43 43 extern BOOL bStopCompile; 44 44 extern HWND hMainDlg; 45 int i3;46 45 char temp2[MAX_PATH]; 47 46 -
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r531 r542 30 30 static void CollectClassesForNameOnly( const char *source, Classes &classes ); 31 31 32 // TypeDefを収集する 33 static void AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine ); 34 static void CollectTypeDefs( const char *source, TypeDefCollection &typeDefs ); 35 32 36 // クラスを収集する 33 37 static void AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, -
trunk/ab5.0/abdev/BasicCompiler_Common/include/TypeDef.h
r524 r542 23 23 24 24 public: 25 TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, int nowLine );25 TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, const Type &baseType ); 26 26 TypeDef() 27 27 { … … 61 61 int GetIndex( const NamespaceScopes &namespaceScopes, const std::string &name ) const; 62 62 int GetIndex( const std::string &fullName ) const; 63 64 private:65 void Add( const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine );66 public:67 void CollectTypeDefs();68 63 }; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp
r531 r542 237 237 } 238 238 239 void LexicalAnalyzer::AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine ) 240 { 241 int i; 242 char temporary[VN_SIZE]; 243 244 for(i=0;;i++){ 245 if(expression[i]=='='||expression[i]=='\0'){ 246 temporary[i]=0; 247 break; 248 } 249 temporary[i]=expression[i]; 250 } 251 252 if(expression[i]!='='){ 253 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 254 return; 255 } 256 257 const char *pTemp=expression.c_str()+i+1; 258 259 //識別文字のエラーチェック(新しい型) 260 i=0; 261 for(;;i++){ 262 if(temporary[i]=='\0') break; 263 if( !( IsVariableChar( temporary[i], true) ) ){ 264 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 265 return; 266 } 267 } 268 269 //識別文字のエラーチェック(コピー元の型) 270 if(pTemp[0]=='*'&&pTemp[1]==1&&(pTemp[2]==ESC_FUNCTION||pTemp[2]==ESC_SUB)){ 271 //関数ポインタ 272 if(pTemp[3]!='('){ 273 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 274 return; 275 } 276 } 277 else{ 278 i=0; 279 while(pTemp[i]=='*') i++; 280 for(;;i++){ 281 if(pTemp[i]=='\0') break; 282 if( !( IsVariableChar( pTemp[i], true) ) ) 283 { 284 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 285 return; 286 } 287 } 288 } 289 290 //識別子が重複している場合はエラーにする 291 if(lstrcmp(temporary,pTemp)==0){ 292 compiler.errorMessenger.Output(1,NULL,nowLine); 293 return; 294 } 295 296 297 298 ////////////////////////// 299 // TypeDef情報を追加 300 ////////////////////////// 301 302 Type baseType; 303 if( !compiler.StringToType( pTemp, baseType ) ) 304 { 305 compiler.errorMessenger.Output(3, pTemp, nowLine ); 306 return; 307 } 308 309 typeDefs.push_back( 310 TypeDef( 311 namespaceScopes, 312 temporary, 313 pTemp, 314 baseType 315 ) 316 ); 317 } 318 void LexicalAnalyzer::CollectTypeDefs( const char *source, TypeDefCollection &typeDefs ) 319 { 320 // 名前空間管理 321 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); 322 namespaceScopes.clear(); 323 324 // Importsされた名前空間の管理 325 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces(); 326 importedNamespaces.clear(); 327 328 int i=-1, i2; 329 char temporary[VN_SIZE]; 330 while(1){ 331 extern char *basbuf; 332 333 i++; 334 335 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){ 336 for(i+=2,i2=0;;i2++,i++){ 337 if( IsCommandDelimitation( basbuf[i] ) ){ 338 temporary[i2]=0; 339 break; 340 } 341 temporary[i2]=basbuf[i]; 342 } 343 namespaceScopes.push_back( temporary ); 344 345 continue; 346 } 347 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){ 348 if( namespaceScopes.size() <= 0 ){ 349 compiler.errorMessenger.Output(12, "End Namespace", i ); 350 } 351 else{ 352 namespaceScopes.pop_back(); 353 } 354 355 i += 2; 356 continue; 357 } 358 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){ 359 for(i+=2,i2=0;;i2++,i++){ 360 if( IsCommandDelimitation( basbuf[i] ) ){ 361 temporary[i2]=0; 362 break; 363 } 364 temporary[i2]=basbuf[i]; 365 } 366 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) ) 367 { 368 compiler.errorMessenger.Output(64,temporary,i ); 369 } 370 371 continue; 372 } 373 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){ 374 importedNamespaces.clear(); 375 continue; 376 } 377 378 if( basbuf[i]==1 ){ 379 char temporary[VN_SIZE]; 380 if(basbuf[i+1]==ESC_TYPEDEF){ 381 int i2 = 0; 382 for(i+=2;;i2++,i++){ 383 if(basbuf[i]=='\n'){ 384 temporary[i2]=0; 385 break; 386 } 387 temporary[i2]=basbuf[i]; 388 if(basbuf[i]=='\0') break; 389 } 390 AddTypeDef( typeDefs, namespaceScopes, temporary, i ); 391 392 continue; 393 } 394 else if( basbuf[i+1] == ESC_CONST && basbuf[i+2] == 1 && basbuf[i+3] == ESC_ENUM ){ 395 int i2 = 0; 396 for(i+=4;;i2++,i++){ 397 if(!IsVariableChar(basbuf[i])){ 398 temporary[i2]=0; 399 break; 400 } 401 temporary[i2]=basbuf[i]; 402 if(basbuf[i]=='\0') break; 403 } 404 405 Type baseType; 406 if( !compiler.StringToType( "Long", baseType ) ) 407 { 408 throw; 409 } 410 411 typeDefs.push_back( 412 TypeDef( 413 namespaceScopes, 414 temporary, 415 "Long", 416 baseType 417 ) 418 ); 419 } 420 } 421 422 //次の行 423 for(;;i++){ 424 if(IsCommandDelimitation(basbuf[i])) break; 425 } 426 if(basbuf[i]=='\0') break; 427 } 428 } 429 239 430 UserProc* LexicalAnalyzer::ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName ) 240 431 { -
trunk/ab5.0/abdev/BasicCompiler_Common/src/TypeDef.cpp
r523 r542 4 4 #include <Compiler.h> 5 5 6 TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, int nowLine )6 TypeDef::TypeDef( const NamespaceScopes &namespaceScopes, const std::string &name, const std::string &baseName, const Type &baseType ) 7 7 : Symbol( namespaceScopes, name ) 8 8 , baseName( baseName ) 9 , baseType( baseType ) 9 10 { 10 if( !compiler.StringToType( baseName, baseType ) ){11 compiler.errorMessenger.Output(3, baseName, nowLine );12 return;13 }14 11 } 15 12 /* … … 56 53 this->push_back( typeDef ); 57 54 } 55 58 56 int TypeDefCollection::GetIndex( const NamespaceScopes &namespaceScopes, const std::string &name ) const{ 59 57 int max = (int)(*this).size(); … … 72 70 return GetIndex( NamespaceScopes( AreaName ), NestName ); 73 71 } 74 75 void TypeDefCollection::Add( const NamespaceScopes &namespaceScopes, const std::string &expression, int nowLine ){76 int i;77 char temporary[VN_SIZE];78 79 for(i=0;;i++){80 if(expression[i]=='='||expression[i]=='\0'){81 temporary[i]=0;82 break;83 }84 temporary[i]=expression[i];85 }86 87 if(expression[i]!='='){88 compiler.errorMessenger.Output(10,"TypeDef",nowLine);89 return;90 }91 92 const char *pTemp=expression.c_str()+i+1;93 94 //識別文字のエラーチェック(新しい型)95 i=0;96 for(;;i++){97 if(temporary[i]=='\0') break;98 if( !( IsVariableChar( temporary[i], true) ) ){99 compiler.errorMessenger.Output(10,"TypeDef",nowLine);100 return;101 }102 }103 104 //識別文字のエラーチェック(コピー元の型)105 if(pTemp[0]=='*'&&pTemp[1]==1&&(pTemp[2]==ESC_FUNCTION||pTemp[2]==ESC_SUB)){106 //関数ポインタ107 if(pTemp[3]!='('){108 compiler.errorMessenger.Output(10,"TypeDef",nowLine);109 return;110 }111 }112 else{113 i=0;114 while(pTemp[i]=='*') i++;115 for(;;i++){116 if(pTemp[i]=='\0') break;117 if( !( IsVariableChar( pTemp[i], true) ) )118 {119 compiler.errorMessenger.Output(10,"TypeDef",nowLine);120 return;121 }122 }123 }124 125 //識別子が重複している場合はエラーにする126 if(lstrcmp(temporary,pTemp)==0){127 compiler.errorMessenger.Output(1,NULL,nowLine);128 return;129 }130 131 132 133 //////////////////////////134 // TypeDef情報を追加135 //////////////////////////136 137 Add( namespaceScopes, temporary, pTemp, nowLine );138 }139 140 void TypeDefCollection::CollectTypeDefs(){141 142 // 名前空間管理143 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();144 namespaceScopes.clear();145 146 // Importsされた名前空間の管理147 NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();148 importedNamespaces.clear();149 150 int i=-1, i2;151 char temporary[VN_SIZE];152 while(1){153 extern char *basbuf;154 155 i++;156 157 if( basbuf[i] == 1 && basbuf[i+1] == ESC_NAMESPACE ){158 for(i+=2,i2=0;;i2++,i++){159 if( IsCommandDelimitation( basbuf[i] ) ){160 temporary[i2]=0;161 break;162 }163 temporary[i2]=basbuf[i];164 }165 namespaceScopes.push_back( temporary );166 167 continue;168 }169 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_ENDNAMESPACE ){170 if( namespaceScopes.size() <= 0 ){171 compiler.errorMessenger.Output(12, "End Namespace", i );172 }173 else{174 namespaceScopes.pop_back();175 }176 177 i += 2;178 continue;179 }180 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_IMPORTS ){181 for(i+=2,i2=0;;i2++,i++){182 if( IsCommandDelimitation( basbuf[i] ) ){183 temporary[i2]=0;184 break;185 }186 temporary[i2]=basbuf[i];187 }188 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )189 {190 compiler.errorMessenger.Output(64,temporary,i );191 }192 193 continue;194 }195 else if( basbuf[i] == 1 && basbuf[i+1] == ESC_CLEARNAMESPACEIMPORTED ){196 importedNamespaces.clear();197 continue;198 }199 200 if( basbuf[i]==1 ){201 char temporary[VN_SIZE];202 if(basbuf[i+1]==ESC_TYPEDEF){203 int i2 = 0;204 for(i+=2;;i2++,i++){205 if(basbuf[i]=='\n'){206 temporary[i2]=0;207 break;208 }209 temporary[i2]=basbuf[i];210 if(basbuf[i]=='\0') break;211 }212 Add( namespaceScopes, temporary, i );213 214 continue;215 }216 else if( basbuf[i+1] == ESC_CONST && basbuf[i+2] == 1 && basbuf[i+3] == ESC_ENUM ){217 int i2 = 0;218 for(i+=4;;i2++,i++){219 if(!IsVariableChar(basbuf[i])){220 temporary[i2]=0;221 break;222 }223 temporary[i2]=basbuf[i];224 if(basbuf[i]=='\0') break;225 }226 Add( namespaceScopes, temporary, "Long", i );227 }228 }229 230 //次の行231 for(;;i++){232 if(IsCommandDelimitation(basbuf[i])) break;233 }234 if(basbuf[i]=='\0') break;235 }236 }
Note:
See TracChangeset
for help on using the changeset viewer.