Code

frontend/parser: Added support for string concatenation.
authorSebastian Harl <sh@tokkee.org>
Thu, 9 Oct 2014 06:57:07 +0000 (08:57 +0200)
committerSebastian Harl <sh@tokkee.org>
Thu, 9 Oct 2014 06:57:07 +0000 (08:57 +0200)
src/frontend/grammar.y
t/unit/frontend/parser_test.c

index 3a78d2490960a4f20cbe130f34e133852c08036f..93616ac07caa9bf7c9419577e89a559b3f6e38dd 100644 (file)
@@ -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);
index 7560a5fe9af7a89c177559d8fd7e54fdb36d5d5c..0c7b30448c41d2231060355abc4381b4b3ec8026 100644 (file)
@@ -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;