Skip to content

Commit 91543dc

Browse files
committed
Get single quote escapes in the Lexer
This could be a bigger problem later. The PostGraph scanner was designed around openCypher and JSON. NOTE: I don't think PostGraph supports Dollar quoting at this time...
1 parent 42773df commit 91543dc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/backend/parser/ag_scanner.l

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@
115115
* \xE1\xA0\x8E
116116
* U+180E MONGOLIAN VOWEL SEPARATOR -- not a whitespace anymore
117117
*/
118+
%x xb
119+
%x xc
120+
%x xd
121+
%x xh
122+
%x xq
123+
%x xqs
124+
%x xe
125+
%x xdolq
126+
%x xui
127+
%x xus
128+
%x xeu
129+
130+
118131
whitespace [\t\n\v\f\r ]+
119132

120133
/*
@@ -202,17 +215,22 @@ decimalscifail2 ({digitseq}|{decimal})[Ee][+-]
202215
dquote \"
203216
dqchars [^"\\]+
204217
squote '
218+
205219
sqchars [^'\\]+
206220
esascii \\["'/\\bfnrt]
207221
esasciifail \\[^Uu]?
208222
esunicode \\(U{hexdigit}{8}|u{hexdigit}{4})
209223
esunicodefail \\(U{hexdigit}{0,7}|u{hexdigit}{0,3})
224+
doublequote {squote}{squote}
210225
escapecode \\{digit}{3}
211226
escapecodefail \\{digit}{0,2}
212227
hexcode \\(x{hexdigit}+|X{hexdigit}+)
213228
hexcodefail \\(X|x)
214229
any (?s:.)
215230

231+
232+
233+
216234
/* id pattern is for UnescapedSymbolicName rule in Cypher. */
217235
id {idstart}{idcont}*
218236
idstart [A-Z_a-z\x80-\xFF]
@@ -454,6 +472,23 @@ ag_token token;
454472
BEGIN(sqstr);
455473
}
456474

475+
{squote} {
476+
update_location();
477+
strbuf_reset(&yyextra.literal_buf);
478+
BEGIN(sqstr);
479+
480+
/*
481+
* In quoted strings, only Unicode escape sequences need to be verified,
482+
* and the actions for <dqstr,sqstr>{esunicode} and <qstru>{esunicode}
483+
* rules verify the code point values. So, quoted strings are always valid.
484+
*/
485+
486+
token.type = AG_TOKEN_STRING;
487+
token.value.s = strbuf_get_str(&yyextra.literal_buf);
488+
token.location = get_location();
489+
return token;
490+
}
491+
457492
<dqstr>{dqchars} |
458493
<sqstr>{sqchars} {
459494
strbuf_append_buf(&yyextra.literal_buf, yytext, yyleng);
@@ -507,6 +542,9 @@ ag_token token;
507542
scan_errposition()));
508543
}
509544
}
545+
<dqstr,sqstr>{doublequote} {
546+
strbuf_append_char(&yyextra.literal_buf, '\'');
547+
}
510548

511549
<dqstr,sqstr>{esunicode} {
512550
pg_wchar c;

0 commit comments

Comments
 (0)