6 #include <boost/spirit/include/phoenix.hpp>
7 #include "knowrob/queries/parsers/common.h"
8 #include "knowrob/queries/parsers/graph.h"
9 #include "knowrob/queries/parsers/terms.h"
10 #include "knowrob/queries/parsers/strings.h"
11 #include "knowrob/Logger.h"
12 #include "knowrob/semweb/GraphPattern.h"
13 #include "knowrob/semweb/GraphBuiltin.h"
15 #define RETURN_GRAPH_PAT_RULE(expr) static GraphTermRule r(expr); return r
21 namespace qi = boost::spirit::qi;
28 struct graph_parsers_struct {
29 graph_parsers_struct() {
30 using namespace boost::phoenix;
32 term %= disjunction | brackets;
33 brackets %= (
'(' >>
term >>
')');
35 disjunction = (((conjunction | brackets)
36 >> (qi::char_(
';') | qi::char_(
'|'))
37 >> (disjunction | brackets))
38 [qi::_val = (qi::_1 | qi::_3)]
39 | conjunction[qi::_val = qi::_1]);
40 conjunction = (((
atomic | brackets)
41 >> (qi::char_(
',') | qi::char_(
'&'))
42 >> (conjunction | brackets))
43 [qi::_val = (qi::_1 & qi::_3)]
44 |
atomic[qi::_val = qi::_1]);
47 builtin %= less | greater | leq | geq | eq | neq | bindCmd | min | max;
69 GraphTermRule less, greater, leq, geq, eq, neq, bindCmd, min, max;
73 static graph_parsers_struct p;
static BuiltinPtr greaterOrEqual(const TermPtr &a, const TermPtr &b)
static BuiltinPtr max(const VariablePtr &var, const TermPtr &a, const TermPtr &b)
static BuiltinPtr lessOrEqual(const TermPtr &a, const TermPtr &b)
static BuiltinPtr equal(const TermPtr &a, const TermPtr &b)
static BuiltinPtr notEqual(const TermPtr &a, const TermPtr &b)
static BuiltinPtr less(const TermPtr &a, const TermPtr &b)
static BuiltinPtr bind(const VariablePtr &var, const TermPtr &val)
static BuiltinPtr greater(const TermPtr &a, const TermPtr &b)
static BuiltinPtr min(const VariablePtr &var, const TermPtr &a, const TermPtr &b)
#define RETURN_GRAPH_PAT_RULE(expr)
boost::spirit::qi::rule< std::string::const_iterator, std::shared_ptr< GraphTerm >(), boost::spirit::ascii::space_type > GraphTermRule
GraphTermRule & graphTerm()
GraphTermRule & pattern()
boost::phoenix::function< make_shared_f< T > > ptr_
IRIAtomPtr iri(std::string_view ns, std::string_view name)