8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.26 1997/10/30 15:28:25 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.27 1997/10/30 16:36:39 thomas Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -57,7 +57,6 @@ void unput(char);
57
57
extern YYSTYPE yylval;
58
58
59
59
int llen;
60
- char *ScanString;
61
60
char literal[MAX_PARSE_BUFFER];
62
61
63
62
%}
@@ -74,6 +73,7 @@ char literal[MAX_PARSE_BUFFER];
74
73
* <xc> extended C-style comments - tgl 1997-07-12
75
74
* <xq> quoted strings - tgl 1997-07-30
76
75
* <xm> numeric strings with embedded minus sign - tgl 1997-09-05
76
+ * <xd> delimited identifiers (double-quoted identifiers) - tgl 1997-10-27
77
77
*
78
78
* The "extended comment" syntax closely resembles allowable operator syntax.
79
79
* So, when in condition <xc>, only strings which would terminate the
@@ -83,10 +83,10 @@ char literal[MAX_PARSE_BUFFER];
83
83
*/
84
84
85
85
%x xc
86
+ %x xd
86
87
%x xq
87
88
%x xm
88
89
89
- /* We used to allow double-quoted strings, but SQL doesn't so we won't either */
90
90
quote '
91
91
xqstart {quote }
92
92
xqstop {quote }
@@ -96,6 +96,11 @@ xqembedded "\\'"
96
96
xqliteral [\\ ](. | \n )
97
97
xqcat {quote }{space }* \n {space }* {quote }
98
98
99
+ dquote \"
100
+ xdstart {dquote }
101
+ xdstop {dquote }
102
+ xdinside [^ " ]*
103
+
99
104
xcline [\/ ][\* ]. * [\* ][\/ ]{space }* \n *
100
105
xcstart [\/ ][\* ]{op_and_self }*
101
106
xcstop {op_and_self }* [\* ][\/ ]({space }* | \n )
@@ -190,12 +195,32 @@ other .
190
195
<xq >{xqcat } {
191
196
}
192
197
198
+
199
+ {xdstart } {
200
+ BEGIN (xd);
201
+ llen = 0 ;
202
+ *literal = ' \0 ' ;
203
+ }
204
+ <xd >{xdstop } {
205
+ BEGIN (INITIAL);
206
+ yylval.str = pstrdup (literal);
207
+ return (IDENT);
208
+ }
209
+ <xd >{xdinside } {
210
+ if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1 ))
211
+ elog (WARN," quoted string parse buffer of %d chars exceeded" ,MAX_PARSE_BUFFER);
212
+ memcpy (literal+llen, yytext, yyleng+1 );
213
+ llen += yyleng;
214
+ }
215
+
216
+
193
217
<xm >{space }* { /* ignore */ }
194
218
<xm >{xmstop } {
195
219
BEGIN (INITIAL);
196
220
return (yytext[0 ]);
197
221
}
198
222
223
+
199
224
{sysfunc } {
200
225
yylval.str = pstrdup (SystemFunctionHandler ((char *)yytext));
201
226
return (SCONST);
@@ -225,39 +250,35 @@ other .
225
250
226
251
{integer }/ {space }* -{number } {
227
252
BEGIN (xm);
228
- ScanString = pstrdup ((char *)yytext);
229
253
yylval.ival = atoi ((char *)yytext);
230
254
return (ICONST);
231
255
}
232
256
{real }/ {space }* -{number } {
233
257
char * endptr;
234
258
BEGIN (xm);
235
259
errno = 0 ;
236
- ScanString = pstrdup ((char *)yytext);
237
260
yylval.dval = strtod (((char *)yytext),&endptr);
238
261
if (*endptr != ' \0 ' || errno == ERANGE)
239
- elog (WARN," \t Bad float8 input format \n " );
262
+ elog (WARN," Bad float8 input '%s' " ,yytext );
240
263
CheckFloat8Val (yylval.dval );
241
264
return (FCONST);
242
265
}
243
266
{integer } {
244
267
char * endptr;
245
268
246
269
errno = 0 ;
247
- ScanString = pstrdup ((char *)yytext);
248
270
yylval.ival = strtol ((char *)yytext,&endptr,10 );
249
271
if (*endptr != ' \0 ' || errno == ERANGE)
250
- elog (WARN," \t Bad integer input format \n " );
272
+ elog (WARN," Bad integer input '%s' " ,yytext );
251
273
return (ICONST);
252
274
}
253
275
{real } {
254
276
char * endptr;
255
277
256
278
errno = 0 ;
257
- ScanString = pstrdup ((char *)yytext);
258
279
yylval.dval = strtod ((char *)yytext,&endptr);
259
280
if (*endptr != ' \0 ' || errno == ERANGE)
260
- elog (WARN," \t Bad float input format \n " );
281
+ elog (WARN," Bad float input '%s' " ,yytext );
261
282
CheckFloat8Val (yylval.dval );
262
283
return (FCONST);
263
284
}
0 commit comments