From a5bd3248d00810f3e576de71aa5ac2ebfb2f001a Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 31 Mar 2014 23:39:38 +0200 Subject: [PATCH] frontend: Require strings instead of identifiers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … 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 | 12 +----------- t/frontend/parser_test.c | 10 +++++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index c3ee0af..ce31331 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -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)); diff --git a/t/frontend/parser_test.c b/t/frontend/parser_test.c index 8526514..71fc1db 100644 --- a/t/frontend/parser_test.c +++ b/t/frontend/parser_test.c @@ -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 ", 9, 0 }, + { "'localhost'", -1, 0 }, + { "'localhost' -- foo", -1, 0 }, + { "'host' ", 6, 0 }, /* syntax errors */ { "LIST", -1, -1 }, -- 2.30.2