Allow key paths to start with "not" in queries

Fixes #445
This commit is contained in:
Scott Kyle 2016-05-19 01:25:53 -07:00
parent 4334d55767
commit 6c0608356a
2 changed files with 10 additions and 4 deletions

View File

@ -24,6 +24,8 @@
#include <pegtl/analyze.hh>
#include <pegtl/trace.hh>
#define string_operator_t(s) seq< pegtl_istring_t(s), not_at< identifier_other > >
using namespace pegtl;
namespace realm {
@ -93,11 +95,11 @@ struct group_pred : if_must< one< '(' >, pad< pred, blank >, one< ')' > > {};
struct true_pred : pegtl_istring_t("truepredicate") {};
struct false_pred : pegtl_istring_t("falsepredicate") {};
struct not_pre : seq< sor< one< '!' >, pegtl_istring_t("not") > > {};
struct not_pre : seq< sor< one< '!' >, string_operator_t("not") > > {};
struct atom_pred : seq< opt< not_pre >, pad< sor< group_pred, true_pred, false_pred, comparison_pred >, blank > > {};
struct and_op : pad< sor< two< '&' >, pegtl_istring_t("and") >, blank > {};
struct or_op : pad< sor< two< '|' >, pegtl_istring_t("or") >, blank > {};
struct and_op : pad< sor< two< '&' >, string_operator_t("and") >, blank > {};
struct or_op : pad< sor< two< '|' >, string_operator_t("or") >, blank > {};
struct or_ext : if_must< or_op, pred > {};
struct and_ext : if_must< and_op, pred > {};

View File

@ -66,6 +66,9 @@ static std::vector<std::string> valid_queries = {
"!(0=0)",
"! (0=0)",
"NOT0=0", // keypath NOT0
"NOT0.a=0", // keypath NOT0
"NOT0a.b=0", // keypath NOT0a
"not-1=1",
"not 0=0",
"NOT(0=0)",
"not (0=0)",
@ -121,6 +124,7 @@ static std::vector<std::string> invalid_queries = {
"(0=0))",
"! =0",
"NOTNOT(0=0)",
"not.a=0",
"(!!0=0)",
"0=0 !",
@ -130,7 +134,7 @@ static std::vector<std::string> invalid_queries = {
"a==a &| a==a",
"a==a && OR a==a",
"a==aORa==a",
//"a=1ANDNOT b=2",
"a=1ANDNOT b=2",
"truepredicate &&",
"truepredicate & truepredicate",