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

Commit8ac5e88

Browse files
author
Michael Meskes
committed
Distinguish between C and SQL mode for C-style comments.
SQL standard asks for allowing nested comments, while C does not. Therefore thetwo comments, while mostly similar, have to be parsed seperately.
1 parent64d15e4 commit8ac5e88

File tree

1 file changed

+27
-12
lines changed
  • src/interfaces/ecpg/preproc

1 file changed

+27
-12
lines changed

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ static struct _if_value
102102
* and to eliminate parsing troubles for numeric strings.
103103
* Exclusive states:
104104
*<xb> bit string literal
105-
*<xc> extended C-style comments - thomas 1997-07-12
105+
*<xcc> extended C-style comments in C
106+
*<xcsql> extended C-style comments in SQL
106107
*<xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27
107108
*<xh> hexadecimal numeric string - thomas 1997-11-16
108109
*<xq> standard quoted strings - thomas 1997-07-30
@@ -115,7 +116,8 @@ static struct _if_value
115116
*/
116117

117118
%xxb
118-
%xxc
119+
%xxcc
120+
%xxcsql
119121
%xxd
120122
%xxdc
121123
%xxh
@@ -369,23 +371,32 @@ cppline{space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
369371

370372
<SQL>{whitespace}{/* ignore */ }
371373

372-
<C,SQL>{xcstart}{
374+
<C>{xcstart}{
373375
token_start = yytext;
374376
state_before = YYSTATE;
375377
xcdepth =0;
376-
BEGIN(xc);
378+
BEGIN(xcc);
377379
/* Put back any characters past slash-star; see above */
378380
yyless(2);
379381
fputs("/*", yyout);
380382
}
381-
<xc>{xcstart}{
383+
<SQL>{xcstart}{
384+
token_start = yytext;
385+
state_before = YYSTATE;
386+
xcdepth =0;
387+
BEGIN(xcsql);
388+
/* Put back any characters past slash-star; see above */
389+
yyless(2);
390+
fputs("/*", yyout);
391+
}
392+
<xcc>{xcstart}{ ECHO; }
393+
<xcsql>{xcstart}{
382394
xcdepth++;
383395
/* Put back any characters past slash-star; see above */
384396
yyless(2);
385397
fputs("/*", yyout);
386398
}
387-
388-
<xc>{xcstop}{
399+
<xcsql>{xcstop}{
389400
ECHO;
390401
if (xcdepth <=0)
391402
{
@@ -395,12 +406,16 @@ cppline{space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
395406
else
396407
xcdepth--;
397408
}
409+
<xcc>{xcstop}{
410+
ECHO;
411+
BEGIN(state_before);
412+
token_start =NULL;
413+
}
414+
<xcc,xcsql>{xcinside}{ ECHO; }
415+
<xcc,xcsql>{op_chars}{ ECHO; }
416+
<xcc,xcsql>\*+{ ECHO; }
398417

399-
<xc>{xcinside}{ ECHO; }
400-
<xc>{op_chars}{ ECHO; }
401-
<xc>\*+{ ECHO; }
402-
403-
<xc><<EOF>>{mmfatal(PARSE_ERROR,"unterminated /* comment"); }
418+
<xcc,xcsql><<EOF>>{mmfatal(PARSE_ERROR,"unterminated /* comment"); }
404419

405420
<SQL>{xbstart}{
406421
token_start = yytext;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp