Skip to content

Commit

Permalink
frontend: Require strings instead of identifiers.
Browse files Browse the repository at this point in the history
… for host names and name matchers. Identifiers were used as an early
work-around but they are not valid in those places.
  • Loading branch information
tokkee committed Mar 31, 2014
1 parent b5c0396 commit a5bd324
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
12 changes: 1 addition & 11 deletions src/frontend/grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -179,7 +169,7 @@ list_statement:
;

expression:
IDENTIFIER
STRING
{
$$ = SDB_CONN_NODE(sdb_object_create_T(/* name = */ NULL,
conn_node_matcher_t));
Expand Down
10 changes: 5 additions & 5 deletions t/frontend/parser_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
};
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit a5bd324

Please sign in to comment.