| 1665 | } |
| 1666 | |
| 1667 | void fxSwitchStatement(txParser* parser) |
| 1668 | { |
| 1669 | txInteger aCount = 0; |
| 1670 | txBoolean aDefaultFlag = 0; |
| 1671 | txInteger aLine = parser->states[0].line; |
| 1672 | fxMatchToken(parser, XS_TOKEN_SWITCH); |
| 1673 | fxMatchToken(parser, XS_TOKEN_LEFT_PARENTHESIS); |
| 1674 | fxCommaExpression(parser); |
| 1675 | fxMatchToken(parser, XS_TOKEN_RIGHT_PARENTHESIS); |
| 1676 | fxMatchToken(parser, XS_TOKEN_LEFT_BRACE); |
| 1677 | while ((parser->states[0].token == XS_TOKEN_CASE) || (parser->states[0].token == XS_TOKEN_DEFAULT)) { |
| 1678 | txInteger aCaseCount; |
| 1679 | txInteger aCaseLine = parser->states[0].line; |
| 1680 | if (parser->states[0].token == XS_TOKEN_CASE) { |
| 1681 | fxMatchToken(parser, XS_TOKEN_CASE); |
| 1682 | fxCommaExpression(parser); |
| 1683 | fxMatchToken(parser, XS_TOKEN_COLON); |
| 1684 | aCaseCount = parser->nodeCount; |
| 1685 | while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_STATEMENT) |
| 1686 | fxStatement(parser, -1); |
| 1687 | aCaseCount = parser->nodeCount - aCaseCount; |
| 1688 | if (aCaseCount > 1) { |
| 1689 | fxPushNodeList(parser, aCaseCount); |
| 1690 | fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aCaseLine); |
| 1691 | } |
| 1692 | else if (aCaseCount == 0) { |
| 1693 | fxPushNULL(parser); |
| 1694 | } |
| 1695 | fxPushNodeStruct(parser, 2, XS_TOKEN_CASE, aCaseLine); |
| 1696 | } |
| 1697 | else { |
| 1698 | fxMatchToken(parser, XS_TOKEN_DEFAULT); |
| 1699 | if (aDefaultFlag) |
| 1700 | fxReportParserError(parser, parser->states[0].line, "invalid default"); |
| 1701 | fxPushNULL(parser); |
| 1702 | fxMatchToken(parser, XS_TOKEN_COLON); |
| 1703 | aCaseCount = parser->nodeCount; |
| 1704 | while (gxTokenFlags[parser->states[0].token] & XS_TOKEN_BEGIN_STATEMENT) |
| 1705 | fxStatement(parser, -1); |
| 1706 | aCaseCount = parser->nodeCount - aCaseCount; |
| 1707 | if (aCaseCount > 1) { |
| 1708 | fxPushNodeList(parser, aCaseCount); |
| 1709 | fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, aLine); |
| 1710 | } |
| 1711 | else if (aCaseCount == 0) { |
| 1712 | fxPushNULL(parser); |
| 1713 | } |
| 1714 | fxPushNodeStruct(parser, 2, XS_TOKEN_CASE, aCaseLine); |
| 1715 | aDefaultFlag = 1; |
| 1716 | } |
| 1717 | aCount++; |
| 1718 | } |
| 1719 | fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE); |
| 1720 | fxPushNodeList(parser, aCount); |
| 1721 | fxPushNodeStruct(parser, 2, XS_TOKEN_SWITCH, aLine); |
| 1722 | } |
| 1723 | |
| 1724 | void fxThrowStatement(txParser* parser) |
no test coverage detected