12
12
*
13
13
*
14
14
* IDENTIFICATION
15
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.66 2000/10/25 07:00:33 meskes Exp $
15
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.67 2000/11/03 10:47:54 meskes Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
21
21
#include < limits.h>
22
22
#include < errno.h>
23
23
24
- #include " postgres.h"
25
-
26
24
#include " miscadmin.h"
27
25
#include " nodes/parsenodes.h"
28
26
#include " nodes/pg_list.h"
@@ -89,14 +87,14 @@ static struct _if_value {
89
87
* We use exclusive states for quoted strings, extended comments,
90
88
* and to eliminate parsing troubles for numeric strings.
91
89
* Exclusive states:
92
- * <xb> binary numeric string - thomas 1997-11-16
90
+ * <xbit> bit string literal
93
91
* <xc> extended C-style comments - thomas 1997-07-12
94
92
* <xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
95
93
* <xh> hexadecimal numeric string - thomas 1997-11-16
96
94
* <xq> quoted strings - thomas 1997-07-30
97
95
*/
98
96
99
- %x xb
97
+ %x xbit
100
98
%x xc
101
99
%x xd
102
100
%x xdc
@@ -106,12 +104,12 @@ static struct _if_value {
106
104
%x xcond
107
105
%x xskip
108
106
109
- /* Binary number
107
+ /* Bit string
110
108
*/
111
- xbstart [bB ]{quote }
112
- xbstop {quote }
113
- xbinside [^ ' ]+
114
- xbcat {quote }{whitespace_with_newline }{quote }
109
+ xbitstart [bB ]{quote }
110
+ xbitstop {quote }
111
+ xbitinside [^ ' ]*
112
+ xbitcat {quote }{whitespace_with_newline }{quote }
115
113
116
114
/* Hexadecimal number
117
115
*/
@@ -192,7 +190,7 @@ typecast "::"
192
190
* If you change either set, adjust the character lists appearing in the
193
191
* rule for "operator"!
194
192
*/
195
- self [,() \[\] .;$ \:\+\-\*\/\%\^\<\>\=\| ]
193
+ self [,() \[\] .;$ \:\+\-\*\/\%\^\<\>\= ]
196
194
op_chars [\~\!\@\#\^\&\|\`\?\$\+\-\*\/\%\<\>\= ]
197
195
operator {op_chars }+
198
196
@@ -313,30 +311,29 @@ cppline {space}*#(.*\\{line_end})*.*
313
311
314
312
<xc ><<EOF>> { mmerror (ET_ERROR, " Unterminated /* comment" ); }
315
313
316
- <SQL >{xbstart } {
317
- BEGIN (xb );
314
+ <SQL >{xbitstart } {
315
+ BEGIN (xbit );
318
316
startlit ();
319
317
}
320
- <xb >{ xbstop } {
318
+ <xbit >{ xbitstop } {
321
319
char * endptr;
322
320
323
321
BEGIN (SQL);
324
- errno = 0 ;
325
- yylval.ival = strtol (literalbuf, &endptr, 2 );
326
- if (*endptr != ' \0 ' || errno == ERANGE)
327
- mmerror (ET_ERROR, " Bad binary integer input!" );
328
- return ICONST;
322
+ if (literalbuf[strspn (literalbuf, " 01" ) + 1 ] != ' \0 ' )
323
+ mmerror (ET_ERROR, " invalid bit string input." );
324
+ yylval.str = literalbuf;
325
+ return BITCONST;
329
326
}
330
327
331
328
<xh >{xhinside } |
332
- <xb >{ xbinside } {
329
+ <xbit >{ xbitinside } {
333
330
addlit (yytext, yyleng);
334
331
}
335
332
<xh >{xhcat } |
336
- <xb >{ xbcat } {
333
+ <xbit >{ xbitcat } {
337
334
/* ignore */
338
335
}
339
- <xb ><<EOF>> { mmerror (ET_ERROR, " Unterminated binary integer " ); }
336
+ <xbit ><<EOF>> { mmerror (ET_ERROR, " Unterminated bit string " ); }
340
337
341
338
<SQL >{xhstart } {
342
339
BEGIN (xh);
@@ -490,7 +487,7 @@ cppline {space}*#(.*\\{line_end})*.*
490
487
* that the "self" rule would have.
491
488
*/
492
489
if (nchars == 1 &&
493
- strchr (" ,()[].;$:+-*/%^<>=| " , yytext[0 ]))
490
+ strchr (" ,()[].;$:+-*/%^<>=" , yytext[0 ]))
494
491
return yytext[0 ];
495
492
}
496
493
0 commit comments