Added command-line option for treating warnings as errors or completely ignoring them.

This commit is contained in:
2016-06-13 14:45:31 +02:00
parent fdbcb261df
commit 5c3ea28e48
6 changed files with 157 additions and 56 deletions

View File

@@ -21,12 +21,42 @@ namespace pddl
class Context
{
public:
Context(utils::Parser &parser)
: parser(parser)
Context() = default;
explicit Context(utils::Parser &&parser)
: parser{std::move(parser)}
{
}
utils::Parser &parser;
explicit Context(utils::Logger &&logger)
: logger{std::move(logger)}
{
}
explicit Context(utils::Parser &&parser, utils::Logger &&logger)
: parser{std::move(parser)},
logger{std::move(logger)}
{
}
Context(const Context &other) = delete;
Context &operator=(const Context &other) = delete;
Context(Context &&other)
: parser(std::move(other.parser)),
logger(std::move(other.logger))
{
}
Context &operator=(Context &&other)
{
parser = std::move(other.parser);
logger = std::move(other.logger);
return *this;
}
utils::Parser parser;
utils::Logger logger;
};

View File

@@ -21,12 +21,15 @@ namespace pddl
class Description
{
public:
static Description fromParser(utils::Parser &&parser);
static Description fromContext(Context &&context);
static Description fromStream(std::istream &istream);
static Description fromFile(const std::string &path);
static Description fromFiles(const std::vector<std::string> &paths);
public:
Context &context();
const Context &context() const;
const Domain &domain() const;
bool containsProblem() const;
@@ -35,12 +38,11 @@ class Description
private:
Description();
void parseContent();
void parse();
void findSections();
void checkConsistency();
utils::Parser m_parser;
Context m_context;
utils::Parser::Position m_domainPosition;

View File

@@ -18,15 +18,29 @@ namespace utils
class Logger
{
public:
enum class WarningLevel
{
Normal,
Error,
Ignore
};
public:
Logger();
void setPedantic(bool isPedantic = true);
Logger(const Logger &other);
Logger &operator=(const Logger &other);
Logger(Logger &&other);
Logger &operator=(Logger &&other);
void setWarningLevel(WarningLevel warningLevel);
void parserWarning(const Parser &parser, const std::string &message);
private:
bool m_isPedantic;
WarningLevel m_warningLevel;
};
////////////////////////////////////////////////////////////////////////////////////////////////////