From ec937d0805b205e5b33ed4f3cb54f40230a826e3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 13 Nov 2018 12:57:52 -0500 Subject: 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. * <> gets its own rule so as to produce a more on-point error message. * Remove duplicate {xdstart} rule. John Naylor, with a few additional changes by me Discussion: https://postgr.es/m/CAJVSVGWGqY9YBs2EwtRUkbNv=hXkN8yRPOoD1wxE6COgvvrz5g@mail.gmail.com --- src/fe_utils/psqlscan.l | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/fe_utils') diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l index fdf49875a72..ae5418e7da0 100644 --- a/src/fe_utils/psqlscan.l +++ b/src/fe_utils/psqlscan.l @@ -23,6 +23,7 @@ * * See psqlscan_int.h for additional commentary. * + * * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * @@ -39,6 +40,9 @@ } %{ + +/* LCOV_EXCL_START */ + #include "fe_utils/psqlscan_int.h" /* @@ -71,8 +75,6 @@ typedef int YYSTYPE; extern int psql_yyget_column(yyscan_t yyscanner); extern void psql_yyset_column(int column_no, yyscan_t yyscanner); -/* LCOV_EXCL_START */ - %} %option reentrant @@ -128,8 +130,8 @@ extern void psql_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 @@ -151,7 +153,7 @@ extern void psql_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] @@ -402,14 +404,15 @@ other . ECHO; } -{xcstart} { +{ +{xcstart} { cur_state->xcdepth++; /* Put back any characters past slash-star; see above */ yyless(2); ECHO; } -{xcstop} { +{xcstop} { if (cur_state->xcdepth <= 0) BEGIN(INITIAL); else @@ -417,17 +420,18 @@ other . ECHO; } -{xcinside} { +{xcinside} { ECHO; } -{op_chars} { +{op_chars} { ECHO; } -\*+ { +\*+ { ECHO; } +} /* */ {xbstart} { BEGIN(xb); -- cgit v1.2.3