From: Sebastian Harl Date: Thu, 9 Oct 2014 06:57:07 +0000 (+0200) Subject: frontend/parser: Added support for string concatenation. X-Git-Tag: sysdb-0.6.0~128 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=0862576c7a992044c91788265ea964dfee8d6217 frontend/parser: Added support for string concatenation. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 3a78d24..93616ac 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -481,6 +481,13 @@ expression: sdb_object_deref(SDB_OBJ($3)); $3 = NULL; } | + expression CONCAT expression + { + $$ = sdb_store_expr_create(SDB_DATA_CONCAT, $1, $3); + sdb_object_deref(SDB_OBJ($1)); $1 = NULL; + sdb_object_deref(SDB_OBJ($3)); $3 = NULL; + } + | '.' IDENTIFIER { int field = sdb_store_parse_field_name($2); diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index 7560a5f..0c7b304 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -143,6 +143,9 @@ START_TEST(test_parse) { "LOOKUP hosts MATCHING " "attribute[foo] <= " "12. + .3", -1, 1, CONNECTION_LOOKUP }, + { "LOOKUP hosts MATCHING " + "attribute[foo] <= " + "'f' || 'oo'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " "attribute[foo] >= " ".4", -1, 1, CONNECTION_LOOKUP }, @@ -241,6 +244,12 @@ START_TEST(test_parse) { "LOOKUP foo MATCHING " "host = 'host' FILTER " "host = 'host'", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "attribute[foo] <= " + "f || 'oo'", -1, -1, 0 }, + { "LOOKUP hosts MATCHING " + "attribute[foo] <= " + "'f' || oo", -1, -1, 0 }, }; size_t i;