| 42 | } |
| 43 | |
| 44 | bool ConditionalParser::andexpr(Expression& expr) |
| 45 | { |
| 46 | if (!notexpr(expr)) |
| 47 | return false; |
| 48 | |
| 49 | while (true) |
| 50 | { |
| 51 | if (!match(TokenType::And)) |
| 52 | return true; |
| 53 | |
| 54 | if (!notexpr(expr)) |
| 55 | { |
| 56 | setError("Expected expression following '&&'."); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | NodePtr right = expr.popNode(); |
| 61 | NodePtr left = expr.popNode(); |
| 62 | |
| 63 | if (left->isValue()) |
| 64 | { |
| 65 | setError("Can't apply '&&' to numeric expression '" + left->print() + "'."); |
| 66 | return false; |
| 67 | } |
| 68 | if (right->isValue()) |
| 69 | { |
| 70 | setError("Can't apply '&&' to numeric expression '" + right->print() + "'."); |
| 71 | return false; |
| 72 | } |
| 73 | expr.pushNode(NodePtr(new BoolNode(NodeType::And, std::move(left), std::move(right)))); |
| 74 | } |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | bool ConditionalParser::notexpr(Expression& expr) |
| 79 | { |