Code

frontend: Added very simple single-quoted string support.
authorSebastian Harl <sh@tokkee.org>
Mon, 31 Mar 2014 21:35:23 +0000 (23:35 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 31 Mar 2014 21:35:23 +0000 (23:35 +0200)
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
src/frontend/scanner.l

index 4f7a8913630c547b19c5edc86b4d320804ecd2ec..c3ee0af37886d3391d37f0d8fd425a586d0257c1 100644 (file)
@@ -75,7 +75,7 @@ sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
 
 %token SCANNER_ERROR
 
-%token <str> IDENTIFIER
+%token <str> IDENTIFIER STRING
 %token <node> FETCH LIST
 
 %type <list> 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:
index c279a4876d11a66672fb54e209c81213608ed55b..c0d167c00c0df1da371d8762098acd57c7ce5abc 100644 (file)
@@ -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 */ }