Code

frontend: Require strings instead of identifiers.
authorSebastian Harl <sh@tokkee.org>
Mon, 31 Mar 2014 21:39:38 +0000 (23:39 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 31 Mar 2014 21:39:38 +0000 (23:39 +0200)
… for host names and name matchers. Identifiers were used as an early
work-around but they are not valid in those places.

src/frontend/grammar.y
t/frontend/parser_test.c

index c3ee0af37886d3391d37f0d8fd425a586d0257c1..ce313310b918f9c6011410d2e9e9c60e430ab67d 100644 (file)
@@ -148,16 +148,6 @@ statement:
        ;
 
 fetch_statement:
-       FETCH IDENTIFIER
-               {
-                       $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
-                                               conn_fetch_t, conn_fetch_destroy));
-                       CONN_FETCH($$)->name = strdup($2);
-                       $$->cmd = CONNECTION_FETCH;
-                       free($2);
-                       $2 = NULL;
-               }
-       |
        FETCH STRING
                {
                        $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
@@ -179,7 +169,7 @@ list_statement:
        ;
 
 expression:
-       IDENTIFIER
+       STRING
                {
                        $$ = SDB_CONN_NODE(sdb_object_create_T(/* name = */ NULL,
                                                conn_node_matcher_t));
index 85265147b1bebdb86ad842ba0a180ef6560faa01..71fc1dbd219b0b382b615897670af5d573d35b9f 100644 (file)
@@ -51,7 +51,7 @@ START_TEST(test_parse)
                { ";;",                 -1,  0, 0 },
 
                /* valid commands */
-               { "FETCH host",         -1,  1, CONNECTION_FETCH },
+               { "FETCH 'host'",       -1,  1, CONNECTION_FETCH },
                { "LIST",               -1,  1, CONNECTION_LIST  },
                { "LIST -- comment",    -1,  1, CONNECTION_LIST  },
                { "LIST;",              -1,  1, CONNECTION_LIST  },
@@ -63,7 +63,7 @@ START_TEST(test_parse)
 
                /* syntax errors */
                { "INVALID",            -1, -1, 0 },
-               { "FETCH $%&#",         -1, -1, 0 },
+               { "FETCH host",         -1, -1, 0 },
                { "LIST; INVALID",       8, -1, 0 },
                { "/* some incomplete", -1, -1, 0 },
        };
@@ -117,9 +117,9 @@ START_TEST(test_parse_matcher)
                { "",                   -1, -1 },
 
                /* valid expressions */
-               { "localhost",          -1,  0 },
-               { "localhost -- foo",   -1,  0 },
-               { "localhost <garbage>", 9,  0 },
+               { "'localhost'",        -1,  0 },
+               { "'localhost' -- foo", -1,  0 },
+               { "'host' <garbage>",    6,  0 },
 
                /* syntax errors */
                { "LIST",               -1, -1 },