| 1635 | } |
| 1636 | |
| 1637 | bool ParseSwitchExpr(Lexeme** str) |
| 1638 | { |
| 1639 | if(!ParseLexem(str, lex_switch)) |
| 1640 | return false; |
| 1641 | |
| 1642 | if(!ParseLexem(str, lex_oparen)) |
| 1643 | ThrowError((*str)->pos, "ERROR: '(' not found after 'switch'"); |
| 1644 | |
| 1645 | const char *condPos = (*str)->pos; |
| 1646 | if(!ParseVaribleSet(str)) |
| 1647 | ThrowError((*str)->pos, "ERROR: expression not found after 'switch('"); |
| 1648 | BeginSwitch(condPos); |
| 1649 | |
| 1650 | if(!ParseLexem(str, lex_cparen)) |
| 1651 | ThrowError((*str)->pos, "ERROR: closing ')' not found after expression in 'switch' statement"); |
| 1652 | |
| 1653 | if(!ParseLexem(str, lex_ofigure)) |
| 1654 | ThrowError((*str)->pos, "ERROR: '{' not found after 'switch(...)'"); |
| 1655 | |
| 1656 | while(ParseLexem(str, lex_case) || ParseLexem(str, lex_default)) |
| 1657 | { |
| 1658 | Lexeme *condPos = *str; |
| 1659 | if(condPos[-1].type == lex_case && !ParseVaribleSet(str)) |
| 1660 | ThrowError((*str)->pos, "ERROR: expression expected after 'case' of 'default'"); |
| 1661 | if(!ParseLexem(str, lex_colon)) |
| 1662 | ThrowError((*str)->pos, "ERROR: ':' expected"); |
| 1663 | |
| 1664 | if(!ParseExpression(str)) |
| 1665 | AddVoidNode(); |
| 1666 | while(ParseExpression(str)) |
| 1667 | AddTwoExpressionNode(); |
| 1668 | if(condPos[-1].type == lex_default) |
| 1669 | AddDefaultNode(); |
| 1670 | else |
| 1671 | AddCaseNode(condPos->pos); |
| 1672 | } |
| 1673 | |
| 1674 | if(!ParseLexem(str, lex_cfigure)) |
| 1675 | ThrowError((*str)->pos, "ERROR: '}' not found after 'switch' statement"); |
| 1676 | EndSwitch(); |
| 1677 | return true; |
| 1678 | } |
| 1679 | |
| 1680 | bool ParseReturnExpr(Lexeme** str, bool yield) |
| 1681 | { |
no test coverage detected