diff --git a/src/frontends/lean/old_elaborator_exception.cpp b/src/frontends/lean/old_elaborator_exception.cpp index f7ef907afc..29b09fa506 100644 --- a/src/frontends/lean/old_elaborator_exception.cpp +++ b/src/frontends/lean/old_elaborator_exception.cpp @@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ -#include "library/generic_exception.h" +#include "library/exception.h" #include "frontends/lean/old_elaborator_exception.h" namespace lean { diff --git a/src/frontends/lean/parser.cpp b/src/frontends/lean/parser.cpp index a3fbf5dc2d..d7bc5fad08 100644 --- a/src/frontends/lean/parser.cpp +++ b/src/frontends/lean/parser.cpp @@ -22,7 +22,7 @@ Author: Leonardo de Moura #include "kernel/instantiate.h" #include "kernel/error_msgs.h" #include "library/trace.h" -#include "library/parser_nested_exception.h" +#include "library/exception.h" #include "library/aliases.h" #include "library/constants.h" #include "library/private.h" diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 62761be937..976c24d855 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(library OBJECT deep_copy.cpp expr_lt.cpp io_state.cpp explicit.cpp num.cpp string.cpp head_map.cpp definition_cache.cpp declaration_index.cpp class.cpp util.cpp print.cpp annotation.cpp quote.cpp typed_expr.cpp protected.cpp reducible.cpp init_module.cpp - generic_exception.cpp fingerprint.cpp flycheck.cpp hott_kernel.cpp pp_options.cpp + exception.cpp fingerprint.cpp flycheck.cpp hott_kernel.cpp pp_options.cpp unfold_macros.cpp app_builder.cpp projection.cpp relation_manager.cpp export.cpp user_recursors.cpp idx_metavar.cpp noncomputable.cpp aux_recursors.cpp norm_num.cpp trace.cpp diff --git a/src/library/class_instance_resolution.cpp b/src/library/class_instance_resolution.cpp index 1fad676e31..c811ffbd2e 100644 --- a/src/library/class_instance_resolution.cpp +++ b/src/library/class_instance_resolution.cpp @@ -17,7 +17,7 @@ Author: Leonardo de Moura #include "library/reducible.h" #include "library/class.h" #include "library/old_local_context.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/io_state_stream.h" #include "library/replace_visitor.h" #include "library/constants.h" diff --git a/src/library/equations_compiler/elim_match.cpp b/src/library/equations_compiler/elim_match.cpp index 5a28a316a0..28518732ee 100644 --- a/src/library/equations_compiler/elim_match.cpp +++ b/src/library/equations_compiler/elim_match.cpp @@ -15,7 +15,7 @@ Author: Leonardo de Moura #include "library/num.h" #include "library/string.h" #include "library/pp_options.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/util.h" #include "library/locals.h" #include "library/app_builder.h" diff --git a/src/library/equations_compiler/equations.cpp b/src/library/equations_compiler/equations.cpp index 113e183ed9..aab2f7e2df 100644 --- a/src/library/equations_compiler/equations.cpp +++ b/src/library/equations_compiler/equations.cpp @@ -17,7 +17,7 @@ Author: Leonardo de Moura #include "kernel/for_each_fn.h" #include "kernel/find_fn.h" #include "kernel/replace_fn.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/kernel_serializer.h" #include "library/io_state_stream.h" #include "library/annotation.h" diff --git a/src/library/equations_compiler/old_compiler.cpp b/src/library/equations_compiler/old_compiler.cpp index 95defa5325..c8fa5e9ba0 100644 --- a/src/library/equations_compiler/old_compiler.cpp +++ b/src/library/equations_compiler/old_compiler.cpp @@ -17,7 +17,7 @@ Author: Leonardo de Moura #include "kernel/for_each_fn.h" #include "kernel/find_fn.h" #include "kernel/replace_fn.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/kernel_serializer.h" #include "library/io_state_stream.h" #include "library/annotation.h" diff --git a/src/library/error_handling.cpp b/src/library/error_handling.cpp index e5bc246cb3..718a7ab9d1 100644 --- a/src/library/error_handling.cpp +++ b/src/library/error_handling.cpp @@ -11,7 +11,7 @@ Author: Leonardo de Moura #include "kernel/for_each_fn.h" #include "library/io_state_stream.h" #include "library/unifier.h" -#include "library/parser_nested_exception.h" +#include "library/exception.h" #include "library/flycheck.h" #include "library/pp_options.h" #include "library/error_handling.h" diff --git a/src/library/generic_exception.cpp b/src/library/exception.cpp similarity index 97% rename from src/library/generic_exception.cpp rename to src/library/exception.cpp index 62c37f17c2..620a3d5909 100644 --- a/src/library/generic_exception.cpp +++ b/src/library/exception.cpp @@ -5,7 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include -#include "library/generic_exception.h" +#include "library/exception.h" namespace lean { diff --git a/src/library/generic_exception.h b/src/library/exception.h similarity index 66% rename from src/library/generic_exception.h rename to src/library/exception.h index 350d703e4d..a9014a7518 100644 --- a/src/library/generic_exception.h +++ b/src/library/exception.h @@ -8,6 +8,7 @@ Author: Leonardo de Moura #include #include "util/sstream.h" #include "kernel/ext_exception.h" +#include "kernel/pos_info_provider.h" namespace lean { class generic_exception : public ext_exception { @@ -34,4 +35,19 @@ public: [[ noreturn ]] void throw_generic_exception(char const * msg, expr const & m, pp_fn const & fn); [[ noreturn ]] void throw_generic_exception(optional const & m, pp_fn const & fn); [[ noreturn ]] void throw_generic_exception(expr const & m, pp_fn const & fn); + +/** \brief Lean exception occurred when parsing file. */ +class parser_nested_exception : public exception { + std::shared_ptr m_exception; + std::shared_ptr m_provider; +public: + parser_nested_exception(std::shared_ptr const & ex, std::shared_ptr const & pr): + exception("parser exception"), m_exception(ex), m_provider(pr) {} + virtual ~parser_nested_exception() {} + virtual throwable * clone() const { return new parser_nested_exception(m_exception, m_provider); } + virtual void rethrow() const { throw *this; } + virtual char const * what() const noexcept { return m_exception->what(); } + throwable const & get_exception() const { return *(m_exception.get()); } + pos_info_provider const & get_provider() const { return *(m_provider.get()); } +}; } diff --git a/src/library/io_state_stream.h b/src/library/io_state_stream.h index 478cfc51f3..08c6e67035 100644 --- a/src/library/io_state_stream.h +++ b/src/library/io_state_stream.h @@ -9,7 +9,7 @@ Author: Leonardo de Moura #include "kernel/environment.h" #include "kernel/ext_exception.h" #include "kernel/abstract_type_context.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/io_state.h" #include "library/constraint.h" diff --git a/src/library/old_type_context.cpp b/src/library/old_type_context.cpp index acca4f2b61..2e726e9f72 100644 --- a/src/library/old_type_context.cpp +++ b/src/library/old_type_context.cpp @@ -21,7 +21,7 @@ Author: Leonardo de Moura #include "library/old_type_context.h" #include "library/pp_options.h" #include "library/reducible.h" -#include "library/generic_exception.h" +#include "library/exception.h" #include "library/class.h" #include "library/constants.h" #include "library/unification_hint.h" diff --git a/src/library/parser_nested_exception.h b/src/library/parser_nested_exception.h deleted file mode 100644 index 47699622d7..0000000000 --- a/src/library/parser_nested_exception.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright (c) 2013 Microsoft Corporation. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. - -Author: Leonardo de Moura -*/ -#include -#include "util/exception.h" -#include "kernel/pos_info_provider.h" - -namespace lean { -/** \brief Lean exception occurred when parsing file. */ -class parser_nested_exception : public exception { - std::shared_ptr m_exception; - std::shared_ptr m_provider; -public: - parser_nested_exception(std::shared_ptr const & ex, std::shared_ptr const & pr): - exception("parser exception"), m_exception(ex), m_provider(pr) {} - virtual ~parser_nested_exception() {} - virtual throwable * clone() const { return new parser_nested_exception(m_exception, m_provider); } - virtual void rethrow() const { throw *this; } - virtual char const * what() const noexcept { return m_exception->what(); } - throwable const & get_exception() const { return *(m_exception.get()); } - pos_info_provider const & get_provider() const { return *(m_provider.get()); } -}; -} diff --git a/src/library/unfold_macros.cpp b/src/library/unfold_macros.cpp index d587ea7b40..88d3d60a3a 100644 --- a/src/library/unfold_macros.cpp +++ b/src/library/unfold_macros.cpp @@ -13,7 +13,7 @@ Author: Leonardo de Moura #include "kernel/abstract.h" #include "library/unfold_macros.h" #include "library/replace_visitor.h" -#include "library/generic_exception.h" +#include "library/exception.h" namespace lean { class unfold_untrusted_macros_fn {