lean2/src/kernel/formatter.h
Leonardo de Moura 7d987df429 refactor(kernel/formatter): move simple_formatter to library
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-08-22 10:26:45 -07:00

33 lines
1.1 KiB
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <memory>
#include <utility>
#include "util/sexpr/options.h"
namespace lean {
class expr;
class environment;
class formatter {
std::function<format(expr const &, options const &)> m_fn;
options m_options;
public:
formatter(options const & o, std::function<format(expr const &, options const &)> const & fn):m_fn(fn), m_options(o) {}
format operator()(expr const & e) const { return m_fn(e, m_options); }
options const & get_options() const { return m_options; }
formatter update_options(options const & o) const { return formatter(o, m_fn); }
};
typedef std::function<formatter(environment const &, options const &)> formatter_factory;
std::ostream & operator<<(std::ostream & out, expr const & e);
typedef std::function<format(formatter const &)> pp_fn;
void set_print_fn(std::function<void(std::ostream &, expr const &)> const & fn);
}