24#include <boost/algorithm/string.hpp>
32using std::regex_search;
33using std::sregex_iterator;
55 if (isnil(
id) or not is_alpha (
id[0]))
60 REQUIRE (is_alpha (
id[0]));
64 id[0] = std::tolower (first);
95 if (regex_search (termString, match, getTermRegex (sym)))
112 if (regex_search (queryString, match, getTermRegex (sym)))
114 string res (sym); res +=
"("+match[1]+
")";
115 queryString.erase (match.position(), match[0].length());
127 return regex_search (queryString, match, getTermRegex (sym));
141 for (sregex_iterator i (q.begin(),q.end(), FIND_PREDICATE);
154 return isnil(pred1)? pred2
155 : isnil(pred2)? pred1
156 : pred1 +
", " + pred2;
Token or Atom with distinct identity.
Lumiera error handling (C++ interface).
const regex FIND_PREDICATE
std::function< bool(string::value_type)> ChPredicate
regex & getTermRegex(Symbol sym)
map< Symbol, regex > regexTable
bool hasTerm(Symbol sym, string const &queryString)
string appendTerms(string const &pred1, string const &pred2)
void normaliseID(string &id)
ensure standard format for a given id string.
string extractID(Symbol sym, const string &termString)
(preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expressio...
uint countPred(const string &q)
count the top-level predicates in the query string.
string removeTerm(Symbol sym, string &queryString)
(preliminary) helper: cut a term with the given symbol.
Implementation namespace for support and library code.
std::string sanitise(std::string const &)
produce an identifier based on the given string.
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
bool isnil(lib::time::Duration const &dur)
Utilities to support working with predicate queries.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...