Branch data Line data Source code
1 : : #include <mutable/parse/AST.hpp> 2 : : 3 : : 4 : : namespace m { 5 : : 6 : : namespace ast { 7 : : 8 : : /** Pretty-prints the AST in SQL. */ 9 : : struct M_EXPORT ASTPrinter : ConstASTVisitor 10 : : { 11 : : public: 12 : : std::ostream &out; ///< the output stream to write to 13 : : private: 14 : : unsigned indent_; ///< the current level of indentation 15 : 6296 : bool is_nested_ = false; ///< whether the statement is nested; determines whether a final ';' must be printed 16 : 6296 : bool expand_nested_queries_ = true; ///< determines whether nested queries are printed 17 : : 18 : : public: 19 : 12592 : ASTPrinter(std::ostream &out, unsigned indent = 0) : out(out), indent_(indent) { (void)(this->indent_); } 20 : : 21 : : bool expand_nested_queries() { return expand_nested_queries_; } 22 : 6084 : void expand_nested_queries(bool expand) { expand_nested_queries_ = expand; } 23 : : 24 : : using ConstASTVisitor::operator(); 25 : : #define DECLARE(CLASS) void operator()(Const<CLASS>&) override; 26 : : M_AST_LIST(DECLARE) 27 : : #undef DECLARE 28 : : }; 29 : : 30 : : } 31 : : 32 : : }