feat(frontends/lean/parser): use LEAN_PATH in the Import command
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
8c8cefcb0c
commit
d5dc5cb576
1 changed files with 3 additions and 1 deletions
|
@ -24,6 +24,7 @@ Author: Leonardo de Moura
|
||||||
#include "util/script_state.h"
|
#include "util/script_state.h"
|
||||||
#include "util/script_exception.h"
|
#include "util/script_exception.h"
|
||||||
#include "util/interrupt.h"
|
#include "util/interrupt.h"
|
||||||
|
#include "util/lean_path.h"
|
||||||
#include "util/sexpr/option_declarations.h"
|
#include "util/sexpr/option_declarations.h"
|
||||||
#include "kernel/normalizer.h"
|
#include "kernel/normalizer.h"
|
||||||
#include "kernel/type_checker.h"
|
#include "kernel/type_checker.h"
|
||||||
|
@ -2245,11 +2246,12 @@ class parser::imp {
|
||||||
void parse_import() {
|
void parse_import() {
|
||||||
next();
|
next();
|
||||||
std::string fname = check_string_next("invalid import command, string (i.e., file name) expected");
|
std::string fname = check_string_next("invalid import command, string (i.e., file name) expected");
|
||||||
|
fname = find_file(fname.c_str());
|
||||||
std::ifstream in(fname);
|
std::ifstream in(fname);
|
||||||
if (!in.is_open())
|
if (!in.is_open())
|
||||||
throw parser_error(sstream() << "invalid import command, failed to open file '" << fname << "'", m_last_cmd_pos);
|
throw parser_error(sstream() << "invalid import command, failed to open file '" << fname << "'", m_last_cmd_pos);
|
||||||
if (!m_env->mark_imported(fname.c_str())) {
|
if (!m_env->mark_imported(fname.c_str())) {
|
||||||
diagnostic(m_io_state) << "Module '" << fname << "' has already been imported" << endl;
|
// module already imported
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue