Escaping predicates containing hyphens for ASP output.

This commit is contained in:
2016-05-22 20:19:45 +02:00
parent 4258dfcfd0
commit d8d6998936
4 changed files with 48 additions and 5 deletions

View File

@@ -1,12 +1,15 @@
#ifndef __UTILS__PARSING_H
#define __UTILS__PARSING_H
#include <algorithm>
#include <exception>
#include <iosfwd>
#include <sstream>
#include <string>
#include <typeinfo>
#include <boost/algorithm/string/replace.hpp>
#include <plasp/utils/ParserException.h>
namespace plasp
@@ -56,6 +59,30 @@ void parseExpected(std::istream &istream, const T &expectedValue)
////////////////////////////////////////////////////////////////////////////////////////////////////
inline std::string escapeASP(const std::string &string)
{
auto escaped = string;
boost::replace_all(escaped, "_", "__");
boost::replace_all(escaped, "-", "_h");
return escaped;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline std::string unescapeASP(const std::string &string)
{
auto unescaped = string;
boost::replace_all(unescaped, "_h", "-");
boost::replace_all(unescaped, "__", "_");
return unescaped;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}