fix(frontends/lean): memory access violation
This commit is contained in:
parent
45684588cc
commit
01f8f3c11d
3 changed files with 10 additions and 8 deletions
|
@ -415,14 +415,16 @@ environment override_notation(environment const & env, name const & n, bool pers
|
||||||
environment r = env;
|
environment r = env;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (auto it = token_ext::get_entries(r, n)) {
|
if (auto it = token_ext::get_entries(r, n)) {
|
||||||
|
list<token_entry> entries = *it;
|
||||||
found = true;
|
found = true;
|
||||||
for (token_entry e : *it) {
|
for (token_entry e : entries) {
|
||||||
r = add_token(r, e, persistent);
|
r = add_token(r, e, persistent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auto it = notation_ext::get_entries(env, n)) {
|
if (auto it = notation_ext::get_entries(env, n)) {
|
||||||
|
list<notation_entry> entries = *it;
|
||||||
found = true;
|
found = true;
|
||||||
for (notation_entry const & e : *it) {
|
for (notation_entry const & e : entries) {
|
||||||
notation_entry new_e(e, false);
|
notation_entry new_e(e, false);
|
||||||
r = add_notation(r, new_e, persistent);
|
r = add_notation(r, new_e, persistent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,8 +403,8 @@ auto scanner::read_key_cmd_id() -> token_kind {
|
||||||
return token_kind::Identifier;
|
return token_kind::Identifier;
|
||||||
} else {
|
} else {
|
||||||
move_back(cs.size() - key_sz, num_utfs - key_utf_sz);
|
move_back(cs.size() - key_sz, num_utfs - key_utf_sz);
|
||||||
m_token_info = info;
|
m_token_info = *info;
|
||||||
return info->is_command() ? token_kind::CommandKeyword : token_kind::Keyword;
|
return m_token_info.is_command() ? token_kind::CommandKeyword : token_kind::Keyword;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ auto scanner::scan(environment const & env) -> token_kind {
|
||||||
token_kind k = read_key_cmd_id();
|
token_kind k = read_key_cmd_id();
|
||||||
if (k == token_kind::Keyword) {
|
if (k == token_kind::Keyword) {
|
||||||
// We treat '(--', '(*', '--' as "keywords.
|
// We treat '(--', '(*', '--' as "keywords.
|
||||||
name const & n = m_token_info->value();
|
name const & n = m_token_info.value();
|
||||||
if (n == *g_begin_comment_tk)
|
if (n == *g_begin_comment_tk)
|
||||||
read_single_line_comment();
|
read_single_line_comment();
|
||||||
else if (n == *g_begin_comment_block_tk)
|
else if (n == *g_begin_comment_block_tk)
|
||||||
|
@ -465,7 +465,7 @@ auto scanner::scan(environment const & env) -> token_kind {
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner::scanner(std::istream & strm, char const * strm_name, unsigned line):
|
scanner::scanner(std::istream & strm, char const * strm_name, unsigned line):
|
||||||
m_tokens(nullptr), m_stream(strm), m_token_info(nullptr) {
|
m_tokens(nullptr), m_stream(strm) {
|
||||||
m_stream_name = strm_name ? strm_name : "[unknown]";
|
m_stream_name = strm_name ? strm_name : "[unknown]";
|
||||||
m_sline = line;
|
m_sline = line;
|
||||||
m_line = line;
|
m_line = line;
|
||||||
|
|
|
@ -40,7 +40,7 @@ protected:
|
||||||
int m_line; // line of the token
|
int m_line; // line of the token
|
||||||
|
|
||||||
name m_name_val;
|
name m_name_val;
|
||||||
token_info const * m_token_info;
|
token_info m_token_info;
|
||||||
mpq m_num_val;
|
mpq m_num_val;
|
||||||
std::string m_buffer;
|
std::string m_buffer;
|
||||||
std::string m_aux_buffer;
|
std::string m_aux_buffer;
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
mpq const & get_num_val() const { return m_num_val; }
|
mpq const & get_num_val() const { return m_num_val; }
|
||||||
name const & get_name_val() const { return m_name_val; }
|
name const & get_name_val() const { return m_name_val; }
|
||||||
std::string const & get_str_val() const { return m_buffer; }
|
std::string const & get_str_val() const { return m_buffer; }
|
||||||
token_info const & get_token_info() const { lean_assert(m_token_info); return *m_token_info; }
|
token_info const & get_token_info() const { return m_token_info; }
|
||||||
|
|
||||||
std::string const & get_stream_name() const { return m_stream_name; }
|
std::string const & get_stream_name() const { return m_stream_name; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue