@@ -166,7 +166,8 @@ static void escape_variable(bool as_ident);
166
166
* <xe> extended quoted strings (support backslash escape sequences)
167
167
* <xdolq> $foo$ quoted strings
168
168
* <xui> quoted identifier with Unicode escapes
169
- * <xus> quoted string with Unicode escapes
169
+ * <xuiend> end of a quoted identifier with Unicode escapes, UESCAPE can follow * <xus> quoted string with Unicode escapes
170
+ * <xusend> end of a quoted string with Unicode escapes, UESCAPE can follow
170
171
*
171
172
* Note: we intentionally don't mimic the backend's <xeu> state; we have
172
173
* no need to distinguish it from <xe> state, and no good way to get out
@@ -182,7 +183,9 @@ static void escape_variable(bool as_ident);
182
183
%x xq
183
184
%x xdolq
184
185
%x xui
186
+ %x xuiend
185
187
%x xus
188
+ %x xusend
186
189
/* Additional exclusive states for psql only: lex backslash commands */
187
190
%x xslashcmd
188
191
%x xslashargstart
@@ -307,17 +310,17 @@ xdinside [^"]+
307
310
/* Unicode escapes */
308
311
uescape [uU][eE][sS ][cC][aA][pP][eE]{whitespace}*{quote}[^' ]{quote}
309
312
/* error rule to avoid backup */
310
- 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])
313
+ 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]
311
314
312
315
/* Quoted identifier with Unicode escapes */
313
316
xuistart [uU]&{dquote}
314
- xuistop1 {dquote}{whitespace}*{uescapefail}?
315
- xuistop2 {dquote}{whitespace}*{uescape}
316
317
317
318
/* Quoted string with Unicode escapes */
318
319
xusstart [uU]&{quote}
319
- xusstop1 {quote}{whitespace}*{uescapefail}?
320
- xusstop2 {quote}{whitespace}*{uescape}
320
+
321
+ /* Optional UESCAPE after a quoted string or identifier with Unicode escapes. */
322
+ xustop1 {uescapefail}?
323
+ xustop2 {uescape}
321
324
322
325
/* error rule to avoid backup */
323
326
xufailed [uU]&
@@ -520,12 +523,22 @@ other .
520
523
BEGIN (INITIAL);
521
524
ECHO;
522
525
}
523
- <xus>{xusstop1} {
526
+ <xus>{quotestop} |
527
+ <xus>{quotefail} {
524
528
yyless (1 );
529
+ BEGIN (xusend);
530
+ ECHO;
531
+ }
532
+ <xusend>{whitespace} {
533
+ ECHO;
534
+ }
535
+ <xusend>{other} |
536
+ <xusend>{xustop1} {
537
+ yyless (0 );
525
538
BEGIN (INITIAL);
526
539
ECHO;
527
540
}
528
- <xus>{xusstop2 } {
541
+ <xusend>{xustop2 } {
529
542
BEGIN (INITIAL);
530
543
ECHO;
531
544
}
@@ -612,12 +625,21 @@ other .
612
625
BEGIN (INITIAL);
613
626
ECHO;
614
627
}
615
- <xui>{xuistop1} {
628
+ <xui>{dquote} {
616
629
yyless (1 );
630
+ BEGIN (xuiend);
631
+ ECHO;
632
+ }
633
+ <xuiend>{whitespace} {
634
+ ECHO;
635
+ }
636
+ <xuiend>{other} |
637
+ <xuiend>{xustop1} {
638
+ yyless (0 );
617
639
BEGIN (INITIAL);
618
640
ECHO;
619
641
}
620
- <xui>{xuistop2 } {
642
+ <xuiend>{xustop2 } {
621
643
BEGIN (INITIAL);
622
644
ECHO;
623
645
}
0 commit comments