Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec937d0

Browse files
committed
Align ECPG lexer more closely with the core and psql lexers.
Make a bunch of basically-cosmetic changes to reduce the diffs betweenthe flex rules in scan.l, psqlscan.l, and pgc.l. Reorder some code,adjust a lot of whitespace, sync some comments, make use of flex startcondition scopes to do that.There are a few non-cosmetic changes in the ECPG lexer:* Bring over the decimalfail rule (and support functionprocess_integer_literal) so that ECPG will lex "1..10" intothe same tokens as the backend would. I'm not sure this makes anyvisible difference to users, but I'm not sure it doesn't, either.* <xdc><<EOF>> gets its own rule so as to produce a more on-pointerror message.* Remove duplicate <SQL>{xdstart} rule.John Naylor, with a few additional changes by meDiscussion:https://postgr.es/m/CAJVSVGWGqY9YBs2EwtRUkbNv=hXkN8yRPOoD1wxE6COgvvrz5g@mail.gmail.com
1 parentd20dcea commitec937d0

File tree

3 files changed

+594
-442
lines changed

3 files changed

+594
-442
lines changed

‎src/backend/parser/scan.l

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*
77
* NOTE NOTE NOTE:
88
*
9-
* The rules in this file must be kept in sync with src/fe_utils/psqlscan.l!
9+
* The rules in this file must be kept in sync with src/fe_utils/psqlscan.l
10+
* and src/interfaces/ecpg/preproc/pgc.l!
1011
*
1112
* The rules are designed so that the scanner never has to backtrack,
1213
* in the sense that there is always a rule that can match the input
@@ -168,8 +169,8 @@ extern void core_yyset_column(int column_no, yyscan_t yyscanner);
168169
%xxc
169170
%xxd
170171
%xxh
171-
%xxe
172172
%xxq
173+
%xxe
173174
%xxdolq
174175
%xxui
175176
%xxuiend
@@ -192,7 +193,7 @@ extern void core_yyset_column(int column_no, yyscan_t yyscanner);
192193
* XXX perhaps \f (formfeed) should be treated as a newline as well?
193194
*
194195
* XXX if you change the set of whitespace characters, fix scanner_isspace()
195-
* to agree, and see also the plpgsql lexer.
196+
* to agree.
196197
*/
197198

198199
space[\t\n\r\f]
@@ -417,32 +418,36 @@ other.
417418
yyless(2);
418419
}
419420

420-
<xc>{xcstart}{
421+
<xc>{
422+
{xcstart}{
421423
(yyextra->xcdepth)++;
422424
/* Put back any characters past slash-star; see above */
423425
yyless(2);
424426
}
425427

426-
<xc>{xcstop}{
428+
{xcstop}{
427429
if (yyextra->xcdepth <=0)
428430
BEGIN(INITIAL);
429431
else
430432
(yyextra->xcdepth)--;
431433
}
432434

433-
<xc>{xcinside}{
435+
{xcinside}{
434436
/* ignore */
435437
}
436438

437-
<xc>{op_chars}{
439+
{op_chars}{
438440
/* ignore */
439441
}
440442

441-
<xc>\*+{
443+
\*+{
442444
/* ignore */
443445
}
444446

445-
<xc><<EOF>>{yyerror("unterminated /* comment"); }
447+
<<EOF>>{
448+
yyerror("unterminated /* comment");
449+
}
450+
}/* <xc> */
446451

447452
{xbstart}{
448453
/* Binary bit type.

‎src/fe_utils/psqlscan.l

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*
2424
* See psqlscan_int.h for additional commentary.
2525
*
26+
*
2627
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
2728
* Portions Copyright (c) 1994, Regents of the University of California
2829
*
@@ -39,6 +40,9 @@
3940
}
4041

4142
%{
43+
44+
/* LCOV_EXCL_START*/
45+
4246
#include"fe_utils/psqlscan_int.h"
4347

4448
/*
@@ -71,8 +75,6 @@ typedef int YYSTYPE;
7175
extern intpsql_yyget_column(yyscan_t yyscanner);
7276
externvoidpsql_yyset_column(int column_no,yyscan_t yyscanner);
7377

74-
/* LCOV_EXCL_START*/
75-
7678
%}
7779

7880
%optionreentrant
@@ -128,8 +130,8 @@ extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
128130
%xxc
129131
%xxd
130132
%xxh
131-
%xxe
132133
%xxq
134+
%xxe
133135
%xxdolq
134136
%xxui
135137
%xxuiend
@@ -151,7 +153,7 @@ extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
151153
* XXX perhaps \f (formfeed) should be treated as a newline as well?
152154
*
153155
* XXX if you change the set of whitespace characters, fix scanner_isspace()
154-
* to agree, and see also the plpgsql lexer.
156+
* to agree.
155157
*/
156158

157159
space[\t\n\r\f]
@@ -402,32 +404,34 @@ other.
402404
ECHO;
403405
}
404406

405-
<xc>{xcstart}{
407+
<xc>{
408+
{xcstart}{
406409
cur_state->xcdepth++;
407410
/* Put back any characters past slash-star; see above */
408411
yyless(2);
409412
ECHO;
410413
}
411414

412-
<xc>{xcstop}{
415+
{xcstop}{
413416
if (cur_state->xcdepth <=0)
414417
BEGIN(INITIAL);
415418
else
416419
cur_state->xcdepth--;
417420
ECHO;
418421
}
419422

420-
<xc>{xcinside}{
423+
{xcinside}{
421424
ECHO;
422425
}
423426

424-
<xc>{op_chars}{
427+
{op_chars}{
425428
ECHO;
426429
}
427430

428-
<xc>\*+{
431+
\*+{
429432
ECHO;
430433
}
434+
}/* <xc> */
431435

432436
{xbstart}{
433437
BEGIN(xb);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp