diff --git a/src/object-store/parser/parser.cpp b/src/object-store/parser/parser.cpp index ef15fd48..9443a37c 100644 --- a/src/object-store/parser/parser.cpp +++ b/src/object-store/parser/parser.cpp @@ -31,15 +31,14 @@ namespace parser { // strings struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; -struct escaped_char : one< '"', '\'', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; +struct escaped_char : one< '"', '\'', '\\', '/', 'b', 'f', 'n', 'r', 't', '0' > {}; struct escaped : sor< escaped_char, unicode > {}; struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; -struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; - -struct dq_string_content : until< at< one< '"' > >, must< char_ > > {}; +struct chars : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; +struct dq_string_content : until< at< one< '"' > >, must< chars > > {}; struct dq_string : seq< one< '"' >, must< dq_string_content >, any > {}; -struct sq_string_content : until< at< one< '\'' > >, must< char_ > > {}; +struct sq_string_content : until< at< one< '\'' > >, must< chars > > {}; struct sq_string : seq< one< '\'' >, must< sq_string_content >, any > {}; // numbers diff --git a/src/object-store/parser/test.cpp b/src/object-store/parser/test.cpp index 23494306..9655ee05 100644 --- a/src/object-store/parser/test.cpp +++ b/src/object-store/parser/test.cpp @@ -7,15 +7,50 @@ #include static std::vector valid_queries = { + // true/false predicates "truepredicate", "falsepredicate", "TRUEPREDICATE", "FALSEPREDICATE", - "truepredicate && truepredicate" + + // characters/strings + "\"\" = ''", + "'azAZ09/ :()[]{}<>,.^@-+=*&~`' = '\\\" \\' \\\\ \\/ \\b \\f \\n \\r \\t \\0'", + "\"azAZ09/\" = \"\\\" \\' \\\\ \\/ \\b \\f \\n \\r \\t \\0\"", + "'\\uffFf' = '\\u0020'", + "'\\u01111' = 'asdf\\u0111asdf'", + + // numbers, bools, keypaths + "-1 = 12", + "0 = 001", + "0x0 = -0X398235fcAb", + "10. = -.034", + "10.0 = 5.034", + "true = false", + "_ = a", + "_a = _.aZ", + "a09._br.z = __-__.Z-9", }; static std::vector invalid_queries = { "predicate", + "'\\a' = ''", // invalid escape + + // invalid unicode + "'\\u0' = ''", + + // invalid strings + "\"' = ''", + "\" = ''", + "' = ''", + + // invalid numbers, bools, keypaths + "03a = 1", + "1..0 = 1", + "1.0. = 1", + "0x = 1", + "truey = false", + "truepredicate &&", "truepredicate & truepredicate", };