- Timestamp:
- May 6, 2008, 9:10:21 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r568 r571 55 55 56 56 // グローバルプロシージャを収集する 57 static bool AnalyzeParameter( Parameters ¶ms, const char *sourceOfParams, int nowLine );57 static bool AnalyzeParameter( Parameters ¶ms, const Jenga::Common::Strings ¶meterStrings, int nowLine ); 58 58 static UserProc* ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL ); 59 59 static void CollectProcedures( const char *source, UserProcs &userProcs, DllProcs &dllProcs ); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp
r568 r571 9 9 10 10 // パラメータを解析 11 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( params, paramStr.c_str(), sourceIndex ); 11 Jenga::Common::Strings parameterStrings; 12 SplitParameter( paramStr, parameterStrings ); 13 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( params, parameterStrings, sourceIndex ); 12 14 13 15 // 動的パラメータを作る -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Procedure.cpp
r568 r571 3 3 using namespace ActiveBasic::Compiler; 4 4 5 bool LexicalAnalyzer::AnalyzeParameter( Parameters ¶ms, const char *sourceOfParams, int nowLine )5 bool LexicalAnalyzer::AnalyzeParameter( Parameters ¶ms, const Jenga::Common::Strings ¶meterStrings, int nowLine ) 6 6 { 7 7 int i2,i3,sw; … … 9 9 10 10 //パラメータ 11 int i = 0; 12 while(1){ 13 if( sourceOfParams[i] == '\0' ) 11 BOOST_FOREACH( const std::string ¶mStr, parameterStrings ) 12 { 13 int i = 0; 14 15 if( paramStr[i] == '\0' ) 14 16 { 15 17 break; … … 18 20 //ByRef 19 21 bool isRef; 20 if( sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){22 if(paramStr[i]==1&¶mStr[i+1]==ESC_BYVAL){ 21 23 isRef = false; 22 24 i+=2; 23 25 } 24 else if( sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){26 else if(paramStr[i]==1&¶mStr[i+1]==ESC_BYREF){ 25 27 isRef = true; 26 28 i+=2; … … 34 36 sw=0; 35 37 for(i2=0;;i++,i2++){ 36 if( sourceOfParams[i]=='('){38 if(paramStr[i]=='('){ 37 39 if(!sw) sw=1; 38 40 39 i3=GetStringInPare(name+i2, sourceOfParams+i);41 i3=GetStringInPare(name+i2,paramStr.c_str()+i); 40 42 i2+=i3-1; 41 43 i+=i3-1; 42 44 continue; 43 45 } 44 if( sourceOfParams[i]=='['){46 if(paramStr[i]=='['){ 45 47 if(!sw) sw=1; 46 48 47 i3=GetStringInBracket(name+i2, sourceOfParams+i);49 i3=GetStringInBracket(name+i2,paramStr.c_str()+i); 48 50 i2+=i3-1; 49 51 i+=i3-1; 50 52 continue; 51 53 } 52 if(!IsVariableChar( sourceOfParams[i])){54 if(!IsVariableChar(paramStr[i])){ 53 55 name[i2]=0; 54 56 break; 55 57 } 56 name[i2]= sourceOfParams[i];58 name[i2]=paramStr[i]; 57 59 } 58 60 if(sw){ … … 81 83 Type type( DEF_NON ); 82 84 char initValue[8192] = ""; 83 if( sourceOfParams[i] == '=' ){85 if( paramStr[i] == '=' ){ 84 86 i++; 85 i = GetOneParameter( sourceOfParams, i, initValue );87 i = GetOneParameter( paramStr.c_str(), i, initValue ); 86 88 87 89 // TODO: エラー用 fix me!!! … … 95 97 } 96 98 } 97 else if( sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){99 else if(paramStr[i]==1&¶mStr[i+1]==ESC_AS){ 98 100 // As指定 99 101 i+=2; 100 102 101 103 i2=0; 102 while( sourceOfParams[i]=='*'){103 temporary[i2]= sourceOfParams[i];104 while(paramStr[i]=='*'){ 105 temporary[i2]=paramStr[i]; 104 106 i++; 105 107 i2++; 106 108 } 107 109 for(;;i++,i2++){ 108 if(!IsVariableChar( sourceOfParams[i])){109 if( sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){110 temporary[i2++]= sourceOfParams[i++];111 temporary[i2]= sourceOfParams[i];110 if(!IsVariableChar(paramStr[i])){ 111 if(paramStr[i]==1&&(paramStr[i+1]==ESC_FUNCTION||paramStr[i+1]==ESC_SUB)){ 112 temporary[i2++]=paramStr[i++]; 113 temporary[i2]=paramStr[i]; 112 114 continue; 113 115 } … … 115 117 break; 116 118 } 117 temporary[i2]= sourceOfParams[i];119 temporary[i2]=paramStr[i]; 118 120 } 119 121 … … 144 146 //パラメータを追加 145 147 params.push_back( pParam ); 146 147 if( sourceOfParams[i] == ',' )148 {149 i++;150 continue;151 }152 else if( sourceOfParams[i] == '\0' )153 {154 break;155 }156 else{157 compiler.errorMessenger.Output(1,NULL,nowLine);158 break;159 }160 148 } 161 149 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Procedure.cpp
r537 r571 98 98 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){ 99 99 int i = 0; 100 int i2,i3,sw;101 char temporary[8192],temp2[VN_SIZE];102 100 103 101 //ソースコードの位置 … … 146 144 } 147 145 148 // パラメータを分割149 146 Jenga::Common::Strings parameters; 147 148 // パラメータ 150 149 SplitParameter( parametersStr1, parameters ); 151 BOOST_FOREACH( const std::string ¶mStr, parameters ) 152 { 153 int i = 0; 154 155 bool isRef = false; 156 if( paramStr[i] == 1 ) 157 { 158 if( paramStr[i+1] == ESC_BYVAL ) 159 { 160 isRef = false; 161 i += 2; 162 } 163 else if( paramStr[i+1] == ESC_BYREF ) 164 { 165 isRef = true; 166 i += 2; 167 } 168 } 169 170 //パラメータ名 171 bool isArray = false; 172 Subscripts subscripts; 173 char name[VN_SIZE]; 174 sw=0; 175 for(i2=0;;i++,i2++){ 176 if(paramStr[i]=='('){ 177 if(!sw) sw=1; 178 179 i3=GetStringInPare(name+i2,paramStr.c_str()+i); 180 i2+=i3-1; 181 i+=i3-1; 182 continue; 183 } 184 if(paramStr[i]=='['){ 185 if(!sw) sw=1; 186 187 i3=GetStringInBracket(name+i2,paramStr.c_str()+i); 188 i2+=i3-1; 189 i+=i3-1; 190 continue; 191 } 192 if(!IsVariableChar(paramStr[i])){ 193 name[i2]=0; 194 break; 195 } 196 name[i2]=paramStr[i]; 197 } 198 if(sw){ 199 //配列パラメータ 200 if( isRef == false ) 201 { 202 compiler.errorMessenger.Output(29,NULL,nowLine); 203 } 204 isArray = true; 205 206 if((name[i2-2]=='('&&name[i2-1]==')')|| 207 (name[i2-2]=='['&&name[i2-1]==']')) 208 { 209 subscripts.push_back( LONG_MAX ); 210 211 name[i2-2]=0; 212 } 213 else{ 214 GetArrange(name,temp2,subscripts); 215 lstrcpy(name,temp2); 216 } 217 218 i2=lstrlen(name); 219 } 220 221 Type type( DEF_NON ); 222 char initValue[8192] = ""; 223 if( paramStr[i] == '=' ){ 224 i++; 225 i = GetOneParameter( paramStr.c_str(), i, initValue ); 226 if( paramStr[i-1] == ',' ) 227 { 228 i--; 229 } 230 231 // TODO: エラー用 fix me!!! 232 //cp = nowLine; 233 234 NumOpe_GetType( initValue, GetStringTypeInfo(), type ); 235 236 if( IS_LITERAL(type.GetIndex()) ) 237 { 238 type.SetIndex( -1 ); 239 } 240 } 241 else if(paramStr[i]==1&¶mStr[i+1]==ESC_AS){ 242 // As指定 243 i+=2; 244 245 i2=0; 246 lstrcpy( temporary, paramStr.c_str() + i ); 247 248 compiler.StringToType( temporary, type ); 249 250 if( type.IsNull() ){ 251 compiler.errorMessenger.Output(3,temporary,nowLine); 252 type.SetBasicType( DEF_PTR_VOID ); 253 } 254 255 if( type.IsObject() ){ 256 if( type.GetClass().IsBlittableType() ){ 257 // Blittable型のときは基本型として扱う 258 type = type.GetClass().GetBlittableType(); 259 } 260 } 261 } 262 else{ 263 type.SetBasicType( Type::GetBasicTypeFromSimpleName(name) ); 264 compiler.errorMessenger.Output(-103,name,nowLine); 265 } 266 267 Parameter *pParam = new Parameter( name, type, isRef, initValue ); 268 if( isArray ){ 269 pParam->SetArray( subscripts ); 270 } 271 272 //パラメータを追加 273 this->params.push_back( pParam ); 274 } 275 150 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( params, parameters, nowLine ); 151 152 // 省略可能パラメータ(古い仕様。非推奨) 276 153 this->secondParmNum = (int)this->params.size(); 277 278 154 SplitParameter( parametersStr2, parameters ); 279 BOOST_FOREACH( const std::string ¶mStr, parameters ) 280 { 281 int i = 0; 282 283 bool isRef = false; 284 if( paramStr[i] == 1 ) 285 { 286 if( paramStr[i+1] == ESC_BYVAL ) 287 { 288 isRef = true; 289 i += 2; 290 } 291 else if( paramStr[i+1] == ESC_BYREF ) 292 { 293 isRef = false; 294 i += 2; 295 } 296 } 297 298 //パラメータ名 299 bool isArray = false; 300 Subscripts subscripts; 301 char name[VN_SIZE]; 302 sw=0; 303 for(i2=0;;i++,i2++){ 304 if(paramStr[i]=='('){ 305 if(!sw) sw=1; 306 307 i3=GetStringInPare(name+i2,paramStr.c_str()+i); 308 i2+=i3-1; 309 i+=i3-1; 310 continue; 311 } 312 if(paramStr[i]=='['){ 313 if(!sw) sw=1; 314 315 i3=GetStringInBracket(name+i2,paramStr.c_str()+i); 316 i2+=i3-1; 317 i+=i3-1; 318 continue; 319 } 320 if(!IsVariableChar(paramStr[i])){ 321 name[i2]=0; 322 break; 323 } 324 name[i2]=paramStr[i]; 325 } 326 if(sw){ 327 //配列パラメータ 328 if( isRef == false ) compiler.errorMessenger.Output(29,NULL,nowLine); 329 isArray = true; 330 331 if((name[i2-2]=='('&&name[i2-1]==')')|| 332 (name[i2-2]=='['&&name[i2-1]==']')) 333 { 334 subscripts.push_back( LONG_MAX ); 335 336 name[i2-2]=0; 337 } 338 else{ 339 GetArrange(name,temp2,subscripts); 340 lstrcpy(name,temp2); 341 } 342 343 i2=lstrlen(name); 344 } 345 346 Type type( DEF_NON ); 347 char initValue[8192] = ""; 348 if( paramStr[i] == '=' ){ 349 i++; 350 i = GetOneParameter( paramStr.c_str(), i, initValue ); 351 if( paramStr[i-1] == ',' ) 352 { 353 i--; 354 } 355 356 // TODO: エラー用 fix me!!! 357 //cp = nowLine; 358 359 NumOpe_GetType( initValue, GetStringTypeInfo(), type ); 360 361 if( IS_LITERAL(type.GetIndex()) ) 362 { 363 type.SetIndex( -1 ); 364 } 365 } 366 else if(paramStr[i]==1&¶mStr[i+1]==ESC_AS){ 367 // As指定 368 i+=2; 369 370 i2=0; 371 while(paramStr[i]=='*'){ 372 temporary[i2]=paramStr[i]; 373 i++; 374 i2++; 375 } 376 for(;;i++,i2++){ 377 if(!IsVariableChar(paramStr[i])){ 378 if(paramStr[i]==1&&(paramStr[i+1]==ESC_FUNCTION||paramStr[i+1]==ESC_SUB)){ 379 temporary[i2++]=paramStr[i++]; 380 temporary[i2]=paramStr[i]; 381 continue; 382 } 383 temporary[i2]=0; 384 break; 385 } 386 temporary[i2]=paramStr[i]; 387 } 388 389 compiler.StringToType( temporary, type ); 390 391 if( type.IsNull() ){ 392 compiler.errorMessenger.Output(3,temporary,nowLine); 393 type.SetBasicType( DEF_PTR_VOID ); 394 } 395 396 if( type.IsObject() ){ 397 if( type.GetClass().IsBlittableType() ){ 398 // Blittable型のときは基本型として扱う 399 type = type.GetClass().GetBlittableType(); 400 } 401 } 402 } 403 else{ 404 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) ); 405 compiler.errorMessenger.Output(-103,temporary,nowLine); 406 } 407 408 Parameter *pParam = new Parameter( name, type, isRef, initValue ); 409 if( isArray ){ 410 pParam->SetArray( subscripts ); 411 } 412 413 //パラメータを追加 414 this->params.push_back( pParam ); 415 } 155 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( params, parameters, nowLine ); 156 416 157 417 158 if(returnTypeStr[0]){
Note:
See TracChangeset
for help on using the changeset viewer.