diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index f262f3e11d9ace504a2fa08dc4b3ef8bb7c9befe..004a5effa1537a29473066103757cd169867c37a 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
#include "utils/llist.h"
#include <stdio.h>
+#include <string.h>
int
sdb_fe_yylex(YYSTYPE *yylval, YYLTYPE *yylloc, sdb_fe_yyscan_t yyscanner);
%token SCANNER_ERROR
%token <str> IDENTIFIER
-%token <node> LIST
+%token <node> FETCH LIST
%type <list> statements
%type <node> statement
+ fetch_statement
list_statement
expression
statements:
statements ';' statement
{
+ /* only accept this in default parse mode */
+ if (parser_mode != SDB_PARSE_DEFAULT) {
+ sdb_fe_yyerror(&yylloc, scanner,
+ YY_("syntax error, unexpected statement, "
+ "expecting expression"));
+ YYABORT;
+ }
+
if ($3) {
sdb_llist_append(pt, SDB_OBJ($3));
sdb_object_deref(SDB_OBJ($3));
|
statement
{
+ /* only accept this in default parse mode */
+ if (parser_mode != SDB_PARSE_DEFAULT) {
+ sdb_fe_yyerror(&yylloc, scanner,
+ YY_("syntax error, unexpected statement, "
+ "expecting expression"));
+ YYABORT;
+ }
+
if ($1) {
sdb_llist_append(pt, SDB_OBJ($1));
sdb_object_deref(SDB_OBJ($1));
;
statement:
+ fetch_statement
+ |
list_statement
|
/* empty */
}
;
+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;
+ }
+ ;
+
list_statement:
LIST
{