feat(frontends/lean): allow user to import several theories using a single import
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
fddaa7bc3a
commit
0878b44fc7
6 changed files with 32 additions and 28 deletions
|
@ -1,8 +1,7 @@
|
|||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Author: Leonardo de Moura
|
||||
import macros
|
||||
import tactic
|
||||
import macros tactic
|
||||
|
||||
universe U ≥ 1
|
||||
definition TypeU := (Type U)
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Author: Leonardo de Moura
|
||||
import macros
|
||||
import subtype
|
||||
import tactic
|
||||
import macros subtype tactic
|
||||
using subtype
|
||||
|
||||
namespace num
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Author: Leonardo de Moura
|
||||
import macros
|
||||
import subtype
|
||||
import macros subtype
|
||||
using subtype
|
||||
-- We are encoding the (optional A) as a subset of A → Bool where
|
||||
-- none is the predicate that is false everywhere
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Author: Leonardo de Moura
|
||||
import macros
|
||||
import subtype
|
||||
import optional
|
||||
import macros subtype optional
|
||||
using subtype
|
||||
using optional
|
||||
|
||||
|
|
|
@ -583,26 +583,34 @@ optional<std::string> parser_imp::find_lua_file(std::string const & fname) {
|
|||
}
|
||||
|
||||
void parser_imp::parse_import() {
|
||||
auto p = pos();
|
||||
next();
|
||||
std::string fname;
|
||||
if (curr_is_identifier()) {
|
||||
fname = name_to_file(curr_name());
|
||||
next();
|
||||
} else {
|
||||
fname = check_string_next("invalid import command, string (i.e., file name) or identifier expected");
|
||||
}
|
||||
bool r = false;
|
||||
if (auto lua_fname = find_lua_file(fname)) {
|
||||
if (!m_script_state)
|
||||
throw parser_error(sstream() << "failed to import Lua file '" << *lua_fname << "', parser does not have an intepreter",
|
||||
m_last_cmd_pos);
|
||||
r = m_script_state->import_explicit(lua_fname->c_str());
|
||||
} else {
|
||||
r = m_env->import(fname, m_io_state);
|
||||
}
|
||||
if (m_verbose && r) {
|
||||
regular(m_io_state) << " Imported '" << fname << "'" << endl;
|
||||
unsigned num = 0;
|
||||
while (curr_is_identifier() || curr_is_string()) {
|
||||
std::string fname;
|
||||
if (curr_is_identifier()) {
|
||||
fname = name_to_file(curr_name());
|
||||
next();
|
||||
} else {
|
||||
fname = curr_string();
|
||||
next();
|
||||
}
|
||||
bool r = false;
|
||||
if (auto lua_fname = find_lua_file(fname)) {
|
||||
if (!m_script_state)
|
||||
throw parser_error(sstream() << "failed to import Lua file '" << *lua_fname << "', parser does not have an intepreter",
|
||||
m_last_cmd_pos);
|
||||
r = m_script_state->import_explicit(lua_fname->c_str());
|
||||
} else {
|
||||
r = m_env->import(fname, m_io_state);
|
||||
}
|
||||
if (m_verbose && r) {
|
||||
regular(m_io_state) << " Imported '" << fname << "'" << endl;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (num == 0)
|
||||
throw parser_error("invalid import command, string (i.e., file name) or identifier expected", p);
|
||||
}
|
||||
|
||||
void parser_imp::parse_help() {
|
||||
|
|
|
@ -165,6 +165,8 @@ public:
|
|||
|
||||
/** \brief Return true iff the current token is an identifier */
|
||||
bool curr_is_identifier() const { return curr() == scanner::token::Id; }
|
||||
/** \brief Return true iff the current token is a string literal */
|
||||
bool curr_is_string() const { return curr() == scanner::token::StringVal; }
|
||||
/** \brief Return true iff the current token is a '_" */
|
||||
bool curr_is_placeholder() const { return curr() == scanner::token::Placeholder; }
|
||||
/** \brief Return true iff the current token is a natural number */
|
||||
|
|
Loading…
Reference in a new issue