* extended quoted strings (support backslash escape sequences)
* $foo$ quoted strings
* quoted identifier with Unicode escapes
- * quoted string with Unicode escapes
+ * end of a quoted identifier with Unicode escapes, UESCAPE can follow * quoted string with Unicode escapes
+ * end of a quoted string with Unicode escapes, UESCAPE can follow
*
* Note: we intentionally don't mimic the backend's state; we have
* no need to distinguish it from state, and no good way to get out
%x xq
%x xdolq
%x xui
+%x xuiend
%x xus
+%x xusend
/* Additional exclusive states for psql only: lex backslash commands */
%x xslashcmd
%x xslashargstart
/* Unicode escapes */
uescape [uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}[^']{quote}
/* error rule to avoid backup */
-uescapefail ("-"|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*"-"|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}[^']|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*|[uU][eE][sS][cC][aA][pP]|[uU][eE][sS][cC][aA]|[uU][eE][sS][cC]|[uU][eE][sS]|[uU][eE]|[uU])
+uescapefail [uU][eE][sS][cC][aA][pP][eE]{whitespace}*"-"|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}[^']|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*|[uU][eE][sS][cC][aA][pP]|[uU][eE][sS][cC][aA]|[uU][eE][sS][cC]|[uU][eE][sS]|[uU][eE]|[uU]
/* Quoted identifier with Unicode escapes */
xuistart [uU]&{dquote}
-xuistop1 {dquote}{whitespace}*{uescapefail}?
-xuistop2 {dquote}{whitespace}*{uescape}
/* Quoted string with Unicode escapes */
xusstart [uU]&{quote}
-xusstop1 {quote}{whitespace}*{uescapefail}?
-xusstop2 {quote}{whitespace}*{uescape}
+
+/* Optional UESCAPE after a quoted string or identifier with Unicode escapes. */
+xustop1 {uescapefail}?
+xustop2 {uescape}
/* error rule to avoid backup */
xufailed [uU]&
BEGIN(INITIAL);
ECHO;
}
-{xusstop1} {
+{quotestop} |
+{quotefail} {
yyless(1);
+ BEGIN(xusend);
+ ECHO;
+ }
+{whitespace} {
+ ECHO;
+ }
+{other} |
+{xustop1} {
+ yyless(0);
BEGIN(INITIAL);
ECHO;
}
->{xusstop2} {
+end>{xustop2} {
BEGIN(INITIAL);
ECHO;
}
BEGIN(INITIAL);
ECHO;
}
-{xuistop1} {
+{dquote} {
yyless(1);
+ BEGIN(xuiend);
+ ECHO;
+ }
+{whitespace} {
+ ECHO;
+ }
+{other} |
+{xustop1} {
+ yyless(0);
BEGIN(INITIAL);
ECHO;
}
->{xuistop2} {
+end>{xustop2} {
BEGIN(INITIAL);
ECHO;
}