From b5c0396e79bf2c0fbd03e96ca0654a4545cbf936 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 31 Mar 2014 23:35:23 +0200 Subject: [PATCH] frontend: Added very simple single-quoted string support. No escape sequences whatsoever are supported so far but except for that any single-quoted strings which do not contain single quotes, can be used. FETCH now supports host names specified as strings as well. --- src/frontend/grammar.y | 12 +++++++++++- src/frontend/scanner.l | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 4f7a891..c3ee0af 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -75,7 +75,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg); %token SCANNER_ERROR -%token IDENTIFIER +%token IDENTIFIER STRING %token FETCH LIST %type statements @@ -157,6 +157,16 @@ fetch_statement: free($2); $2 = NULL; } + | + FETCH STRING + { + $$ = 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; + } ; list_statement: diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index c279a48..c0d167c 100644 --- a/src/frontend/scanner.l +++ b/src/frontend/scanner.l @@ -74,6 +74,8 @@ csc_inside ([^*/]+|[^*]\/|\*[^/]) csc_end \*\/ identifier ([A-Za-z_][A-Za-z_0-9$]*) +/* TODO: fully support SQL strings */ +string ('[^']*') %% @@ -98,6 +100,11 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*) yylval->str = strdup(yytext); return IDENTIFIER; } +{string} { + yytext[yyleng - 1] = '\0'; + yylval->str = strdup(yytext + 1); + return STRING; + } . { /* do nothing for now */ } -- 2.30.2