feat(frontends/lean): add 'print aliases' command
This commit is contained in:
parent
53a05e845e
commit
0acdcd487b
5 changed files with 23 additions and 1 deletions
|
@ -22,7 +22,7 @@
|
||||||
"instances" "coercions" "metaclasses" "raw" "migrate" "replacing"
|
"instances" "coercions" "metaclasses" "raw" "migrate" "replacing"
|
||||||
"calc" "have" "show" "suffices" "by" "in" "at" "let" "forall" "Pi" "fun"
|
"calc" "have" "show" "suffices" "by" "in" "at" "let" "forall" "Pi" "fun"
|
||||||
"exists" "if" "dif" "then" "else" "assume" "assert" "take"
|
"exists" "if" "dif" "then" "else" "assume" "assert" "take"
|
||||||
"obtain" "from")
|
"obtain" "from" "aliases")
|
||||||
"lean keywords ending with 'word' (not symbol)")
|
"lean keywords ending with 'word' (not symbol)")
|
||||||
(defconst lean-keywords1-regexp
|
(defconst lean-keywords1-regexp
|
||||||
(eval `(rx word-start (or ,@lean-keywords1) word-end)))
|
(eval `(rx word-start (or ,@lean-keywords1) word-end)))
|
||||||
|
|
|
@ -595,6 +595,19 @@ static void print_no_patterns(parser & p) {
|
||||||
out << "\n";
|
out << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_aliases(parser const & p) {
|
||||||
|
io_state_stream out = p.regular_stream();
|
||||||
|
for_each_expr_alias(p.env(), [&](name const & n, list<name> const & as) {
|
||||||
|
out << n << " -> {";
|
||||||
|
bool first = true;
|
||||||
|
for (name const & a : as) {
|
||||||
|
if (first) first = false; else out << ", ";
|
||||||
|
out << a;
|
||||||
|
}
|
||||||
|
out << "}\n";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
environment print_cmd(parser & p) {
|
environment print_cmd(parser & p) {
|
||||||
flycheck_information info(p.regular_stream());
|
flycheck_information info(p.regular_stream());
|
||||||
if (info.enabled()) {
|
if (info.enabled()) {
|
||||||
|
@ -676,6 +689,9 @@ environment print_cmd(parser & p) {
|
||||||
} else if (p.curr_is_token_or_id(get_prefix_tk())) {
|
} else if (p.curr_is_token_or_id(get_prefix_tk())) {
|
||||||
p.next();
|
p.next();
|
||||||
print_prefix(p);
|
print_prefix(p);
|
||||||
|
} else if (p.curr_is_token_or_id(get_aliases_tk())) {
|
||||||
|
p.next();
|
||||||
|
print_aliases(p);
|
||||||
} else if (p.curr_is_token_or_id(get_coercions_tk())) {
|
} else if (p.curr_is_token_or_id(get_coercions_tk())) {
|
||||||
p.next();
|
p.next();
|
||||||
optional<name> C;
|
optional<name> C;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// DO NOT EDIT, automatically generated file, generator scripts/gen_tokens_cpp.py
|
// DO NOT EDIT, automatically generated file, generator scripts/gen_tokens_cpp.py
|
||||||
#include "util/name.h"
|
#include "util/name.h"
|
||||||
namespace lean{
|
namespace lean{
|
||||||
|
static name const * g_aliases_tk = nullptr;
|
||||||
static name const * g_period_tk = nullptr;
|
static name const * g_period_tk = nullptr;
|
||||||
static name const * g_placeholder_tk = nullptr;
|
static name const * g_placeholder_tk = nullptr;
|
||||||
static name const * g_colon_tk = nullptr;
|
static name const * g_colon_tk = nullptr;
|
||||||
|
@ -163,6 +164,7 @@ static name const * g_this_tk = nullptr;
|
||||||
static name const * g_noncomputable_tk = nullptr;
|
static name const * g_noncomputable_tk = nullptr;
|
||||||
static name const * g_theory_tk = nullptr;
|
static name const * g_theory_tk = nullptr;
|
||||||
void initialize_tokens() {
|
void initialize_tokens() {
|
||||||
|
g_aliases_tk = new name{"aliases"};
|
||||||
g_period_tk = new name{"."};
|
g_period_tk = new name{"."};
|
||||||
g_placeholder_tk = new name{"_"};
|
g_placeholder_tk = new name{"_"};
|
||||||
g_colon_tk = new name{":"};
|
g_colon_tk = new name{":"};
|
||||||
|
@ -324,6 +326,7 @@ void initialize_tokens() {
|
||||||
g_theory_tk = new name{"theory"};
|
g_theory_tk = new name{"theory"};
|
||||||
}
|
}
|
||||||
void finalize_tokens() {
|
void finalize_tokens() {
|
||||||
|
delete g_aliases_tk;
|
||||||
delete g_period_tk;
|
delete g_period_tk;
|
||||||
delete g_placeholder_tk;
|
delete g_placeholder_tk;
|
||||||
delete g_colon_tk;
|
delete g_colon_tk;
|
||||||
|
@ -484,6 +487,7 @@ void finalize_tokens() {
|
||||||
delete g_noncomputable_tk;
|
delete g_noncomputable_tk;
|
||||||
delete g_theory_tk;
|
delete g_theory_tk;
|
||||||
}
|
}
|
||||||
|
name const & get_aliases_tk() { return *g_aliases_tk; }
|
||||||
name const & get_period_tk() { return *g_period_tk; }
|
name const & get_period_tk() { return *g_period_tk; }
|
||||||
name const & get_placeholder_tk() { return *g_placeholder_tk; }
|
name const & get_placeholder_tk() { return *g_placeholder_tk; }
|
||||||
name const & get_colon_tk() { return *g_colon_tk; }
|
name const & get_colon_tk() { return *g_colon_tk; }
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
namespace lean {
|
namespace lean {
|
||||||
void initialize_tokens();
|
void initialize_tokens();
|
||||||
void finalize_tokens();
|
void finalize_tokens();
|
||||||
|
name const & get_aliases_tk();
|
||||||
name const & get_period_tk();
|
name const & get_period_tk();
|
||||||
name const & get_placeholder_tk();
|
name const & get_placeholder_tk();
|
||||||
name const & get_colon_tk();
|
name const & get_colon_tk();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
aliases aliases
|
||||||
period .
|
period .
|
||||||
placeholder _
|
placeholder _
|
||||||
colon :
|
colon :
|
||||||
|
|
Loading…
Reference in a new issue