Changeset 182 in dev for trunk/abdev/BasicCompiler_Common/StrOperation.cpp
- Timestamp:
- Jun 24, 2007, 6:49:13 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/StrOperation.cpp
r77 r182 1 #include <jenga/include/smoothie/LexicalAnalysis.h> 2 1 3 #include "../BasicCompiler_Common/common.h" 2 4 … … 167 169 free(temp); 168 170 } 169 _int8 IsCommandDelimitation(char c){170 if(c=='\n'||c==':'||c=='\0') return 1;171 return 0;172 }173 BOOL IsBlank(char c){174 if(c==' '||c=='\t') return 1;175 return 0;176 }177 int GetOneParameter(const char *Parameter,int pos,char *retAns){178 int i,i2,i3,IsStr;179 for(i=pos,i2=0,IsStr=0;;i++,i2++){180 if(Parameter[i]=='\"') IsStr^=1;181 else if(Parameter[i]=='('&&IsStr==0){182 i3=GetStringInPare(retAns+i2,Parameter+i);183 i+=i3-1;184 i2+=i3-1;185 continue;186 }187 else if(Parameter[i]=='['&&IsStr==0){188 i3=GetStringInBracket(retAns+i2,Parameter+i);189 i+=i3-1;190 i2+=i3-1;191 continue;192 }193 else if(Parameter[i]==','&&IsStr==0){194 retAns[i2]=0;195 i++;196 break;197 }198 199 if(IsCommandDelimitation(Parameter[i])&&IsStr==0200 || Parameter[i] == ')' && IsStr == 0 ){201 retAns[i2]=0;202 break;203 }204 205 retAns[i2]=Parameter[i];206 }207 return i;208 }209 int JumpOneParameter(char *Parameter,int i){210 int i2,IsStr;211 for(i2=0,IsStr=0;;i++,i2++){212 if(Parameter[i]=='\"') IsStr^=1;213 else if(Parameter[i]=='('&&IsStr==0){214 i=JumpStringInPare(Parameter,i+1);215 continue;216 }217 else if(Parameter[i]=='['&&IsStr==0){218 i=JumpStringInBracket(Parameter,i+1);219 continue;220 }221 else if(Parameter[i]==','&&IsStr==0){222 i++;223 break;224 }225 if(IsCommandDelimitation(Parameter[i])) break;226 }227 return i;228 }229 int GetStringInQuotation(char *buffer,char *ReadBuffer){230 int i;231 232 if(ReadBuffer[0]=='\"'){233 buffer[0]=ReadBuffer[0];234 i=1;235 }236 else i=0;237 238 for(;;i++){239 buffer[i]=ReadBuffer[i];240 if(IsDBCSLeadByte(ReadBuffer[i])){241 i++;242 buffer[i]=ReadBuffer[i];243 continue;244 }245 if(ReadBuffer[i]=='\"'){246 i++;247 buffer[i]=0;248 break;249 }250 if(ReadBuffer[i]=='\0') return 0;251 }252 return i;253 }254 int GetStringInPare(char *buffer,const char *ReadBuffer){255 int i,IsStr,PareNum;256 for(i=0,IsStr=0,PareNum=0;;i++){257 buffer[i]=ReadBuffer[i];258 if(IsDBCSLeadByte(ReadBuffer[i])){259 i++;260 buffer[i]=ReadBuffer[i];261 continue;262 }263 if(ReadBuffer[i]=='\"') IsStr^=1;264 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;265 else if(ReadBuffer[i]==')'&&IsStr==0){266 PareNum--;267 if(PareNum==0){268 i++;269 buffer[i]=0;270 break;271 }272 }273 else if(ReadBuffer[i]=='\0') return 0;274 }275 return i;276 }277 int GetStringInPare_RemovePare(char *buffer,char *ReadBuffer){278 int i,IsStr,PareNum;279 for(i=0,IsStr=0,PareNum=1;;i++){280 buffer[i]=ReadBuffer[i];281 if(IsDBCSLeadByte(ReadBuffer[i])){282 i++;283 buffer[i]=ReadBuffer[i];284 continue;285 }286 if(ReadBuffer[i]=='\"') IsStr^=1;287 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;288 else if(ReadBuffer[i]==')'&&IsStr==0){289 PareNum--;290 if(PareNum==0){291 buffer[i]=0;292 break;293 }294 }295 else if(ReadBuffer[i]=='\0') return 0;296 }297 return i;298 }299 int GetStringInBracket(char *buffer,const char *ReadBuffer){300 int i,IsStr,PareNum;301 for(i=0,IsStr=0,PareNum=0;;i++){302 buffer[i]=ReadBuffer[i];303 if(IsDBCSLeadByte(ReadBuffer[i])){304 i++;305 buffer[i]=ReadBuffer[i];306 continue;307 }308 if(ReadBuffer[i]=='\"') IsStr^=1;309 else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;310 else if(ReadBuffer[i]==']'&&IsStr==0){311 PareNum--;312 if(PareNum==0){313 i++;314 buffer[i]=0;315 break;316 }317 }318 else if(ReadBuffer[i]=='\0') return 0;319 }320 return i;321 }322 int JumpStringInPare(const char *buffer,int pos){323 int PareNum;324 for(PareNum=1;;pos++){325 if(buffer[pos]=='\"'){326 for(pos++;;pos++){327 if(buffer[pos]=='\"') break;328 }329 continue;330 }331 else if(buffer[pos]=='(') PareNum++;332 else if(buffer[pos]==')'){333 PareNum--;334 if(PareNum==0) return pos;335 }336 else if(buffer[pos]=='\0') break;337 }338 return 0;339 }340 int JumpStringInBracket(const char *buffer,int pos){341 int PareNum;342 for(PareNum=1;;pos++){343 if(buffer[pos]=='\"'){344 for(pos++;;pos++){345 if(buffer[pos]=='\"') break;346 }347 continue;348 }349 else if(buffer[pos]=='[') PareNum++;350 else if(buffer[pos]==']'){351 PareNum--;352 if(PareNum==0) return pos;353 }354 else if(buffer[pos]=='\0') break;355 }356 return 0;357 }358 171 359 172 int GetCpFromLine(int LineNum){
Note:
See TracChangeset
for help on using the changeset viewer.