Skip to content

Commit b703c12

Browse files
author
Michael Meskes
committed
Parser sync.
1 parent 94d8bbe commit b703c12

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,5 +1004,10 @@ Tue Oct 31 16:09:55 CET 2000
10041004

10051005
- Added patch by Christof Petig <christof.petig@wtal.de> fixing some
10061006
parser bugs.
1007+
1008+
Fri Nov 3 11:34:43 CET 2000
1009+
1010+
- Synced pgc.l with scan.l.
1011+
- Synced gram.y and preproc.y.
10071012
- Set ecpg version to 2.8.0.
10081013
- Set library version to 3.2.0.

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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
*/
@@ -21,8 +21,6 @@
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 string literal
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 [,()\[\].;$\:\+\-\*\/\%\^\<\>\=]
196194
op_chars [\~\!\@\#\^\&\|\`\?\$\+\-\*\/\%\<\>\=]
197195
operator {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);
318316
startlit();
319317
}
320-
<xb>{xbstop} {
318+
<xbit>{xbitstop} {
321319
char* endptr;
322320

323321
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;
329326
}
330327

331328
<xh>{xhinside} |
332-
<xb>{xbinside} {
329+
<xbit>{xbitinside} {
333330
addlit(yytext, yyleng);
334331
}
335332
<xh>{xhcat} |
336-
<xb>{xbcat} {
333+
<xbit>{xbitcat} {
337334
/* ignore */
338335
}
339-
<xb><<EOF>> { mmerror(ET_ERROR, "Unterminated binary integer"); }
336+
<xbit><<EOF>> { mmerror(ET_ERROR, "Unterminated bit string"); }
340337

341338
<SQL>{xhstart} {
342339
BEGIN(xh);
@@ -490,7 +487,7 @@ cppline {space}*#(.*\\{line_end})*.*
490487
* that the "self" rule would have.
491488
*/
492489
if (nchars == 1 &&
493-
strchr(",()[].;$:+-*/%^<>=|", yytext[0]))
490+
strchr(",()[].;$:+-*/%^<>=", yytext[0]))
494491
return yytext[0];
495492
}
496493

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ make_name(void)
242242
%token UNIONJOIN
243243

244244
/* Special keywords, not in the query language - see the "lex" file */
245-
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP
245+
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE IP BITCONST
246246
%token <ival> ICONST PARAM
247247
%token <dval> FCONST
248248

@@ -281,7 +281,7 @@ make_name(void)
281281
%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
282282
%type <str> OptUnder key_reference comment_text ConstraintDeferrabilitySpec
283283
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
284-
%type <str> ColConstraint ColConstraintElem drop_type
284+
%type <str> ColConstraint ColConstraintElem drop_type Bitconst
285285
%type <str> OptTableElementList OptTableElement TableConstraint
286286
%type <str> ConstraintElem key_actions ColQualList TokenId DropSchemaStmt
287287
%type <str> target_list target_el update_target_list alias_clause
@@ -3790,6 +3790,7 @@ ParamNo: PARAM opt_indirection
37903790

37913791
Iconst: ICONST { $$ = make_name();};
37923792
Fconst: FCONST { $$ = make_name();};
3793+
Bitconst: BITCONST { $$ = make_name();};
37933794
Sconst: SCONST {
37943795
$$ = (char *)mm_alloc(strlen($1) + 3);
37953796
$$[0]='\'';
@@ -3825,6 +3826,7 @@ AllConst: Sconst { $$ = $1; }
38253826
PosAllConst: Sconst { $$ = $1; }
38263827
| Fconst { $$ = $1; }
38273828
| Iconst { $$ = $1; }
3829+
| Bitconst { $$ = $1; }
38283830
| civar { $$ = make_str("?"); }
38293831
;
38303832

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy