feat(frontends/lean): add 'print metaclasses' command

This commit is contained in:
Leonardo de Moura 2015-02-11 10:12:45 -08:00
parent 2cbaf1bbe3
commit 9d1cd073c5
4 changed files with 16 additions and 0 deletions

View file

@ -156,6 +156,13 @@ static void print_notation(parser & p) {
p.regular_stream() << "no notation" << endl;
}
static void print_metaclasses(parser & p) {
buffer<name> c;
get_metaclasses(c);
for (name const & n : c)
p.regular_stream() << "[" << n << "]" << endl;
}
environment print_cmd(parser & p) {
flycheck_information info(p.regular_stream());
if (info.enabled()) {
@ -212,6 +219,9 @@ environment print_cmd(parser & p) {
if (p.curr_is_identifier())
C = p.check_constant_next("invalid 'print coercions', constant expected");
print_coercions(p, C);
} else if (p.curr_is_token_or_id(get_metaclasses_tk())) {
p.next();
print_metaclasses(p);
} else if (p.curr_is_token_or_id(get_axioms_tk())) {
p.next();
print_axioms(p);

View file

@ -122,6 +122,7 @@ static name * g_persistent = nullptr;
static name * g_root = nullptr;
static name * g_fields = nullptr;
static name * g_trust = nullptr;
static name * g_metaclasses = nullptr;
void initialize_tokens() {
g_period = new name(".");
@ -239,9 +240,11 @@ void initialize_tokens() {
g_root = new name("_root_");
g_fields = new name("fields");
g_trust = new name("trust");
g_metaclasses = new name("metaclasses");
}
void finalize_tokens() {
delete g_metaclasses;
delete g_persistent;
delete g_root;
delete g_fields;
@ -359,6 +362,7 @@ void finalize_tokens() {
delete g_period;
}
name const & get_metaclasses_tk() { return *g_metaclasses; }
name const & get_period_tk() { return *g_period; }
name const & get_placeholder_tk() { return *g_placeholder; }
name const & get_colon_tk() { return *g_colon; }

View file

@ -124,4 +124,5 @@ name const & get_persistent_tk();
name const & get_root_tk();
name const & get_fields_tk();
name const & get_trust_tk();
name const & get_metaclasses_tk();
}

1
tests/lean/run/meta.lean Normal file
View file

@ -0,0 +1 @@
print metaclasses