Commit 0a9be2db authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Add support for delimited identifiers. Include new exclusive state "xd".

Remove unused ScanString variable and code.
parent 0175759e
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.26 1997/10/30 15:28:25 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.27 1997/10/30 16:36:39 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,7 +57,6 @@ void unput(char); ...@@ -57,7 +57,6 @@ void unput(char);
extern YYSTYPE yylval; extern YYSTYPE yylval;
int llen; int llen;
char *ScanString;
char literal[MAX_PARSE_BUFFER]; char literal[MAX_PARSE_BUFFER];
%} %}
...@@ -74,6 +73,7 @@ char literal[MAX_PARSE_BUFFER]; ...@@ -74,6 +73,7 @@ char literal[MAX_PARSE_BUFFER];
* <xc> extended C-style comments - tgl 1997-07-12 * <xc> extended C-style comments - tgl 1997-07-12
* <xq> quoted strings - tgl 1997-07-30 * <xq> quoted strings - tgl 1997-07-30
* <xm> numeric strings with embedded minus sign - tgl 1997-09-05 * <xm> numeric strings with embedded minus sign - tgl 1997-09-05
* <xd> delimited identifiers (double-quoted identifiers) - tgl 1997-10-27
* *
* The "extended comment" syntax closely resembles allowable operator syntax. * The "extended comment" syntax closely resembles allowable operator syntax.
* So, when in condition <xc>, only strings which would terminate the * So, when in condition <xc>, only strings which would terminate the
...@@ -83,10 +83,10 @@ char literal[MAX_PARSE_BUFFER]; ...@@ -83,10 +83,10 @@ char literal[MAX_PARSE_BUFFER];
*/ */
%x xc %x xc
%x xd
%x xq %x xq
%x xm %x xm
/* We used to allow double-quoted strings, but SQL doesn't so we won't either */
quote ' quote '
xqstart {quote} xqstart {quote}
xqstop {quote} xqstop {quote}
...@@ -96,6 +96,11 @@ xqembedded "\\'" ...@@ -96,6 +96,11 @@ xqembedded "\\'"
xqliteral [\\](.|\n) xqliteral [\\](.|\n)
xqcat {quote}{space}*\n{space}*{quote} xqcat {quote}{space}*\n{space}*{quote}
dquote \"
xdstart {dquote}
xdstop {dquote}
xdinside [^"]*
xcline [\/][\*].*[\*][\/]{space}*\n* xcline [\/][\*].*[\*][\/]{space}*\n*
xcstart [\/][\*]{op_and_self}* xcstart [\/][\*]{op_and_self}*
xcstop {op_and_self}*[\*][\/]({space}*|\n) xcstop {op_and_self}*[\*][\/]({space}*|\n)
...@@ -190,12 +195,32 @@ other . ...@@ -190,12 +195,32 @@ other .
<xq>{xqcat} { <xq>{xqcat} {
} }
{xdstart} {
BEGIN(xd);
llen = 0;
*literal = '\0';
}
<xd>{xdstop} {
BEGIN(INITIAL);
yylval.str = pstrdup(literal);
return (IDENT);
}
<xd>{xdinside} {
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;
}
<xm>{space}* { /* ignore */ } <xm>{space}* { /* ignore */ }
<xm>{xmstop} { <xm>{xmstop} {
BEGIN(INITIAL); BEGIN(INITIAL);
return (yytext[0]); return (yytext[0]);
} }
{sysfunc} { {sysfunc} {
yylval.str = pstrdup(SystemFunctionHandler((char *)yytext)); yylval.str = pstrdup(SystemFunctionHandler((char *)yytext));
return (SCONST); return (SCONST);
...@@ -225,7 +250,6 @@ other . ...@@ -225,7 +250,6 @@ other .
{integer}/{space}*-{number} { {integer}/{space}*-{number} {
BEGIN(xm); BEGIN(xm);
ScanString = pstrdup((char*)yytext);
yylval.ival = atoi((char*)yytext); yylval.ival = atoi((char*)yytext);
return (ICONST); return (ICONST);
} }
...@@ -233,10 +257,9 @@ other . ...@@ -233,10 +257,9 @@ other .
char* endptr; char* endptr;
BEGIN(xm); BEGIN(xm);
errno = 0; errno = 0;
ScanString = pstrdup((char*)yytext);
yylval.dval = strtod(((char *)yytext),&endptr); yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(WARN,"\tBad float8 input format\n"); elog(WARN,"Bad float8 input '%s'",yytext);
CheckFloat8Val(yylval.dval); CheckFloat8Val(yylval.dval);
return (FCONST); return (FCONST);
} }
...@@ -244,20 +267,18 @@ other . ...@@ -244,20 +267,18 @@ other .
char* endptr; char* endptr;
errno = 0; errno = 0;
ScanString = pstrdup((char*)yytext);
yylval.ival = strtol((char *)yytext,&endptr,10); yylval.ival = strtol((char *)yytext,&endptr,10);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(WARN,"\tBad integer input format\n"); elog(WARN,"Bad integer input '%s'",yytext);
return (ICONST); return (ICONST);
} }
{real} { {real} {
char* endptr; char* endptr;
errno = 0; errno = 0;
ScanString = pstrdup((char*)yytext);
yylval.dval = strtod((char *)yytext,&endptr); yylval.dval = strtod((char *)yytext,&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(WARN,"\tBad float input format\n"); elog(WARN,"Bad float input '%s'",yytext);
CheckFloat8Val(yylval.dval); CheckFloat8Val(yylval.dval);
return (FCONST); return (FCONST);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment