*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.28 1997/11/14 15:43:27 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.29 1997/11/17 16:31:39 thomas Exp $
*
*-------------------------------------------------------------------------
*/
* There are exclusive states for quoted strings, extended comments,
* and to eliminate parsing troubles for numeric strings.
* Exclusive states:
+ * binary numeric string - thomas 1997-11-16
+ * hexadecimal numeric string - thomas 1997-11-16
* extended C-style comments - tgl 1997-07-12
* quoted strings - tgl 1997-07-30
* numeric strings with embedded minus sign - tgl 1997-09-05
* operator-like symbols. - thomas 1997-07-14
*/
+%x xb
%x xc
%x xd
+%x xh
%x xq
%x xm
xqliteral [\\](.|\n)
xqcat {quote}{space}*\n{space}*{quote}
+xbstart [bB]{quote}
+xbstop {quote}
+xbinside [^']*
+xbcat {quote}{space}*\n{space}*{quote}
+
+xhstart [xX]{quote}
+xhstop {quote}
+xhinside [^']*
+xhcat {quote}{space}*\n{space}*{quote}
+
dquote \"
xdstart {dquote}
xdstop {dquote}
{xcinside} { /* ignore */ }
+{xbstart} {
+ BEGIN(xb);
+ llen = 0;
+ *literal = '\0';
+ }
+{xbstop} {
+ char* endptr;
+
+ BEGIN(INITIAL);
+ errno = 0;
+ yylval.ival = strtol((char *)literal,&endptr,2);
+ if (*endptr != '\0' || errno == ERANGE)
+ elog(WARN,"Bad binary integer input '%s'",literal);
+ return (ICONST);
+ }
+{xhinside} |
+{xbinside} {
+ if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1))
+ elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
+ memcpy(literal+llen, yytext, yyleng+1);
+ llen += yyleng;
+ }
+{xhcat} |
+{xbcat} {
+ }
+
+{xhstart} {
+ BEGIN(xh);
+ llen = 0;
+ *literal = '\0';
+ }
+{xhstop} {
+ char* endptr;
+
+ BEGIN(INITIAL);
+ errno = 0;
+ yylval.ival = strtol((char *)literal,&endptr,16);
+ if (*endptr != '\0' || errno == ERANGE)
+ elog(WARN,"Bad hexadecimal integer input '%s'",literal);
+ return (ICONST);
+ }
+
{xqstart} {
BEGIN(xq);
llen = 0;
}
{integer}/{space}*-{number} {
+ char* endptr;
+
BEGIN(xm);
- yylval.ival = atoi((char*)yytext);
+ errno = 0;
+ yylval.ival = strtol((char *)yytext,&endptr,10);
+ if (*endptr != '\0' || errno == ERANGE)
+ elog(WARN,"Bad integer input '%s'",yytext);
return (ICONST);
}
{real}/{space}*-{number} {
char* endptr;
+
BEGIN(xm);
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);