From: Sebastian Harl Date: Mon, 31 Mar 2014 21:39:38 +0000 (+0200) Subject: frontend: Require strings instead of identifiers. X-Git-Tag: sysdb-0.1.0~163 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a5bd3248d00810f3e576de71aa5ac2ebfb2f001a;p=sysdb.git frontend: Require strings instead of identifiers. … for host names and name matchers. Identifiers were used as an early work-around but they are not valid in those places. --- 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 },