6 #include <boost/spirit/include/qi.hpp>
7 #include "knowrob/queries/QueryParser.h"
8 #include "knowrob/queries/QueryError.h"
9 #include "knowrob/queries/parsers/strings.h"
10 #include "knowrob/queries/parsers/terms.h"
11 #include "knowrob/queries/parsers/formula.h"
12 #include "knowrob/integration/python/utils.h"
13 #include "knowrob/formulas/ModalFormula.h"
14 #include "knowrob/queries/parsers/graph.h"
18 template<
typename ResultType,
typename RuleType>
19 static inline ResultType parse_(
const std::string &queryString,
const RuleType &rule) {
20 auto first = queryString.begin();
21 auto last = queryString.end();
24 bool r = boost::spirit::qi::phrase_parse(first, last, rule, boost::spirit::ascii::space, result);
26 if (first == last && r) {
29 throw QueryError(
"Query string ({}) has invalid syntax.", queryString);
34 return parse_<FormulaPtr, knowrob::parsers::formula::FormulaRule>(queryString,
39 return parse_<PredicatePtr, knowrob::parsers::formula::PredicateRule>(queryString,
64 class_<QueryParser, boost::noncopyable>
65 (
"QueryParser", no_init)
static TermPtr parseConstant(const std::string &queryString)
static std::string parseRawAtom(const std::string &queryString)
static FunctionPtr parseFunction(const std::string &queryString)
static std::shared_ptr< GraphTerm > parseGraphTerm(const std::string &queryString)
static FormulaPtr parse(const std::string &queryString)
static PredicatePtr parsePredicate(const std::string &queryString)
boost::spirit::qi::rule< std::string::const_iterator, std::shared_ptr< GraphTerm >(), boost::spirit::ascii::space_type > GraphTermRule
GraphTermRule & graphTerm()
StringRule & atom_or_iri()
FunctionRule & function()
void createType< QueryParser >()
std::shared_ptr< Term > TermPtr
std::shared_ptr< Formula > FormulaPtr
std::shared_ptr< Predicate > PredicatePtr
std::shared_ptr< Function > FunctionPtr