Added parsing utils to skip PDDL sections.
This commit is contained in:
43
lib/pddlparse/include/pddlparse/detail/parsing/Utils.h
Normal file
43
lib/pddlparse/include/pddlparse/detail/parsing/Utils.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __PDDL_PARSE__DETAIL__PARSE_UTILS_H
|
||||
#define __PDDL_PARSE__DETAIL__PARSE_UTILS_H
|
||||
|
||||
#include <pddlparse/Tokenizer.h>
|
||||
|
||||
namespace pddl
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ParseUtils
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void skipSection(Tokenizer &tokenizer)
|
||||
{
|
||||
size_t openParentheses = 1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
const auto character = tokenizer.currentCharacter();
|
||||
tokenizer.advance();
|
||||
|
||||
if (character == '(')
|
||||
openParentheses++;
|
||||
else if (character == ')')
|
||||
{
|
||||
openParentheses--;
|
||||
|
||||
if (openParentheses == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user