Fixed further white space issue with empty n-ary predicates.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <plasp/pddl/ConsistencyException.h>
|
||||
#include <plasp/pddl/Context.h>
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Identifier.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
|
||||
namespace plasp
|
||||
@@ -48,7 +49,7 @@ std::unique_ptr<Derived> Binary<Derived>::parse(Context &context,
|
||||
const auto position = parser.position();
|
||||
|
||||
if (!parser.probe<std::string>("(")
|
||||
|| !parser.probeIdentifier(Derived::Identifier))
|
||||
|| !parser.probeIdentifier(Derived::Identifier, isIdentifier))
|
||||
{
|
||||
parser.seek(position);
|
||||
return nullptr;
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <plasp/pddl/ConsistencyException.h>
|
||||
#include <plasp/pddl/Context.h>
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Identifier.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
|
||||
namespace plasp
|
||||
@@ -46,7 +47,7 @@ std::unique_ptr<Derived> NAry<Derived>::parse(Context &context,
|
||||
const auto position = parser.position();
|
||||
|
||||
if (!parser.probe<std::string>("(")
|
||||
|| !parser.probeIdentifier(Derived::Identifier))
|
||||
|| !parser.probeIdentifier(Derived::Identifier, isIdentifier))
|
||||
{
|
||||
parser.seek(position);
|
||||
return nullptr;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <plasp/pddl/Context.h>
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Identifier.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
@@ -44,7 +45,7 @@ NotPointer Not::parse(Context &context, ExpressionContext &expressionContext,
|
||||
const auto position = parser.position();
|
||||
|
||||
if (!parser.probe<std::string>("(")
|
||||
|| !parser.probeIdentifier("not"))
|
||||
|| !parser.probeIdentifier("not", isIdentifier))
|
||||
{
|
||||
parser.seek(position);
|
||||
return nullptr;
|
||||
|
@@ -67,7 +67,8 @@ class Parser
|
||||
template<typename Type>
|
||||
bool probe(const Type &expectedValue);
|
||||
|
||||
bool probeIdentifier(const std::string &identifier);
|
||||
template<class CharacterPredicate>
|
||||
bool probeIdentifier(const std::string &identifier, CharacterPredicate characterPredicate);
|
||||
|
||||
template<typename Type>
|
||||
void expect(const Type &expectedValue);
|
||||
@@ -130,6 +131,14 @@ std::string Parser::parseIdentifier(CharacterPredicate characterPredicate)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class CharacterPredicate>
|
||||
bool Parser::probeIdentifier(const std::string &expectedValue, CharacterPredicate characterPredicate)
|
||||
{
|
||||
return probe<std::string>(expectedValue) && !characterPredicate(currentCharacter());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class WhiteSpacePredicate>
|
||||
void Parser::skipWhiteSpace(WhiteSpacePredicate whiteSpacePredicate)
|
||||
{
|
||||
|
Reference in New Issue
Block a user