Changeset 568 in dev for trunk/ab5.0/abdev
- Timestamp:
- May 6, 2008, 8:23:41 PM (17 years ago)
- Location:
- trunk/ab5.0/abdev/BasicCompiler_Common
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
r561 r568 55 55 56 56 // グローバルプロシージャを収集する 57 static bool AnalyzeParameter( Parameters ¶ms, const char *sourceOfParams, int nowLine ); 57 58 static UserProc* ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL ); 58 59 static void CollectProcedures( const char *source, UserProcs &userProcs, DllProcs &dllProcs ); -
trunk/ab5.0/abdev/BasicCompiler_Common/include/Parameter.h
r524 r568 101 101 } 102 102 103 bool Analyze( const char *sourceOfParams, int nowLine );104 105 103 std::string GetString() const; 106 104 }; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp
r525 r568 9 9 10 10 // パラメータを解析 11 params.Analyze(paramStr.c_str(), sourceIndex );11 ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( params, paramStr.c_str(), sourceIndex ); 12 12 13 13 // 動的パラメータを作る -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Procedure.cpp
r552 r568 2 2 3 3 using namespace ActiveBasic::Compiler; 4 5 bool LexicalAnalyzer::AnalyzeParameter( Parameters ¶ms, const char *sourceOfParams, int nowLine ) 6 { 7 int i2,i3,sw; 8 char temporary[8192],temp2[VN_SIZE]; 9 10 //パラメータ 11 int i = 0; 12 while(1){ 13 if( sourceOfParams[i] == '\0' ) 14 { 15 break; 16 } 17 18 //ByRef 19 bool isRef; 20 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){ 21 isRef = false; 22 i+=2; 23 } 24 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){ 25 isRef = true; 26 i+=2; 27 } 28 else isRef = false; 29 30 //パラメータ名 31 bool isArray = false; 32 Subscripts subscripts; 33 char name[VN_SIZE]; 34 sw=0; 35 for(i2=0;;i++,i2++){ 36 if(sourceOfParams[i]=='('){ 37 if(!sw) sw=1; 38 39 i3=GetStringInPare(name+i2,sourceOfParams+i); 40 i2+=i3-1; 41 i+=i3-1; 42 continue; 43 } 44 if(sourceOfParams[i]=='['){ 45 if(!sw) sw=1; 46 47 i3=GetStringInBracket(name+i2,sourceOfParams+i); 48 i2+=i3-1; 49 i+=i3-1; 50 continue; 51 } 52 if(!IsVariableChar(sourceOfParams[i])){ 53 name[i2]=0; 54 break; 55 } 56 name[i2]=sourceOfParams[i]; 57 } 58 if(sw){ 59 //配列パラメータ 60 if( isRef == false ) 61 { 62 compiler.errorMessenger.Output(29,NULL,nowLine); 63 } 64 isArray = true; 65 66 if((name[i2-2]=='('&&name[i2-1]==')')|| 67 (name[i2-2]=='['&&name[i2-1]==']')) 68 { 69 subscripts.push_back( LONG_MAX ); 70 71 name[i2-2]=0; 72 } 73 else{ 74 GetArrange(name,temp2,subscripts); 75 lstrcpy(name,temp2); 76 } 77 78 i2=lstrlen(name); 79 } 80 81 Type type( DEF_NON ); 82 char initValue[8192] = ""; 83 if( sourceOfParams[i] == '=' ){ 84 i++; 85 i = GetOneParameter( sourceOfParams, i, initValue ); 86 87 // TODO: エラー用 fix me!!! 88 //cp = nowLine; 89 90 NumOpe_GetType( initValue, GetStringTypeInfo(), type ); 91 92 if( IS_LITERAL(type.GetIndex()) ) 93 { 94 type.SetIndex( -1 ); 95 } 96 } 97 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ 98 // As指定 99 i+=2; 100 101 i2=0; 102 while(sourceOfParams[i]=='*'){ 103 temporary[i2]=sourceOfParams[i]; 104 i++; 105 i2++; 106 } 107 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]; 112 continue; 113 } 114 temporary[i2]=0; 115 break; 116 } 117 temporary[i2]=sourceOfParams[i]; 118 } 119 120 compiler.StringToType( temporary, type ); 121 122 if( type.IsNull() ){ 123 compiler.errorMessenger.Output(3,temporary,nowLine); 124 type.SetBasicType( DEF_PTR_VOID ); 125 } 126 127 if( type.IsObject() ){ 128 if( type.GetClass().IsBlittableType() ){ 129 // Blittable型のときは基本型として扱う 130 type = type.GetClass().GetBlittableType(); 131 } 132 } 133 } 134 else{ 135 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) ); 136 compiler.errorMessenger.Output(-103,temporary,nowLine); 137 } 138 139 Parameter *pParam = new Parameter( name, type, isRef, initValue ); 140 if( isArray ){ 141 pParam->SetArray( subscripts ); 142 } 143 144 //パラメータを追加 145 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 } 161 162 return true; 163 } 4 164 5 165 UserProc* LexicalAnalyzer::ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName ) -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Parameter.cpp
r465 r568 88 88 } 89 89 90 bool Parameters::Analyze( const char *sourceOfParams, int nowLine )91 {92 int i2,i3,sw;93 char temporary[8192],temp2[VN_SIZE];94 95 //パラメータ96 int i = 0;97 while(1){98 if( sourceOfParams[i] == '\0' )99 {100 break;101 }102 103 //ByRef104 bool isRef;105 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){106 isRef = false;107 i+=2;108 }109 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){110 isRef = true;111 i+=2;112 }113 else isRef = false;114 115 //パラメータ名116 bool isArray = false;117 Subscripts subscripts;118 char name[VN_SIZE];119 sw=0;120 for(i2=0;;i++,i2++){121 if(sourceOfParams[i]=='('){122 if(!sw) sw=1;123 124 i3=GetStringInPare(name+i2,sourceOfParams+i);125 i2+=i3-1;126 i+=i3-1;127 continue;128 }129 if(sourceOfParams[i]=='['){130 if(!sw) sw=1;131 132 i3=GetStringInBracket(name+i2,sourceOfParams+i);133 i2+=i3-1;134 i+=i3-1;135 continue;136 }137 if(!IsVariableChar(sourceOfParams[i])){138 name[i2]=0;139 break;140 }141 name[i2]=sourceOfParams[i];142 }143 if(sw){144 //配列パラメータ145 if( isRef == false )146 {147 compiler.errorMessenger.Output(29,NULL,nowLine);148 }149 isArray = true;150 151 if((name[i2-2]=='('&&name[i2-1]==')')||152 (name[i2-2]=='['&&name[i2-1]==']'))153 {154 subscripts.push_back( LONG_MAX );155 156 name[i2-2]=0;157 }158 else{159 GetArrange(name,temp2,subscripts);160 lstrcpy(name,temp2);161 }162 163 i2=lstrlen(name);164 }165 166 Type type( DEF_NON );167 char initValue[8192] = "";168 if( sourceOfParams[i] == '=' ){169 i++;170 i = GetOneParameter( sourceOfParams, i, initValue );171 172 // TODO: エラー用 fix me!!!173 //cp = nowLine;174 175 NumOpe_GetType( initValue, GetStringTypeInfo(), type );176 177 if( IS_LITERAL(type.GetIndex()) )178 {179 type.SetIndex( -1 );180 }181 }182 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){183 // As指定184 i+=2;185 186 i2=0;187 while(sourceOfParams[i]=='*'){188 temporary[i2]=sourceOfParams[i];189 i++;190 i2++;191 }192 for(;;i++,i2++){193 if(!IsVariableChar(sourceOfParams[i])){194 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){195 temporary[i2++]=sourceOfParams[i++];196 temporary[i2]=sourceOfParams[i];197 continue;198 }199 temporary[i2]=0;200 break;201 }202 temporary[i2]=sourceOfParams[i];203 }204 205 compiler.StringToType( temporary, type );206 207 if( type.IsNull() ){208 compiler.errorMessenger.Output(3,temporary,nowLine);209 type.SetBasicType( DEF_PTR_VOID );210 }211 212 if( type.IsObject() ){213 if( type.GetClass().IsBlittableType() ){214 // Blittable型のときは基本型として扱う215 type = type.GetClass().GetBlittableType();216 }217 }218 }219 else{220 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) );221 compiler.errorMessenger.Output(-103,temporary,nowLine);222 }223 224 Parameter *pParam = new Parameter( name, type, isRef, initValue );225 if( isArray ){226 pParam->SetArray( subscripts );227 }228 229 //パラメータを追加230 this->push_back( pParam );231 232 if( sourceOfParams[i] == ',' )233 {234 i++;235 continue;236 }237 else if( sourceOfParams[i] == '\0' )238 {239 break;240 }241 else{242 compiler.errorMessenger.Output(1,NULL,nowLine);243 break;244 }245 }246 247 return true;248 }249 250 90 std::string Parameters::GetString() const 251 91 {
Note:
See TracChangeset
for help on using the changeset viewer.