2013-07-16 01:43:32 +00:00
|
|
|
/*
|
2013-07-19 17:29:33 +00:00
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
2013-07-16 01:43:32 +00:00
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
2013-07-19 17:29:33 +00:00
|
|
|
Author: Leonardo de Moura
|
2013-07-16 01:43:32 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <exception>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace lean {
|
2013-08-15 17:46:13 +00:00
|
|
|
/** \brief Base class for all Lean exceptions */
|
2013-07-16 01:43:32 +00:00
|
|
|
class exception : public std::exception {
|
2013-08-13 17:55:41 +00:00
|
|
|
protected:
|
2013-07-16 01:43:32 +00:00
|
|
|
std::string m_msg;
|
|
|
|
public:
|
|
|
|
exception(char const * msg);
|
|
|
|
exception(std::string const & msg);
|
|
|
|
exception(exception const & ex);
|
2013-07-17 00:38:51 +00:00
|
|
|
virtual ~exception() noexcept;
|
2013-07-16 01:43:32 +00:00
|
|
|
virtual char const * what() const noexcept;
|
|
|
|
};
|
2013-08-15 17:46:13 +00:00
|
|
|
/** \brief Exception produced by a Lean parser. */
|
2013-08-13 17:55:41 +00:00
|
|
|
class parser_exception : public exception {
|
|
|
|
protected:
|
|
|
|
unsigned m_line;
|
|
|
|
unsigned m_pos;
|
|
|
|
public:
|
|
|
|
parser_exception(char const * msg, unsigned l, unsigned p);
|
|
|
|
parser_exception(std::string const & msg, unsigned l, unsigned p);
|
|
|
|
parser_exception(parser_exception const & ex);
|
|
|
|
virtual ~parser_exception() noexcept;
|
|
|
|
virtual char const * what() const noexcept;
|
|
|
|
unsigned get_line() const { return m_line; }
|
|
|
|
unsigned get_pos() const { return m_pos; }
|
|
|
|
};
|
2013-07-16 01:43:32 +00:00
|
|
|
}
|