Unified · Split
| @@ -553,7 +553,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 552 unmodified lines | ||
| 553 | 553 | static char *pstrcpy(char *buf, int buf_size, const char *s); |
| 554 | 554 | static char *pstrcat(char *buf, int buf_size, const char *s); |
| 555 | 555 | |
| 556 | −static void sum(int l); | |
| 557 | 556 | static void next(void); |
| 558 | 557 | static void next_nomacro(void); |
| 559 | 558 | static void parse_expr_type(CType *type); |
| @@ -6478,39 +6477,130 @@ static void uneq(void) · 5918 unmodified lines | ||
| 6478 | 6477 | } |
| 6479 | 6478 | } |
| 6480 | 6479 | |
| 6481 | −static void sum(int l) | |
| 6480 | +static void expr_prod(void) | |
| 6482 | 6481 | { |
| 6483 | 6482 | int t; |
| 6484 | 6483 | |
| 6485 | − if (l == 0) | |
| 6484 | + uneq(); | |
| 6485 | + while (tok == '*' || tok == '/' || tok == '%') { | |
| 6486 | + t = tok; | |
| 6487 | + next(); | |
| 6486 | 6488 | uneq(); |
| 6487 | − else { | |
| 6488 | − sum(--l); | |
| 6489 | − while ((l == 0 && (tok == '*' || tok == '/' || tok == '%')) || | |
| 6490 | − (l == 1 && (tok == '+' || tok == '-')) || | |
| 6491 | − (l == 2 && (tok == TOK_SHL || tok == TOK_SAR)) || | |
| 6492 | − (l == 3 && ((tok >= TOK_ULE && tok <= TOK_GT) || | |
| 6493 | − tok == TOK_ULT || tok == TOK_UGE)) || | |
| 6494 | − (l == 4 && (tok == TOK_EQ || tok == TOK_NE)) || | |
| 6495 | − (l == 5 && tok == '&') || | |
| 6496 | − (l == 6 && tok == '^') || | |
| 6497 | − (l == 7 && tok == '|') || | |
| 6498 | − (l == 8 && tok == TOK_LAND) || | |
| 6499 | − (l == 9 && tok == TOK_LOR)) { | |
| 6500 | − t = tok; | |
| 6501 | − next(); | |
| 6502 | − sum(l); | |
| 6503 | − gen_op(t); | |
| 6504 | − } | |
| 6489 | + gen_op(t); | |
| 6490 | + } | |
| 6491 | +} | |
| 6492 | + | |
| 6493 | +static void expr_sum(void) | |
| 6494 | +{ | |
| 6495 | + int t; | |
| 6496 | + | |
| 6497 | + expr_prod(); | |
| 6498 | + while (tok == '+' || tok == '-') { | |
| 6499 | + t = tok; | |
| 6500 | + next(); | |
| 6501 | + expr_prod(); | |
| 6502 | + gen_op(t); | |
| 6503 | + } | |
| 6504 | +} | |
| 6505 | + | |
| 6506 | +static void expr_shift(void) | |
| 6507 | +{ | |
| 6508 | + int t; | |
| 6509 | + | |
| 6510 | + expr_sum(); | |
| 6511 | + while (tok == TOK_SHL || tok == TOK_SAR) { | |
| 6512 | + t = tok; | |
| 6513 | + next(); | |
| 6514 | + expr_sum(); | |
| 6515 | + gen_op(t); | |
| 6516 | + } | |
| 6517 | +} | |
| 6518 | + | |
| 6519 | +static void expr_cmp(void) | |
| 6520 | +{ | |
| 6521 | + int t; | |
| 6522 | + | |
| 6523 | + expr_shift(); | |
| 6524 | + while ((tok >= TOK_ULE && tok <= TOK_GT) || | |
| 6525 | + tok == TOK_ULT || tok == TOK_UGE) { | |
| 6526 | + t = tok; | |
| 6527 | + next(); | |
| 6528 | + expr_shift(); | |
| 6529 | + gen_op(t); | |
| 6530 | + } | |
| 6531 | +} | |
| 6532 | + | |
| 6533 | +static void expr_cmpeq(void) | |
| 6534 | +{ | |
| 6535 | + int t; | |
| 6536 | + | |
| 6537 | + expr_cmp(); | |
| 6538 | + while (tok == TOK_EQ || tok == TOK_NE) { | |
| 6539 | + t = tok; | |
| 6540 | + next(); | |
| 6541 | + expr_cmp(); | |
| 6542 | + gen_op(t); | |
| 6543 | + } | |
| 6544 | +} | |
| 6545 | + | |
| 6546 | +static void expr_and(void) | |
| 6547 | +{ | |
| 6548 | + expr_cmpeq(); | |
| 6549 | + while (tok == '&') { | |
| 6550 | + next(); | |
| 6551 | + expr_cmpeq(); | |
| 6552 | + gen_op('&'); | |
| 6553 | + } | |
| 6554 | +} | |
| 6555 | + | |
| 6556 | +static void expr_xor(void) | |
| 6557 | +{ | |
| 6558 | + expr_and(); | |
| 6559 | + while (tok == '^') { | |
| 6560 | + next(); | |
| 6561 | + expr_and(); | |
| 6562 | + gen_op('^'); | |
| 6563 | + } | |
| 6564 | +} | |
| 6565 | + | |
| 6566 | +static void expr_or(void) | |
| 6567 | +{ | |
| 6568 | + expr_xor(); | |
| 6569 | + while (tok == '|') { | |
| 6570 | + next(); | |
| 6571 | + expr_xor(); | |
| 6572 | + gen_op('|'); | |
| 6573 | + } | |
| 6574 | +} | |
| 6575 | + | |
| 6576 | +/* XXX: suppress this mess */ | |
| 6577 | +static void expr_land_const(void) | |
| 6578 | +{ | |
| 6579 | + expr_or(); | |
| 6580 | + while (tok == TOK_LAND) { | |
| 6581 | + next(); | |
| 6582 | + expr_or(); | |
| 6583 | + gen_op(TOK_LAND); | |
| 6584 | + } | |
| 6585 | +} | |
| 6586 | + | |
| 6587 | +/* XXX: suppress this mess */ | |
| 6588 | +static void expr_lor_const(void) | |
| 6589 | +{ | |
| 6590 | + expr_land_const(); | |
| 6591 | + while (tok == TOK_LOR) { | |
| 6592 | + next(); | |
| 6593 | + expr_land_const(); | |
| 6594 | + gen_op(TOK_LOR); | |
| 6505 | 6595 | } |
| 6506 | 6596 | } |
| 6507 | 6597 | |
| 6508 | 6598 | /* only used if non constant */ |
| 6509 | −static void eand(void) | |
| 6599 | +static void expr_land(void) | |
| 6510 | 6600 | { |
| 6511 | 6601 | int t; |
| 6512 | 6602 | |
| 6513 | − sum(8); | |
| 6603 | + expr_or(); | |
| 6514 | 6604 | t = 0; |
| 6515 | 6605 | while (1) { |
| 6516 | 6606 | if (tok != TOK_LAND) { |
| @@ -6522,15 +6612,15 @@ static void eand(void) · 5 unmodified lines | ||
| 6522 | 6612 | } |
| 6523 | 6613 | t = gtst(1, t); |
| 6524 | 6614 | next(); |
| 6525 | − sum(8); | |
| 6615 | + expr_or(); | |
| 6526 | 6616 | } |
| 6527 | 6617 | } |
| 6528 | 6618 | |
| 6529 | −static void eor(void) | |
| 6619 | +static void expr_lor(void) | |
| 6530 | 6620 | { |
| 6531 | 6621 | int t; |
| 6532 | 6622 | |
| 6533 | − eand(); | |
| 6623 | + expr_land(); | |
| 6534 | 6624 | t = 0; |
| 6535 | 6625 | while (1) { |
| 6536 | 6626 | if (tok != TOK_LOR) { |
| @@ -6542,7 +6632,7 @@ static void eor(void) · 5 unmodified lines | ||
| 6542 | 6632 | } |
| 6543 | 6633 | t = gtst(0, t); |
| 6544 | 6634 | next(); |
| 6545 | − eand(); | |
| 6635 | + expr_land(); | |
| 6546 | 6636 | } |
| 6547 | 6637 | } |
| 6548 | 6638 | |
| @@ -6555,7 +6645,7 @@ static void expr_eq(void) · 6 unmodified lines | ||
| 6555 | 6645 | |
| 6556 | 6646 | if (const_wanted) { |
| 6557 | 6647 | int c1, c; |
| 6558 | − sum(10); | |
| 6648 | + expr_lor_const(); | |
| 6559 | 6649 | if (tok == '?') { |
| 6560 | 6650 | c = vtop->c.i; |
| 6561 | 6651 | vpop(); |
| @@ -6569,7 +6659,7 @@ static void expr_eq(void) · 7 unmodified lines | ||
| 6569 | 6659 | vtop->c.i = c1; |
| 6570 | 6660 | } |
| 6571 | 6661 | } else { |
| 6572 | − eor(); | |
| 6662 | + expr_lor(); | |
| 6573 | 6663 | if (tok == '?') { |
| 6574 | 6664 | next(); |
| 6575 | 6665 | save_regs(1); /* we need to save all registers here except |