mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Align ECPG lexer more closely with the core and psql lexers.
Make a bunch of basically-cosmetic changes to reduce the diffs between
the 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 start
condition scopes to do that.
There are a few non-cosmetic changes in the ECPG lexer:
* Bring over the decimalfail rule (and support function
process_integer_literal) so that ECPG will lex "1..10" into
the same tokens as the backend would. I'm not sure this makes any
visible 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-point
error message.
* Remove duplicate <SQL>{xdstart} rule.
John Naylor, with a few additional changes by me
Discussion: https://postgr.es/m/CAJVSVGWGqY9YBs2EwtRUkbNv=hXkN8yRPOoD1wxE6COgvvrz5g@mail.gmail.com
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
*
|
||||
* NOTE NOTE NOTE:
|
||||
*
|
||||
* The rules in this file must be kept in sync with src/fe_utils/psqlscan.l!
|
||||
* The rules in this file must be kept in sync with src/fe_utils/psqlscan.l
|
||||
* and src/interfaces/ecpg/preproc/pgc.l!
|
||||
*
|
||||
* The rules are designed so that the scanner never has to backtrack,
|
||||
* 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);
|
||||
%x xc
|
||||
%x xd
|
||||
%x xh
|
||||
%x xe
|
||||
%x xq
|
||||
%x xe
|
||||
%x xdolq
|
||||
%x xui
|
||||
%x xuiend
|
||||
@@ -192,7 +193,7 @@ extern void core_yyset_column(int column_no, yyscan_t yyscanner);
|
||||
* XXX perhaps \f (formfeed) should be treated as a newline as well?
|
||||
*
|
||||
* XXX if you change the set of whitespace characters, fix scanner_isspace()
|
||||
* to agree, and see also the plpgsql lexer.
|
||||
* to agree.
|
||||
*/
|
||||
|
||||
space [ \t\n\r\f]
|
||||
@@ -417,32 +418,36 @@ other .
|
||||
yyless(2);
|
||||
}
|
||||
|
||||
<xc>{xcstart} {
|
||||
<xc>{
|
||||
{xcstart} {
|
||||
(yyextra->xcdepth)++;
|
||||
/* Put back any characters past slash-star; see above */
|
||||
yyless(2);
|
||||
}
|
||||
|
||||
<xc>{xcstop} {
|
||||
{xcstop} {
|
||||
if (yyextra->xcdepth <= 0)
|
||||
BEGIN(INITIAL);
|
||||
else
|
||||
(yyextra->xcdepth)--;
|
||||
}
|
||||
|
||||
<xc>{xcinside} {
|
||||
{xcinside} {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
<xc>{op_chars} {
|
||||
{op_chars} {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
<xc>\*+ {
|
||||
\*+ {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
<xc><<EOF>> { yyerror("unterminated /* comment"); }
|
||||
<<EOF>> {
|
||||
yyerror("unterminated /* comment");
|
||||
}
|
||||
} /* <xc> */
|
||||
|
||||
{xbstart} {
|
||||
/* Binary bit type.
|
||||
|
||||
Reference in New Issue
Block a user