25#include "jsonpath_gram.h"
46#define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg)
int errmsg_internal(const char *fmt,...)
#define ereport(elevel,...)
static bool parseHexChar(char *s, struct Node *escontext, yyscan_t yyscanner)
static bool parseUnicode(char *s, int l, struct Node *escontext, yyscan_t yyscanner)
static void addchar(bool init, char c, yyscan_t yyscanner)
static void fprintf_to_ereport(const char *fmt, const char *msg)
static enum yytokentype checkKeyword(yyscan_t yyscanner)
static void addstring(bool init, char *s, int l, yyscan_t yyscanner)
59%option never-interactive
65%option prefix="jsonpath_yy"
66%option extra-type="struct jsonpath_yy_extra_type *"
88special [\?\%\$\.\[\]\{\}\(\)\|\&\!\=<>\@\#\,\*:\-\+\/]
91other [^\?\%\$\.\[\]\{\}\(\)\|\&\!\=<>\@\#\,\*:\-\+\/\\\" \t\n\r\f]
99decinteger (0|[1-9](_?{decdigit})*)
101decdigits {decdigit}(_?{decdigit})*
103hexinteger 0[xX]{hexdigit}(_?{hexdigit})*
104octinteger 0[oO]{octdigit}(_?{octdigit})*
105bininteger 0[bB]{bindigit}(_?{bindigit})*
107decimal ({decinteger}\.{decdigits}?|\.{decdigits})
108real ({decinteger}|{decimal})[Ee][-+]?{decdigits}
109realfail ({decinteger}|{decimal})[Ee][-+]
111decinteger_junk {decinteger}{other}
112decimal_junk {decimal}{other}
113real_junk {real}{other}
115unicode \\u({hexdigit}{4}|\{{hexdigit}{1,6}\})
116unicodefail \\u({hexdigit}{0,3}|\{{hexdigit}{0,6})
117hex_char \\x{hexdigit}{2}
118hex_fail \\x{hexdigit}{0,1}
150<xnq,xq,xvq>\\b {
addchar(
false,
'\b', yyscanner); }
152<xnq,xq,xvq>\\f {
addchar(
false,
'\f', yyscanner); }
154<xnq,xq,xvq>\\n {
addchar(
false,
'\n', yyscanner); }
156<xnq,xq,xvq>\\r {
addchar(
false,
'\r', yyscanner); }
158<xnq,xq,xvq>\\t {
addchar(
false,
'\t', yyscanner); }
160<xnq,xq,xvq>\\v {
addchar(
false,
'\v', yyscanner); }
162<xnq,xq,xvq>{unicode}+ {
167<xnq,xq,xvq>{hex_char} {
172<xnq,xq,xvq>{unicode}*{unicodefail} {
174 "invalid Unicode escape sequence");
void jsonpath_yyerror(JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner, const char *message)
178<xnq,xq,xvq>{hex_fail} {
180 "invalid hexadecimal character sequence");
184<xnq,xq,xvq>{unicode}+\\ {
195 "unexpected end after backslash");
201 "unterminated quoted string");
227 "unexpected end of comment");
230\&\& {
return AND_P; }
236\*\* {
return ANY_P; }
254 addchar(
false,
'\0', yyscanner);
260 addchar(
true,
'\0', yyscanner);
264{special} {
return *
yytext; }
269 addchar(
true,
'\0', yyscanner);
275 addchar(
false,
'\0', yyscanner);
282 addchar(
false,
'\0', yyscanner);
289 addchar(
false,
'\0', yyscanner);
296 addchar(
false,
'\0', yyscanner);
303 addchar(
false,
'\0', yyscanner);
310 addchar(
false,
'\0', yyscanner);
317 "invalid numeric literal");
322 "trailing junk after numeric literal");
327 "trailing junk after numeric literal");
332 "trailing junk after numeric literal");
336 addchar(
true,
'\0', yyscanner);
342 addchar(
true,
'\0', yyscanner);
359#define yyextra (((struct yyguts_t *) yyscanner)->yyextra_r)
378 errmsg(
"%s at end of jsonpath input",
_(message))));
385 errmsg(
"%s at or near \"%s\" of jsonpath input",
403 {2,
false,
IS_P,
"is"},
404 {2,
false,
TO_P,
"to"},
405 {3,
false,
ABS_P,
"abs"},
406 {3,
false,
LAX_P,
"lax"},
407 {4,
false,
DATE_P,
"date"},
408 {4,
false,
FLAG_P,
"flag"},
409 {4,
false,
LAST_P,
"last"},
410 {4,
true,
NULL_P,
"null"},
411 {4,
false,
SIZE_P,
"size"},
412 {4,
false,
TIME_P,
"time"},
413 {4,
true,
TRUE_P,
"true"},
414 {4,
false,
TYPE_P,
"type"},
415 {4,
false,
WITH_P,
"with"},
501 yyextra->scanstring.total *= 2;
556 if (
c >=
'0' &&
c <=
'9')
561 if (
c >=
'a' &&
c <=
'f')
563 *result =
c -
'a' + 0xA;
566 if (
c >=
'A' &&
c <=
'F')
568 *result =
c -
'A' + 0xA;
584 errmsg(
"unsupported Unicode escape sequence"),
585 errdetail(
"\\u0000 cannot be converted to text.")));
602 errmsg(
"could not convert Unicode to server encoding")));
617 errmsg(
"invalid input syntax for type %s",
"jsonpath"),
618 errdetail(
"Unicode high surrogate must not follow "
619 "a high surrogate.")));
628 errmsg(
"invalid input syntax for type %s",
"jsonpath"),
629 errdetail(
"Unicode low surrogate must follow a high "
638 errmsg(
"invalid input syntax for type %s",
"jsonpath"),
639 errdetail(
"Unicode low surrogate must follow a high "
656 for (
i = 2;
i < l;
i += 2)
664 while (s[++
i] !=
'}' &&
i < l)
666 if (!
hexval(s[
i], &
si, escontext, yyscanner))
674 for (
j = 0;
j < 4 &&
i < l;
j++)
676 if (!
hexval(s[
i++], &
si, escontext, yyscanner))
690 errmsg(
"invalid input syntax for type %s",
"jsonpath"),
691 errdetail(
"Unicode low surrogate must follow a high "
706 if (!
hexval(s[2], &
s2, escontext, yyscanner))
708 if (!
hexval(s[3], &
s3, escontext, yyscanner))
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define errsave(context,...)
int jsonpath_yyparse(JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
static void resizeString(bool init, int appendLen, yyscan_t yyscanner)
void jsonpath_yyfree(void *ptr, yyscan_t yyscanner)
void * jsonpath_yyrealloc(void *ptr, yy_size_t bytes, yyscan_t yyscanner)
JsonPathParseResult * parsejsonpath(const char *str, int len, struct Node *escontext)
static const JsonPathKeyword keywords[]
static bool addUnicodeChar(char32_t ch, struct Node *escontext, yyscan_t yyscanner)
void * jsonpath_yyalloc(yy_size_t bytes, yyscan_t yyscanner)
static bool hexval(char c, int *result, struct Node *escontext, yyscan_t yyscanner)
static bool addUnicode(char32_t ch, int *hi_surrogate, struct Node *escontext, yyscan_t yyscanner)
bool pg_unicode_to_server_noerror(char32_t c, unsigned char *s)
void pg_unicode_to_server(char32_t c, unsigned char *s)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
#define SOFT_ERROR_OCCURRED(escontext)
#define IsA(nodeptr, _type_)
static bool is_utf16_surrogate_first(char32_t c)
static bool is_utf16_surrogate_second(char32_t c)
static char32_t surrogate_pair_to_codepoint(char16_t first, char16_t second)
#define MAX_UNICODE_EQUIVALENT_STRING
int pg_strncasecmp(const char *s1, const char *s2, size_t n)