From 03ca7cdb382216ef995665cc59a07b4125241965 Mon Sep 17 00:00:00 2001 From: Tim King Date: Wed, 3 Feb 2010 19:41:14 +0000 Subject: By popular demand, I also added a printAst to Expr. --- src/expr/expr.cpp | 12 ++++++++++++ src/expr/expr.h | 18 ++++++++++++++++++ src/expr/node.h | 12 ++++++++++++ 3 files changed, 42 insertions(+) (limited to 'src/expr') diff --git a/src/expr/expr.cpp b/src/expr/expr.cpp index 50c9edcd2..578eaf2f5 100644 --- a/src/expr/expr.cpp +++ b/src/expr/expr.cpp @@ -17,6 +17,8 @@ #include "expr/node.h" #include "util/Assert.h" +#include "util/output.h" + namespace CVC4 { std::ostream& operator<<(std::ostream& out, const Expr& e) { @@ -168,4 +170,14 @@ Expr BoolExpr::iteExpr(const Expr& then_e, const Expr& else_e) const { return d_em->mkExpr(ITE, *this, then_e, else_e); } +void Expr::printAst(std::ostream & o, int indent) const{ + getNode().printAst(o,indent); +} + +void Expr::debugPrint(){ + printAst(Warning()); + Warning().flush(); +} + + } // End namespace CVC4 diff --git a/src/expr/expr.h b/src/expr/expr.h index 6f7330ed0..8d0d4f347 100644 --- a/src/expr/expr.h +++ b/src/expr/expr.h @@ -129,6 +129,24 @@ public: */ ExprManager* getExprManager() const; + /** + * Very basic pretty printer for Expr. + * This is equivalent to calling e.getNode().printAst(...) + * @param o output stream to print to. + * @param indent number of spaces to indent the formula by. + */ + void printAst(std::ostream & o, int indent = 0) const; + +private: + + /** + * Pretty printer for use within gdb + * This is not intended to be used outside of gdb. + * This writes to the ostream Warning() and immediately flushes + * the ostream. + */ + void debugPrint(); + protected: /** diff --git a/src/expr/node.h b/src/expr/node.h index ab5007a34..46827d196 100644 --- a/src/expr/node.h +++ b/src/expr/node.h @@ -154,9 +154,21 @@ public: bool isNull() const; + /** + * Very basic pretty printer for Node. + * @param o output stream to print to. + * @param indent number of spaces to indent the formula by. + */ void printAst(std::ostream & o, int indent = 0) const; private: + + /** + * Pretty printer for use within gdb + * This is not intended to be used outside of gdb. + * This writes to the ostream Warning() and immediately flushes + * the ostream. + */ void debugPrint(); };/* class Node */ -- cgit v1.2.3