patrick
/
plasp
Archived
1
0
Fork 0

Made type warnings non-fatal by default.

This commit is contained in:
Patrick Lühne 2016-06-04 16:42:41 +02:00
parent 813fecbf15
commit 837612bb8d
4 changed files with 81 additions and 1 deletions

View File

@ -10,6 +10,7 @@
#include <plasp/pddl/expressions/Constant.h>
#include <plasp/pddl/expressions/PredicateDeclaration.h>
#include <plasp/pddl/expressions/PrimitiveType.h>
#include <plasp/utils/Logger.h>
namespace plasp
{
@ -31,6 +32,7 @@ class Context
}
utils::Parser &parser;
utils::Logger logger;
expressions::PrimitiveTypes primitiveTypes;
//std::unordered_map<std::string, expressions::PrimitiveType *> primitiveTypesHashMap;

View File

@ -0,0 +1,37 @@
#ifndef __PLASP__UTILS__LOGGER_H
#define __PLASP__UTILS__LOGGER_H
#include <string>
#include <plasp/utils/Parser.h>
namespace plasp
{
namespace utils
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Logger
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class Logger
{
public:
Logger();
void setPedantic(bool isPedantic = true);
void parserWarning(const Parser &parser, const std::string &text);
private:
bool m_isPedantic;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@ -129,7 +129,7 @@ PrimitiveType *PrimitiveType::parseExisting(Context &context)
{
// Primitive type "object" is implicitly declared
if (typeName != "object")
throw ConsistencyException("Primitive type \"" + typeName + "\" used but never declared");
context.logger.parserWarning(context.parser, "Primitive type \"" + typeName + "\" used but never declared");
return create(typeName, context);
}

View File

@ -0,0 +1,41 @@
#include <plasp/utils/Logger.h>
#include <plasp/utils/ParserWarning.h>
namespace plasp
{
namespace utils
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Logger
//
////////////////////////////////////////////////////////////////////////////////////////////////////
Logger::Logger()
: m_isPedantic{false}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Logger::setPedantic(bool isPedantic)
{
m_isPedantic = isPedantic;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Logger::parserWarning(const Parser &parser, const std::string &text)
{
if (m_isPedantic)
throw ParserWarning(parser, text);
std::cerr << "Warning: " << parser.row() << ":" << parser.column() << "\t" << text << std::endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}