Changeset 2520 in Sophya for trunk/SophyaLib/SysTools/cexpre.cc
- Timestamp:
- Mar 19, 2004, 9:07:28 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/cexpre.cc
r2518 r2520 311 311 size_t p=0, q=0; 312 312 char lastopc=0, opc=0; // Last/current operation sign (+,-,*,/,...) 313 int osn = 0; 313 314 bool finok = false; 314 315 bool fgcont = true; … … 344 345 } 345 346 else rx = cx; 346 p = stop+1; lastopc = opc;347 p = stop+1; osn = 0; lastopc = opc; 347 348 } 348 349 } … … 363 364 errmsg = "CExpressionEvaluator::ParseString()/ Syntax Error - rx&&cx (B)"; 364 365 } 365 if (q > p) cx = new CE_NumberExp(sex.substr(p ,q-p));366 if (q > p) cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn)); 366 367 else cx = rx; 367 368 … … 378 379 if (opc == ')') { // Signe de fin de traitement d'une portion d'expression 379 380 if (extype == 2) { rx = fx; fx = NULL; } 380 stop = q; lastopc = opc;381 stop = q; osn = 0; lastopc = opc; 381 382 fgcont = false; 382 383 finok = true; … … 384 385 else { 385 386 if (q == (len-1)) finok = true; 386 p = q+1; lastopc = opc;387 p = q+1; osn = 0; lastopc = opc; 387 388 } 388 389 } … … 393 394 case '*' : 394 395 case '/' : 395 // Traitement des signes +/- qui pourrait faire partie d'une constante numerique 396 if (!( ((opc=='+')||(opc=='-')) && ( (q==off) || ( (q==p) && (rx == NULL) ) ) ) ) { 397 // ((lastopc=='+')||(lastopc=='-')||(lastopc=='*')||(lastopc=='/')) ) ) ) ) { 396 if (!( ((opc=='+')||(opc=='-')) && ( (q==off) || ( (q==p) && lastopc != '(') ) ) ) { 398 397 CE_BinExp* nbx; 399 398 if (opc == '+') nbx = new CE_AddExp; … … 402 401 else nbx = new CE_DivExp; 403 402 if ((p == q) && (rx == NULL)) { 404 checkok = false; p = q; fgcont = false;403 checkok = false; p = q; osn = 0; fgcont = false; 405 404 delete nbx; 406 405 errmsg = "CExpressionEvaluator::ParseString() Syntax Error - rx==NULL (C)"; … … 408 407 else { 409 408 if (p == q) cx = rx; 410 else cx = new CE_NumberExp(sex.substr(p ,q-p));409 else cx = new CE_NumberExp(sex.substr(p-osn,q-p+osn)); 411 410 rx = Arrange_CE_BinExpStack(sbx, cx, nbx); 412 p = q+1; lastopc = opc; 413 } 411 p = q+1; osn = 0; lastopc = opc; 412 } 413 } 414 else { 415 // Traitement des signes +/- qui pourrait faire partie d'une constante numerique 416 p = q+1; osn++; 417 continue; 414 418 } 415 419 break; … … 425 429 } 426 430 else { 427 if (p<len) cx = new CE_NumberExp(sex.substr(p ));431 if (p<len) cx = new CE_NumberExp(sex.substr(p-osn)); 428 432 else cx = rx; 429 433 rx = Arrange_CE_BinExpStack(sbx, cx);
Note:
See TracChangeset
for help on using the changeset viewer.