diff --git a/include/boost/boostache/vm/printer.hpp b/include/boost/boostache/vm/printer.hpp index c160c76..8bac1ef 100644 --- a/include/boost/boostache/vm/printer.hpp +++ b/include/boost/boostache/vm/printer.hpp @@ -2,96 +2,169 @@ * \file vm/printer.hpp * * Copyright 2014, 2015 Michael Caisse : ciere.com + * Copyright 2014, 2015 Michal Bukovsky * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ + #ifndef BOOST_BOOSTACHE_VM_PRINTER_HPP #define BOOST_BOOSTACHE_VM_PRINTER_HPP #include #include -namespace boost { namespace boostache { namespace vm { namespace ast +namespace boost { namespace boostache { +namespace vm { namespace ast { namespace detail { + +class printer +{ +public: + typedef void result_type; + + printer(std::ostream &out) + : out{out}, decorations{true} + {} + + void operator()(undefined) + { + print_decoration(); + out << "[]" << std::endl; + } + + void operator()(literal const & v) + { + print_decoration(); + out << "[: \"" << shrink(v.value) << "\"]" << std::endl; + } + + void operator()(variable const & v) + { + print_decoration(); + out << "[: " << v.name << "]" << std::endl; + } + + void operator()(render const & v) + { + print_decoration(); + out << "[: " << v.name << "]" << std::endl; + } + + void operator()(for_each const & v) + { + print_decoration(); + out << "[: " << v.name << "]" << std::endl; + indent_decoration(v.value); + boost::apply_visitor(*this, v.value); + undent_decoration(); + } + + void operator()(condition const & v) + {} + + void operator()(select_context const & v) + { + print_decoration(); + out << "[