| 13 | } |
| 14 | |
| 15 | bool ConditionalParser::orexpr(Expression& expr) |
| 16 | { |
| 17 | if (!andexpr(expr)) |
| 18 | return false; |
| 19 | |
| 20 | while (true) |
| 21 | { |
| 22 | if (!match(TokenType::Or)) |
| 23 | return true; |
| 24 | |
| 25 | if (!andexpr(expr)) |
| 26 | { |
| 27 | setError("Expected expression following '||'."); |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | NodePtr right = expr.popNode(); |
| 32 | NodePtr left = expr.popNode(); |
| 33 | |
| 34 | if (left->isValue() || right->isValue()) |
| 35 | { |
| 36 | setError("Can't apply '||' to numeric expression."); |
| 37 | return false; |
| 38 | } |
| 39 | expr.pushNode(NodePtr(new BoolNode(NodeType::Or, std::move(left), std::move(right)))); |
| 40 | } |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | bool ConditionalParser::andexpr(Expression& expr) |
| 45 | { |