Prepared exceptions to have different types.

This commit is contained in:
Patrick Lühne 2017-06-17 22:06:18 +02:00
parent da2a3eefa4
commit 7ead2277e8
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
16 changed files with 38 additions and 30 deletions

View File

@ -1,5 +1,5 @@
#ifndef __PDDL_PARSE__PARSER_EXCEPTION_H #ifndef __PDDL_PARSE__EXCEPTION_H
#define __PDDL_PARSE__PARSER_EXCEPTION_H #define __PDDL_PARSE__EXCEPTION_H
#include <exception> #include <exception>
#include <string> #include <string>
@ -11,39 +11,39 @@ namespace pddl
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// ParserException // Exception
// //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException: public std::exception class Exception: public std::exception
{ {
public: public:
explicit ParserException() explicit Exception()
: ParserException("unspecified parser error") : Exception("unspecified parser error")
{ {
} }
explicit ParserException(const char *message) explicit Exception(const char *message)
: ParserException(static_cast<std::string>(message)) : Exception(static_cast<std::string>(message))
{ {
} }
explicit ParserException(const std::string &message) explicit Exception(const std::string &message)
: m_message{message} : m_message{message}
{ {
} }
explicit ParserException(const tokenize::Location &location) explicit Exception(const tokenize::Location &location)
: ParserException(location, "unspecified parser error") : Exception(location, "unspecified parser error")
{ {
} }
explicit ParserException(const tokenize::Location &location, const char *message) explicit Exception(const tokenize::Location &location, const char *message)
: ParserException(location, static_cast<std::string>(message)) : Exception(location, static_cast<std::string>(message))
{ {
} }
explicit ParserException(const tokenize::Location &location, const std::string &message) explicit Exception(const tokenize::Location &location, const std::string &message)
: m_location{location}, : m_location{location},
m_message{message}, m_message{message},
// TODO: refactor // TODO: refactor
@ -52,7 +52,7 @@ class ParserException: public std::exception
{ {
} }
~ParserException() noexcept = default; ~Exception() noexcept = default;
const char *what() const throw() const char *what() const throw()
{ {
@ -77,6 +77,14 @@ class ParserException: public std::exception
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException : public Exception
{
public:
using Exception::Exception;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
} }
#endif #endif

View File

@ -3,7 +3,7 @@
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/Context.h> #include <pddlparse/Context.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTContext.h> #include <pddlparse/detail/ASTContext.h>
#include <pddlparse/detail/VariableStack.h> #include <pddlparse/detail/VariableStack.h>
#include <pddlparse/detail/parsing/VariableDeclaration.h> #include <pddlparse/detail/parsing/VariableDeclaration.h>

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/Action.h> #include <pddlparse/detail/parsing/Action.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTContext.h> #include <pddlparse/detail/ASTContext.h>
#include <pddlparse/detail/VariableStack.h> #include <pddlparse/detail/VariableStack.h>
#include <pddlparse/detail/parsing/Effect.h> #include <pddlparse/detail/parsing/Effect.h>

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/Constant.h> #include <pddlparse/detail/parsing/Constant.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
namespace pddl namespace pddl
{ {

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/ConstantDeclaration.h> #include <pddlparse/detail/parsing/ConstantDeclaration.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTCopy.h> #include <pddlparse/detail/ASTCopy.h>
#include <pddlparse/detail/parsing/PrimitiveType.h> #include <pddlparse/detail/parsing/PrimitiveType.h>

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/Description.h> #include <pddlparse/detail/parsing/Description.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/parsing/Domain.h> #include <pddlparse/detail/parsing/Domain.h>
#include <pddlparse/detail/parsing/Problem.h> #include <pddlparse/detail/parsing/Problem.h>
#include <pddlparse/detail/parsing/Utils.h> #include <pddlparse/detail/parsing/Utils.h>

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/Domain.h> #include <pddlparse/detail/parsing/Domain.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/Requirements.h> #include <pddlparse/detail/Requirements.h>
#include <pddlparse/detail/parsing/Action.h> #include <pddlparse/detail/parsing/Action.h>
#include <pddlparse/detail/parsing/ConstantDeclaration.h> #include <pddlparse/detail/parsing/ConstantDeclaration.h>

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/InitialState.h> #include <pddlparse/detail/parsing/InitialState.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/parsing/Fact.h> #include <pddlparse/detail/parsing/Fact.h>
namespace pddl namespace pddl

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/PredicateDeclaration.h> #include <pddlparse/detail/parsing/PredicateDeclaration.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTContext.h> #include <pddlparse/detail/ASTContext.h>
#include <pddlparse/detail/parsing/VariableDeclaration.h> #include <pddlparse/detail/parsing/VariableDeclaration.h>

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/PrimitiveType.h> #include <pddlparse/detail/parsing/PrimitiveType.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/Requirements.h> #include <pddlparse/detail/Requirements.h>
namespace pddl namespace pddl

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/PrimitiveTypeDeclaration.h> #include <pddlparse/detail/parsing/PrimitiveTypeDeclaration.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTCopy.h> #include <pddlparse/detail/ASTCopy.h>
#include <pddlparse/detail/parsing/PrimitiveType.h> #include <pddlparse/detail/parsing/PrimitiveType.h>

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/Problem.h> #include <pddlparse/detail/parsing/Problem.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/Requirements.h> #include <pddlparse/detail/Requirements.h>
#include <pddlparse/detail/parsing/ConstantDeclaration.h> #include <pddlparse/detail/parsing/ConstantDeclaration.h>
#include <pddlparse/detail/parsing/InitialState.h> #include <pddlparse/detail/parsing/InitialState.h>

View File

@ -4,7 +4,7 @@
#include <map> #include <map>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
namespace pddl namespace pddl
{ {

View File

@ -1,6 +1,6 @@
#include <pddlparse/detail/parsing/Type.h> #include <pddlparse/detail/parsing/Type.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/parsing/Expressions.h> #include <pddlparse/detail/parsing/Expressions.h>
#include <pddlparse/detail/parsing/PrimitiveType.h> #include <pddlparse/detail/parsing/PrimitiveType.h>

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/Variable.h> #include <pddlparse/detail/parsing/Variable.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
namespace pddl namespace pddl
{ {

View File

@ -1,7 +1,7 @@
#include <pddlparse/detail/parsing/VariableDeclaration.h> #include <pddlparse/detail/parsing/VariableDeclaration.h>
#include <pddlparse/AST.h> #include <pddlparse/AST.h>
#include <pddlparse/ParserException.h> #include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTCopy.h> #include <pddlparse/detail/ASTCopy.h>
#include <pddlparse/detail/parsing/Type.h> #include <pddlparse/detail/parsing/Type.h>