patrick
/
plasp
Archived
1
0
Fork 0

Minor refactoring to simplify parser classes.

This commit is contained in:
Patrick Lühne 2017-05-10 16:12:37 +02:00
parent d7db0d8ccd
commit c10187f6ba
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
3 changed files with 59 additions and 75 deletions

View File

@ -12,54 +12,52 @@ namespace parsebase
// //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
class CaseSensitiveParserPolicy struct CaseSensitiveParserPolicy
{ {
public: static constexpr char transformCharacter(char c) noexcept
static constexpr char transformCharacter(char c) noexcept {
{ return c;
return c; }
}
static bool isWhiteSpaceCharacter(char c) static bool isWhiteSpaceCharacter(char c)
{ {
return std::iswspace(c); return std::iswspace(c);
} }
static bool isBlankCharacter(char c) static bool isBlankCharacter(char c)
{ {
return std::isblank(c); return std::isblank(c);
} }
static bool isIdentifierCharacter(char c) static bool isIdentifierCharacter(char c)
{ {
return std::isgraph(c); return std::isgraph(c);
} }
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
class CaseInsensitiveParserPolicy struct CaseInsensitiveParserPolicy
{ {
public: static char transformCharacter(char c) noexcept
static char transformCharacter(char c) noexcept {
{ return std::tolower(c);
return std::tolower(c); }
}
static bool isWhiteSpaceCharacter(char c) static bool isWhiteSpaceCharacter(char c)
{ {
return std::iswspace(c); return std::iswspace(c);
} }
static bool isBlankCharacter(char c) static bool isBlankCharacter(char c)
{ {
return std::isblank(c); return std::isblank(c);
} }
static bool isIdentifierCharacter(char c) static bool isIdentifierCharacter(char c)
{ {
return std::isgraph(c); return std::isgraph(c);
} }
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -30,27 +30,14 @@ class Stream
}; };
public: public:
explicit Stream(); Stream();
explicit Stream(std::string streamName, std::istream &istream); explicit Stream(std::string streamName, std::istream &istream);
~Stream() = default;
Stream(const Stream &other) = delete; Stream(const Stream &other) = delete;
Stream &operator=(const Stream &other) = delete; Stream &operator=(const Stream &other) = delete;
Stream(Stream &&other) = default;
Stream(Stream &&other) Stream &operator=(Stream &&other) = default;
: m_stream{std::move(other.m_stream)},
m_delimiters{std::move(other.m_delimiters)}
{
}
Stream &operator=(Stream &&other)
{
m_stream = std::move(other.m_stream);
m_delimiters = std::move(other.m_delimiters);
return *this;
}
~Stream() = default;
void read(std::string streamName, std::istream &istream); void read(std::string streamName, std::istream &istream);
void read(const std::experimental::filesystem::path &path); void read(const std::experimental::filesystem::path &path);

View File

@ -16,32 +16,31 @@ namespace detail
// //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
class PDDLParserPolicy struct PDDLParserPolicy
{ {
public: static char transformCharacter(char c) noexcept
static char transformCharacter(char c) noexcept {
{ return std::tolower(c);
return std::tolower(c); }
}
static bool isWhiteSpaceCharacter(char c) static bool isWhiteSpaceCharacter(char c)
{ {
return std::iswspace(c); return std::iswspace(c);
} }
static bool isBlankCharacter(char c) static bool isBlankCharacter(char c)
{ {
return std::isblank(c); return std::isblank(c);
} }
static bool isIdentifierCharacter(char c) static bool isIdentifierCharacter(char c)
{ {
return c != '?' return c != '?'
&& c != '(' && c != '('
&& c != ')' && c != ')'
&& c != ';' && c != ';'
&& std::isgraph(c); && std::isgraph(c);
} }
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////