diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l
index cd7ea8513109fd266437b10dfaf5a2428b55aec3..c0d167c00c0df1da371d8762098acd57c7ce5abc 100644 (file)
--- a/src/frontend/scanner.l
+++ b/src/frontend/scanner.l
%{
%{
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "frontend/connection.h"
#include "frontend/parser.h"
#include "frontend/grammar.h"
#include "utils/error.h"
#include "frontend/parser.h"
#include "frontend/grammar.h"
#include "utils/error.h"
#include <string.h>
#include <string.h>
+#define YY_EXTRA_TYPE sdb_fe_yyextra_t *
+
void
sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
void
sdb_fe_yyerror(YYLTYPE *lval, sdb_fe_yyscan_t scanner, const char *msg);
csc_end \*\/
identifier ([A-Za-z_][A-Za-z_0-9$]*)
csc_end \*\/
identifier ([A-Za-z_][A-Za-z_0-9$]*)
+/* TODO: fully support SQL strings */
+string ('[^']*')
%%
%%
<CSC>{csc_inside} { /* ignore */ }
<CSC>{csc_end} { BEGIN(INITIAL); }
<CSC><<EOF>> {
<CSC>{csc_inside} { /* ignore */ }
<CSC>{csc_end} { BEGIN(INITIAL); }
<CSC><<EOF>> {
- sdb_fe_yyerror(yylval, yyscanner, "unterminated C-style comment");
+ sdb_fe_yyerror(yylloc, yyscanner, "unterminated C-style comment");
return SCANNER_ERROR;
}
return SCANNER_ERROR;
}
/* XXX */
if (! strcasecmp(yytext, "LIST"))
return LIST;
/* XXX */
if (! strcasecmp(yytext, "LIST"))
return LIST;
+ else if (! strcasecmp(yytext, "FETCH"))
+ return FETCH;
+ yylval->str = strdup(yytext);
return IDENTIFIER;
}
return IDENTIFIER;
}
+{string} {
+ yytext[yyleng - 1] = '\0';
+ yylval->str = strdup(yytext + 1);
+ return STRING;
+ }
. { /* do nothing for now */ }
%%
sdb_fe_yyscan_t
. { /* do nothing for now */ }
%%
sdb_fe_yyscan_t
-sdb_fe_scanner_init(const char *str)
+sdb_fe_scanner_init(const char *str, int len, sdb_fe_yyextra_t *yyext)
{
yyscan_t scanner;
{
yyscan_t scanner;
+ if (! str)
+ return NULL;
+
if (sdb_fe_yylex_init(&scanner)) {
char errbuf[1024];
sdb_log(SDB_LOG_ERR, "frontend: yylex_init failed: %s",
if (sdb_fe_yylex_init(&scanner)) {
char errbuf[1024];
sdb_log(SDB_LOG_ERR, "frontend: yylex_init failed: %s",
return NULL;
}
return NULL;
}
+ sdb_fe_yyset_extra(yyext, scanner);
+
+ if (len < 0)
+ len = strlen(str);
+
/* the newly allocated buffer state (YY_BUFFER_STATE) is stored inside the
* scanner and, thus, will be freed by yylex_destroy */
/* the newly allocated buffer state (YY_BUFFER_STATE) is stored inside the
* scanner and, thus, will be freed by yylex_destroy */
- yy_scan_string(str, scanner);
+ sdb_fe_yy_scan_bytes(str, len, scanner);
return scanner;
} /* sdb_fe_scanner_init */
return scanner;
} /* sdb_fe_scanner_init */