2013-08-17 01:34:11 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include <sstream>
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "kernel/kernel_exception.h"
|
2013-10-01 01:16:13 +00:00
|
|
|
#include "kernel/printer.h"
|
|
|
|
#include "kernel/formatter.h"
|
2013-08-31 23:46:41 +00:00
|
|
|
|
2013-08-17 01:34:11 +00:00
|
|
|
namespace lean {
|
2013-08-17 18:29:43 +00:00
|
|
|
class simple_formatter_cell : public formatter_cell {
|
2013-08-17 01:34:11 +00:00
|
|
|
public:
|
2013-09-20 04:26:01 +00:00
|
|
|
virtual format operator()(expr const & e, options const &) {
|
2013-08-17 01:34:11 +00:00
|
|
|
std::ostringstream s; s << e; return format(s.str());
|
|
|
|
}
|
2013-09-20 04:26:01 +00:00
|
|
|
virtual format operator()(context const & c, options const &) {
|
2013-08-17 01:34:11 +00:00
|
|
|
std::ostringstream s; s << c; return format(s.str());
|
|
|
|
}
|
2013-09-20 04:26:01 +00:00
|
|
|
virtual format operator()(context const & c, expr const & e, bool format_ctx, options const &) {
|
2013-08-17 01:34:11 +00:00
|
|
|
std::ostringstream s;
|
|
|
|
if (format_ctx)
|
2013-09-21 04:46:32 +00:00
|
|
|
s << c << " |- ";
|
2013-09-13 19:49:03 +00:00
|
|
|
s << mk_pair(e, c);
|
2013-08-17 01:34:11 +00:00
|
|
|
return format(s.str());
|
|
|
|
}
|
2013-09-20 04:26:01 +00:00
|
|
|
virtual format operator()(object const & obj, options const &) {
|
2013-08-17 17:55:42 +00:00
|
|
|
std::ostringstream s; s << obj; return format(s.str());
|
|
|
|
}
|
2013-09-20 04:26:01 +00:00
|
|
|
virtual format operator()(environment const & env, options const &) {
|
2013-08-17 01:34:11 +00:00
|
|
|
std::ostringstream s; s << env; return format(s.str());
|
|
|
|
}
|
|
|
|
};
|
2013-08-17 18:29:43 +00:00
|
|
|
formatter mk_simple_formatter() {
|
|
|
|
return formatter(new simple_formatter_cell());
|
2013-08-17 01:34:11 +00:00
|
|
|
}
|
|
|
|
}
|