fix and tests for arguments

This commit is contained in:
Ari Lazier 2015-11-12 14:34:47 -08:00
parent 113510991a
commit c6899d25d7
2 changed files with 17 additions and 4 deletions

View File

@ -61,8 +61,8 @@ struct false_value : pegtl_istring_t("false") {};
struct key_path : list< seq< sor< alpha, one< '_' > >, star< sor< alnum, one< '_', '-' > > > >, one< '.' > > {}; struct key_path : list< seq< sor< alpha, one< '_' > >, star< sor< alnum, one< '_', '-' > > > >, one< '.' > > {};
// argument // argument
struct argument_index : until< at< one< '}' > >, must< digit > > {}; struct argument_index : plus< digit > {};
struct argument : seq< one< '{' >, must< argument_index >, any > {}; struct argument : seq< one< '{' >, must< argument_index, one< '}' > > > {};
// expressions and operators // expressions and operators
struct expr : sor< dq_string, sq_string, number, argument, true_value, false_value, key_path > {}; struct expr : sor< dq_string, sq_string, number, argument, true_value, false_value, key_path > {};

View File

@ -20,7 +20,7 @@ static std::vector<std::string> valid_queries = {
"'\\uffFf' = '\\u0020'", "'\\uffFf' = '\\u0020'",
"'\\u01111' = 'asdf\\u0111asdf'", "'\\u01111' = 'asdf\\u0111asdf'",
// numbers, bools, keypaths // expressions (numbers, bools, keypaths, arguments)
"-1 = 12", "-1 = 12",
"0 = 001", "0 = 001",
"0x0 = -0X398235fcAb", "0x0 = -0X398235fcAb",
@ -30,6 +30,10 @@ static std::vector<std::string> valid_queries = {
"_ = a", "_ = a",
"_a = _.aZ", "_a = _.aZ",
"a09._br.z = __-__.Z-9", "a09._br.z = __-__.Z-9",
// arguments
"{0} = {19}",
"{0} = {0}",
}; };
static std::vector<std::string> invalid_queries = { static std::vector<std::string> invalid_queries = {
@ -44,12 +48,21 @@ static std::vector<std::string> invalid_queries = {
"\" = ''", "\" = ''",
"' = ''", "' = ''",
// invalid numbers, bools, keypaths // expressions
"03a = 1", "03a = 1",
"1..0 = 1", "1..0 = 1",
"1.0. = 1", "1.0. = 1",
"1-0 = 1",
"0x = 1", "0x = 1",
"truey = false", "truey = false",
"- = a",
"a..b = a",
"a$a = a",
"{} = {0}",
"{-1} = {0}",
"{a} = {0}",
"{ = }",
"truepredicate &&", "truepredicate &&",
"truepredicate & truepredicate", "truepredicate & truepredicate",