From 735b49ff2aa95009afc4f7fa8c76ee3663ea6b89 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Thu, 12 Nov 2015 14:34:47 -0800 Subject: [PATCH] fix and tests for arguments --- src/object-store/parser/parser.cpp | 4 ++-- src/object-store/parser/test.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/object-store/parser/parser.cpp b/src/object-store/parser/parser.cpp index 9443a37c..5bc6e7d8 100644 --- a/src/object-store/parser/parser.cpp +++ b/src/object-store/parser/parser.cpp @@ -61,8 +61,8 @@ struct false_value : pegtl_istring_t("false") {}; struct key_path : list< seq< sor< alpha, one< '_' > >, star< sor< alnum, one< '_', '-' > > > >, one< '.' > > {}; // argument -struct argument_index : until< at< one< '}' > >, must< digit > > {}; -struct argument : seq< one< '{' >, must< argument_index >, any > {}; +struct argument_index : plus< digit > {}; +struct argument : seq< one< '{' >, must< argument_index, one< '}' > > > {}; // expressions and operators struct expr : sor< dq_string, sq_string, number, argument, true_value, false_value, key_path > {}; diff --git a/src/object-store/parser/test.cpp b/src/object-store/parser/test.cpp index 9655ee05..3870569f 100644 --- a/src/object-store/parser/test.cpp +++ b/src/object-store/parser/test.cpp @@ -20,7 +20,7 @@ static std::vector valid_queries = { "'\\uffFf' = '\\u0020'", "'\\u01111' = 'asdf\\u0111asdf'", - // numbers, bools, keypaths + // expressions (numbers, bools, keypaths, arguments) "-1 = 12", "0 = 001", "0x0 = -0X398235fcAb", @@ -30,6 +30,10 @@ static std::vector valid_queries = { "_ = a", "_a = _.aZ", "a09._br.z = __-__.Z-9", + + // arguments + "{0} = {19}", + "{0} = {0}", }; static std::vector invalid_queries = { @@ -44,12 +48,21 @@ static std::vector invalid_queries = { "\" = ''", "' = ''", - // invalid numbers, bools, keypaths + // expressions "03a = 1", "1..0 = 1", "1.0. = 1", + "1-0 = 1", "0x = 1", "truey = false", + "- = a", + "a..b = a", + "a$a = a", + "{} = {0}", + "{-1} = {0}", + "{a} = {0}", + "{ = }", + "truepredicate &&", "truepredicate & truepredicate",