diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index e6c627b3a4b966e288c9aadbbcf02ddfea5e0eb6..f262f3e11d9ace504a2fa08dc4b3ef8bb7c9befe 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
%{
-#include "frontend/connection.h"
+#include "frontend/connection-private.h"
#include "frontend/parser.h"
#include "frontend/grammar.h"
+#include "core/store.h"
+
#include "utils/error.h"
#include "utils/llist.h"
/* quick access to the current parse tree */
#define pt sdb_fe_yyget_extra(scanner)->parsetree
+/* quick access to the parser mode */
+#define parser_mode sdb_fe_yyget_extra(scanner)->mode
+
%}
%pure-parser
%name-prefix="sdb_fe_yy"
%union {
+ char *str;
+
sdb_llist_t *list;
sdb_conn_node_t *node;
}
%token SCANNER_ERROR
-%token IDENTIFIER
+%token <str> IDENTIFIER
%token <node> LIST
%type <list> statements
%type <node> statement
list_statement
+ expression
%%
|
statement
{
+ if ($1) {
+ sdb_llist_append(pt, SDB_OBJ($1));
+ sdb_object_deref(SDB_OBJ($1));
+ }
+ }
+ |
+ expression
+ {
+ /* only accept this in expression parse mode */
+ if (! (parser_mode & SDB_PARSE_EXPR)) {
+ sdb_fe_yyerror(&yylloc, scanner,
+ YY_("syntax error, unexpected expression, "
+ "expecting statement"));
+ YYABORT;
+ }
+
if ($1) {
sdb_llist_append(pt, SDB_OBJ($1));
sdb_object_deref(SDB_OBJ($1));
{
$$ = SDB_CONN_NODE(sdb_object_create_T(/* name = */ NULL,
sdb_conn_node_t));
- ((sdb_conn_node_t *)$$)->cmd = CONNECTION_LIST;
+ $$->cmd = CONNECTION_LIST;
+ }
+ ;
+
+expression:
+ IDENTIFIER
+ {
+ $$ = SDB_CONN_NODE(sdb_object_create_T(/* name = */ NULL,
+ conn_node_matcher_t));
+ $$->cmd = CONNECTION_EXPR;
+ /* XXX: this is just a placeholder for now */
+ CONN_MATCHER($$)->matcher = sdb_store_host_matcher($1,
+ /* name_re = */ NULL, /* service = */ NULL,
+ /* attr = */ NULL);
+ free($1);
+ $1 = NULL;
}
;