index cd465ce67f87be50c0456869053a7c88469e6484..eb1ec180c2b73a9ce94743deecb23ea69422551e 100644 (file)
#include "tools/sysdb/input.h"
+#include <ctype.h>
#include <string.h>
#ifdef YY_INPUT
#define APPEND() \
do { \
+ if (! isspace((int)yytext[0])) \
+ sysdb_input->have_input = 1; \
sysdb_input->query_len += strlen(yytext); \
} while (0)
%x CSC
-whitespace ([ \t\n\r\f]+)
+newline (\n|\r\n)
simple_comment ("--"[^\n\r]*)
/*
csc_inside ([^*/]+|[^*]\/|\*[^/])
csc_end \*\/
-identifier ([A-Za-z_][A-Za-z_0-9$]*)
+/*
+ * Strings.
+ */
+/* TODO: fully support SQL strings */
+string ('([^']|'')*')
%%
-{whitespace} { APPEND(); }
+ /*
+ * Here, we only care about syntax elements that may include semicolons
+ * and escape their meaning as a query terminator.
+ */
+
{simple_comment} { APPEND(); }
{csc_start} { APPEND(); BEGIN(CSC); }
<CSC>{csc_end} { APPEND(); BEGIN(INITIAL); }
<CSC><<EOF>> { return -1; }
-{identifier} { APPEND(); }
+{string} { APPEND(); }
/*
* The following rules are specific to the command line tool.
*/
-";" { APPEND(); sdb_input_exec_query(); }
+";\n" { APPEND(); sdb_input_exec_query(); }
+";" { APPEND(); sdb_input_exec_query(); }
+
+{newline} {
+ APPEND();
+ if (! sysdb_input->have_input)
+ /* give the input module a chance to do stuff on empty lines */
+ sdb_input_exec_query();
+ }
-. { APPEND(); }
+. { APPEND(); }
%%