more grammer tests
This commit is contained in:
parent
d455aaf402
commit
113510991a
|
@ -31,15 +31,14 @@ namespace parser {
|
||||||
|
|
||||||
// strings
|
// strings
|
||||||
struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {};
|
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 escaped : sor< escaped_char, unicode > {};
|
||||||
struct unescaped : utf8::range< 0x20, 0x10FFFF > {};
|
struct unescaped : utf8::range< 0x20, 0x10FFFF > {};
|
||||||
struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {};
|
struct chars : if_then_else< one< '\\' >, must< escaped >, unescaped > {};
|
||||||
|
struct dq_string_content : until< at< one< '"' > >, must< chars > > {};
|
||||||
struct dq_string_content : until< at< one< '"' > >, must< char_ > > {};
|
|
||||||
struct dq_string : seq< one< '"' >, must< dq_string_content >, any > {};
|
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 > {};
|
struct sq_string : seq< one< '\'' >, must< sq_string_content >, any > {};
|
||||||
|
|
||||||
// numbers
|
// numbers
|
||||||
|
|
|
@ -7,15 +7,50 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
static std::vector<std::string> valid_queries = {
|
static std::vector<std::string> valid_queries = {
|
||||||
|
// true/false predicates
|
||||||
"truepredicate",
|
"truepredicate",
|
||||||
"falsepredicate",
|
"falsepredicate",
|
||||||
"TRUEPREDICATE",
|
"TRUEPREDICATE",
|
||||||
"FALSEPREDICATE",
|
"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<std::string> invalid_queries = {
|
static std::vector<std::string> invalid_queries = {
|
||||||
"predicate",
|
"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 & truepredicate",
|
"truepredicate & truepredicate",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue