*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.66 2000/10/25 07:00:33 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.67 2000/11/03 10:47:54 meskes Exp $
*
*-------------------------------------------------------------------------
*/
#include <limits.h>
#include <errno.h>
-#include "postgres.h"
-
#include "miscadmin.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
* We use exclusive states for quoted strings, extended comments,
* and to eliminate parsing troubles for numeric strings.
* Exclusive states:
- * <xb> binary numeric string - thomas 1997-11-16
+ * <xbit> bit string literal
* <xc> extended C-style comments - thomas 1997-07-12
* <xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
* <xh> hexadecimal numeric string - thomas 1997-11-16
* <xq> quoted strings - thomas 1997-07-30
*/
-%x xb
+%x xbit
%x xc
%x xd
%x xdc
%x xcond
%x xskip
-/* Binary number
+/* Bit string
*/
-xbstart [bB]{quote}
-xbstop {quote}
-xbinside [^']+
-xbcat {quote}{whitespace_with_newline}{quote}
+xbitstart [bB]{quote}
+xbitstop {quote}
+xbitinside [^']*
+xbitcat {quote}{whitespace_with_newline}{quote}
/* Hexadecimal number
*/
* If you change either set, adjust the character lists appearing in the
* rule for "operator"!
*/
-self [,()\[\].;$\:\+\-\*\/\%\^\<\>\=\|]
+self [,()\[\].;$\:\+\-\*\/\%\^\<\>\=]
op_chars [\~\!\@\#\^\&\|\`\?\$\+\-\*\/\%\<\>\=]
operator {op_chars}+
<xc><<EOF>> { mmerror(ET_ERROR, "Unterminated /* comment"); }
-<SQL>{xbstart} {
- BEGIN(xb);
+<SQL>{xbitstart} {
+ BEGIN(xbit);
startlit();
}
-<xb>{xbstop} {
+<xbit>{xbitstop} {
char* endptr;
BEGIN(SQL);
- errno = 0;
- yylval.ival = strtol(literalbuf, &endptr, 2);
- if (*endptr != '\0' || errno == ERANGE)
- mmerror(ET_ERROR, "Bad binary integer input!");
- return ICONST;
+ if (literalbuf[strspn(literalbuf, "01") + 1] != '\0')
+ mmerror(ET_ERROR, "invalid bit string input.");
+ yylval.str = literalbuf;
+ return BITCONST;
}
<xh>{xhinside} |
-<xb>{xbinside} {
+<xbit>{xbitinside} {
addlit(yytext, yyleng);
}
<xh>{xhcat} |
-<xb>{xbcat} {
+<xbit>{xbitcat} {
/* ignore */
}
-<xb><<EOF>> { mmerror(ET_ERROR, "Unterminated binary integer"); }
+<xbit><<EOF>> { mmerror(ET_ERROR, "Unterminated bit string"); }
<SQL>{xhstart} {
BEGIN(xh);
* that the "self" rule would have.
*/
if (nchars == 1 &&
- strchr(",()[].;$:+-*/%^<>=|", yytext[0]))
+ strchr(",()[].;$:+-*/%^<>=", yytext[0]))
return yytext[0];
}
%token UNIONJOIN
/* Special keywords, not in the query language - see the "lex" file */
-%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP
+%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BITCONST
%token <ival> ICONST PARAM
%token <dval> FCONST
%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
%type <str> OptUnder key_reference comment_text ConstraintDeferrabilitySpec
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
-%type <str> ColConstraint ColConstraintElem drop_type
+%type <str> ColConstraint ColConstraintElem drop_type Bitconst
%type <str> OptTableElementList OptTableElement TableConstraint
%type <str> ConstraintElem key_actions ColQualList TokenId DropSchemaStmt
%type <str> target_list target_el update_target_list alias_clause
Iconst: ICONST { $$ = make_name();};
Fconst: FCONST { $$ = make_name();};
+Bitconst: BITCONST { $$ = make_name();};
Sconst: SCONST {
$$ = (char *)mm_alloc(strlen($1) + 3);
$$[0]='\'';
PosAllConst: Sconst { $$ = $1; }
| Fconst { $$ = $1; }
| Iconst { $$ = $1; }
+ | Bitconst { $$ = $1; }
| civar { $$ = make_str("?"); }
;