diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile index 07857543a5..7dac1e03fb 100644 --- a/src/backend/utils/adt/Makefile +++ b/src/backend/utils/adt/Makefile @@ -43,6 +43,7 @@ jsonpath_gram.h: jsonpath_gram.c jsonpath_gram.c: BISONFLAGS += -d jsonpath_scan.c: FLEXFLAGS = -CF -p -p +jsonpath_scan.c: FLEX_NO_BACKUP=yes # Force these dependencies to be known even without dependency info built: diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l index 06efe0e6ab..1df4506897 100644 --- a/src/backend/utils/adt/jsonpath_scan.l +++ b/src/backend/utils/adt/jsonpath_scan.l @@ -71,9 +71,20 @@ fprintf_to_ereport(const char *fmt, const char *msg) special [\?\%\$\.\[\]\{\}\(\)\|\&\!\=\<\>\@\#\,\*:\-\+\/] any [^\?\%\$\.\[\]\{\}\(\)\|\&\!\=\<\>\@\#\,\*:\-\+\/\\\"\' \t\n\r\f] blank [ \t\n\r\f] + +digit [0-9] +integer {digit}+ +decimal {digit}*\.{digit}+ +decimalfail {digit}+\. +real ({integer}|{decimal})[Ee][-+]?{digit}+ +realfail1 ({integer}|{decimal})[Ee] +realfail2 ({integer}|{decimal})[Ee][-+] + hex_dig [0-9A-Fa-f] unicode \\u({hex_dig}{4}|\{{hex_dig}{1,6}\}) +unicodefail \\u({hex_dig}{0,3}|\{{hex_dig}{0,6}) hex_char \\x{hex_dig}{2} +hex_fail \\x{hex_dig}{0,1} %% @@ -121,28 +132,30 @@ hex_char \\x{hex_dig}{2} BEGIN xCOMMENT; } -[0-9]+(\.[0-9]+)?[eE][+-]?[0-9]+ /* float */ { +{real} { addstring(true, yytext, yyleng); addchar(false, '\0'); yylval->str = scanstring; return NUMERIC_P; } -\.[0-9]+[eE][+-]?[0-9]+ /* float */ { +{decimal} { addstring(true, yytext, yyleng); addchar(false, '\0'); yylval->str = scanstring; return NUMERIC_P; } -([0-9]+)?\.[0-9]+ { +{integer} { addstring(true, yytext, yyleng); addchar(false, '\0'); yylval->str = scanstring; - return NUMERIC_P; + return INT_P; } -[0-9]+ { +{decimalfail} { + /* throw back the ., and treat as integer */ + yyless(yyleng - 1); addstring(true, yytext, yyleng); addchar(false, '\0'); yylval->str = scanstring; @@ -199,6 +212,8 @@ hex_char \\x{hex_dig}{2} return checkSpecialVal(); } +({realfail1}|{realfail2}) { yyerror(NULL, "Floating point number is invalid"); } + \\[\"\'\\] { addchar(false, yytext[1]); } \\b { addchar(false, '\b'); } @@ -213,13 +228,13 @@ hex_char \\x{hex_dig}{2} \\v { addchar(false, '\v'); } -{unicode}+ { parseUnicode(yytext, yyleng); } +{unicode} { parseUnicode(yytext, yyleng); } -{hex_char}+ { parseHexChars(yytext, yyleng); } +{hex_char} { parseHexChars(yytext, yyleng); } -\\x { yyerror(NULL, "Hex character sequence is invalid"); } +{hex_fail} { yyerror(NULL, "Hex character sequence is invalid"); } -\\u { yyerror(NULL, "Unicode sequence is invalid"); } +{unicodefail} { yyerror(NULL, "Unicode sequence is invalid"); } \\. { yyerror(NULL, "Escape sequence is invalid"); }