2014-06-11 00:02:06 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include <utility>
|
|
|
|
#include <string>
|
|
|
|
#include "frontends/lean/parser_pos_provider.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
parser_pos_provider::parser_pos_provider(pos_info_table_ptr const & pos_table,
|
|
|
|
std::string const & strm_name, pos_info const & some_pos):
|
|
|
|
m_pos_table(pos_table), m_strm_name(strm_name), m_pos(some_pos) {}
|
|
|
|
|
|
|
|
parser_pos_provider::~parser_pos_provider() {}
|
|
|
|
|
2014-08-02 03:17:26 +00:00
|
|
|
optional<pos_info> parser_pos_provider::get_pos_info(expr const & e) const {
|
2014-06-11 00:02:06 +00:00
|
|
|
if (!m_pos_table)
|
2014-08-02 03:17:26 +00:00
|
|
|
return optional<pos_info>();
|
2014-06-11 00:02:06 +00:00
|
|
|
tag t = e.get_tag();
|
|
|
|
if (t == nulltag)
|
2014-08-02 03:17:26 +00:00
|
|
|
return optional<pos_info>();
|
2014-06-11 00:02:06 +00:00
|
|
|
auto it = m_pos_table->find(t);
|
|
|
|
if (it == m_pos_table->end())
|
2014-08-02 03:17:26 +00:00
|
|
|
return optional<pos_info>();
|
|
|
|
return optional<pos_info>(it->second);
|
2014-06-11 00:02:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-02 03:17:26 +00:00
|
|
|
pos_info parser_pos_provider::get_some_pos() const {
|
2014-06-11 00:02:06 +00:00
|
|
|
return m_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
char const * parser_pos_provider::get_file_name() const {
|
|
|
|
return m_strm_name.c_str();
|
|
|
|
}
|
|
|
|
}
|