std::ostream & operator<< (std::ostream & out, const Type & t);\r
std::ostream & operator<< (std::ostream & out, const Variable & v);\r
std::ostream & operator<< (std::ostream & out, const Body & b);\r
-std::ostream & operator<< (std::ostream & out, const OperatorExpr & o);\r
+std::ostream & operator<< (std::ostream & out, const UnaryOperatorExpr & o);\r
+std::ostream & operator<< (std::ostream & out, const BinaryOperatorExpr & o);\r
+std::ostream & operator<< (std::ostream & out, const TernaryOperatorExpr & o);\r
std::ostream & operator<< (std::ostream & out, const Expr & e);\r
std::ostream & operator<< (std::ostream & out, const Stmt & s);\r
\r
\r
return out;\r
}\r
-std::ostream & operator<< (std::ostream & out, const OperatorExpr & o) {\r
- out << *o.lexpr << " ";\r
-\r
- switch (o.type) {\r
- case OperatorType::Plus: out << "+"; break;\r
- case OperatorType::Minus: out << "-"; break;\r
- case OperatorType::Multiply: out << "*"; break;\r
- case OperatorType::Divide: out << "/"; break;\r
- case OperatorType::Equals: out << "=="; break;\r
- case OperatorType::NotEquals: out << "!="; break;\r
- case OperatorType::LessThan: out << "<"; break;\r
- case OperatorType::GreaterThan: out << ">"; break;\r
+std::ostream & operator<< (std::ostream & out, const UnaryOperatorExpr & o) {\r
+ if (o.type == UnaryOperatorType::IncrementPost || o.type == UnaryOperatorType::DecrementPost) {\r
+ out << UnaryOperatorTypeStrings[(int)o.type] << *o.expr;\r
+ }\r
+ else {\r
+ out << *o.expr << UnaryOperatorTypeStrings[(int)o.type];\r
}\r
\r
- out << " " << *o.rexpr;\r
+ return out;\r
+}\r
+std::ostream & operator<< (std::ostream & out, const BinaryOperatorExpr & o) {\r
+ out << *o.lexpr << " " << BinaryOperatorTypeStrings[(int)o.type] << " " << *o.rexpr;\r
+\r
+ return out;\r
+}\r
+std::ostream & operator<< (std::ostream & out, const TernaryOperatorExpr & o) {\r
+ out << *o.lexpr << " ? " << *o.rexprTrue << " : " << *o.rexprFalse;\r
\r
return out;\r
}\r