From 50af579b446ddf6aac91d441bba3f0760ccd383d Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 11 Dec 2014 22:06:49 +0100 Subject: [PATCH] sysdb: Parse strings correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … and focus only on syntax elements that may include semicolons and escape their meaning as a query terminator. --- src/tools/sysdb/scanner.l | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/tools/sysdb/scanner.l b/src/tools/sysdb/scanner.l index cd465ce..1404690 100644 --- a/src/tools/sysdb/scanner.l +++ b/src/tools/sysdb/scanner.l @@ -63,7 +63,7 @@ %x CSC -whitespace ([ \t\n\r\f]+) +newline ([\n\r]+) simple_comment ("--"[^\n\r]*) /* @@ -73,11 +73,19 @@ csc_start \/\* 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); } @@ -85,15 +93,16 @@ identifier ([A-Za-z_][A-Za-z_0-9$]*) {csc_end} { APPEND(); BEGIN(INITIAL); } <> { return -1; } -{identifier} { APPEND(); } +{string} { APPEND(); } /* * The following rules are specific to the command line tool. */ -";" { APPEND(); sdb_input_exec_query(); } +";" { APPEND(); sdb_input_exec_query(); } -. { APPEND(); } +. { APPEND(); } +{newline} { APPEND(); } %% -- 2.30.2