1212 *
1313 *
1414 * 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 $
1616 *
1717 *-------------------------------------------------------------------------
1818*/
2121#include < limits.h>
2222#include < errno.h>
2323
24- #include " postgres.h"
25-
2624#include " miscadmin.h"
2725#include " nodes/parsenodes.h"
2826#include " nodes/pg_list.h"
@@ -89,14 +87,14 @@ static struct _if_value {
8987 * We use exclusive states for quoted strings, extended comments,
9088 * and to eliminate parsing troubles for numeric strings.
9189 * Exclusive states:
92- * <xb> binary numeric string- thomas 1997-11-16
90+ * <xbit> bit stringliteral
9391 * <xc> extended C-style comments - thomas 1997-07-12
9492 * <xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
9593 * <xh> hexadecimal numeric string - thomas 1997-11-16
9694 * <xq> quoted strings - thomas 1997-07-30
9795 */
9896
99- %x xb
97+ %x xbit
10098%x xc
10199%x xd
102100%x xdc
@@ -106,12 +104,12 @@ static struct _if_value {
106104%x xcond
107105%x xskip
108106
109- /*Binary number
107+ /*Bit string
110108 */
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 }
115113
116114/* Hexadecimal number
117115 */
@@ -192,7 +190,7 @@ typecast"::"
192190 * If you change either set, adjust the character lists appearing in the
193191 * rule for "operator"!
194192 */
195- self [,() \[\] .;$ \:\+\-\*\/\%\^\<\>\=\| ]
193+ self [,() \[\] .;$ \:\+\-\*\/\%\^\<\>\= ]
196194op_chars [\~\!\@\#\^\&\|\`\?\$\+\-\*\/\%\<\>\= ]
197195operator {op_chars }+
198196
@@ -313,30 +311,29 @@ cppline{space}*#(.*\\{line_end})*.*
313311
314312<xc ><<EOF>> {mmerror (ET_ERROR," Unterminated /* comment" ); }
315313
316- <SQL >{xbstart }{
317- BEGIN (xb );
314+ <SQL >{xbitstart }{
315+ BEGIN (xbit );
318316startlit ();
319317}
320- <xb >{ xbstop } {
318+ <xbit >{ xbitstop } {
321319char * endptr;
322320
323321BEGIN (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;
329326}
330327
331328<xh >{xhinside }|
332- <xb >{ xbinside }{
329+ <xbit >{ xbitinside }{
333330addlit (yytext, yyleng);
334331}
335332<xh >{xhcat }|
336- <xb >{ xbcat }{
333+ <xbit >{ xbitcat }{
337334/* ignore */
338335}
339- <xb ><<EOF>> {mmerror (ET_ERROR," Unterminatedbinary integer " ); }
336+ <xbit ><<EOF>> {mmerror (ET_ERROR," Unterminatedbit string " ); }
340337
341338<SQL >{xhstart }{
342339BEGIN (xh);
@@ -490,7 +487,7 @@ cppline{space}*#(.*\\{line_end})*.*
490487 * that the "self" rule would have.
491488 */
492489if (nchars ==1 &&
493- strchr (" ,()[].;$:+-*/%^<>=| " , yytext[0 ]))
490+ strchr (" ,()[].;$:+-*/%^<>=" , yytext[0 ]))
494491return yytext[0 ];
495492}
496493