feat(frontends/lean/pp): pretty print '@' explict operator
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
320bc55e85
commit
6e135832d8
2 changed files with 19 additions and 7 deletions
|
@ -14,6 +14,7 @@ Author: Leonardo de Moura
|
||||||
#include "library/expr_pair.h"
|
#include "library/expr_pair.h"
|
||||||
#include "library/placeholder.h"
|
#include "library/placeholder.h"
|
||||||
#include "library/private.h"
|
#include "library/private.h"
|
||||||
|
#include "library/explicit.h"
|
||||||
#include "frontends/lean/pp.h"
|
#include "frontends/lean/pp.h"
|
||||||
#include "frontends/lean/pp_options.h"
|
#include "frontends/lean/pp_options.h"
|
||||||
#include "frontends/lean/token_table.h"
|
#include "frontends/lean/token_table.h"
|
||||||
|
@ -38,6 +39,7 @@ static format g_have_fmt = highlight_keyword(format("have"));
|
||||||
static format g_from_fmt = highlight_keyword(format("from"));
|
static format g_from_fmt = highlight_keyword(format("from"));
|
||||||
static format g_fact_fmt = highlight_keyword(format("[fact]"));
|
static format g_fact_fmt = highlight_keyword(format("[fact]"));
|
||||||
static format g_show_fmt = highlight_keyword(format("show"));
|
static format g_show_fmt = highlight_keyword(format("show"));
|
||||||
|
static format g_explicit_fmt = highlight_keyword(format("@"));
|
||||||
|
|
||||||
name pretty_fn::mk_metavar_name(name const & m) {
|
name pretty_fn::mk_metavar_name(name const & m) {
|
||||||
if (auto it = m_purify_meta_table.find(m))
|
if (auto it = m_purify_meta_table.find(m))
|
||||||
|
@ -381,14 +383,23 @@ auto pretty_fn::pp_show(expr const & e) -> result {
|
||||||
return mk_result(group(r), 0);
|
return mk_result(group(r), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pretty_fn::pp_explicit(expr const & e) -> result {
|
||||||
|
result res_arg = pp_child(get_explicit_arg(e), max_bp());
|
||||||
|
return mk_result(compose(g_explicit_fmt, res_arg.first), max_bp());
|
||||||
|
}
|
||||||
|
|
||||||
auto pretty_fn::pp_macro(expr const & e) -> result {
|
auto pretty_fn::pp_macro(expr const & e) -> result {
|
||||||
// TODO(Leo): have macro annotations
|
if (is_explicit(e)) {
|
||||||
// fix macro<->pp interface
|
return pp_explicit(e);
|
||||||
format r = compose(format("["), format(macro_def(e).get_name()));
|
} else {
|
||||||
for (unsigned i = 0; i < macro_num_args(e); i++)
|
// TODO(Leo): have macro annotations
|
||||||
r += nest(m_indent, compose(line(), pp_child(macro_arg(e, i), max_bp()).first));
|
// fix macro<->pp interface
|
||||||
r += format("]");
|
format r = compose(format("["), format(macro_def(e).get_name()));
|
||||||
return mk_result(group(r));
|
for (unsigned i = 0; i < macro_num_args(e); i++)
|
||||||
|
r += nest(m_indent, compose(line(), pp_child(macro_arg(e, i), max_bp()).first));
|
||||||
|
r += format("]");
|
||||||
|
return mk_result(group(r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pretty_fn::pp(expr const & e) -> result {
|
auto pretty_fn::pp(expr const & e) -> result {
|
||||||
|
|
|
@ -68,6 +68,7 @@ private:
|
||||||
result pp_have(expr const & e);
|
result pp_have(expr const & e);
|
||||||
result pp_show(expr const & e);
|
result pp_show(expr const & e);
|
||||||
result pp_macro(expr const & e);
|
result pp_macro(expr const & e);
|
||||||
|
result pp_explicit(expr const & e);
|
||||||
void set_options_core(options const & o);
|
void set_options_core(options const & o);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue