17 llvm::raw_ostream& m_stream;
19 bool m_needs_sep =
false;
22 void header(string_view label);
23 void indent(string_view text);
26 explicit PrintVisitor(llvm::raw_ostream& stream,
bool pretty =
false) : m_stream{stream}, m_pretty(pretty) {}
39inline void PrintVisitor::header(string_view label) {
41 m_stream << (m_pretty ? (
"\n" + std::string(m_indent * 2UL,
' ')) :
" ");
46 m_stream << label <<
"=";
49inline void PrintVisitor::indent(string_view text) {
52 m_stream << std::string(m_indent * 2UL,
' ');
58 m_stream.changeColor(llvm::raw_ostream::SAVEDCOLOR,
true) << expr.kind_name();
59 m_stream.resetColor();
78 m_stream.write_escaped(str);
87 m_stream.changeColor(llvm::raw_ostream::RED) <<
"null";
88 m_stream.resetColor();
All nodes in the AST tree of the program inherit from this class.
PrintVisitor(PrintVisitor &&)=delete
auto visit(const ast::AST &expr, string_view label) -> PrintVisitor &override
auto operator=(const PrintVisitor &) -> PrintVisitor &=delete
PrintVisitor(const PrintVisitor &)=delete
auto operator=(PrintVisitor &&) -> PrintVisitor &=delete
PrintVisitor(llvm::raw_ostream &stream, bool pretty=false)
~PrintVisitor() override=default