From: Sebastian Harl Date: Thu, 11 Dec 2014 21:06:49 +0000 (+0100) Subject: sysdb: Parse strings correctly. X-Git-Tag: sysdb-0.7.0~112^2~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=50af579b446ddf6aac91d441bba3f0760ccd383d;p=sysdb.git sysdb: Parse strings correctly. … and focus only on syntax elements that may include semicolons and escape their meaning as a query terminator. --- 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(); } %%