|
From: Hans-Bernhard B. <br...@us...> - 2001-06-19 20:04:05
|
Update of /cvsroot/cscope/cscope/src
In directory usw-pr-cvs1:/tmp/cvs-serv26568/src
Modified Files:
fscanner.l
Log Message:
fscanner.l: bugfixes and improvements
Index: fscanner.l
===================================================================
RCS file: /cvsroot/cscope/cscope/src/fscanner.l,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** fscanner.l 2001/06/15 11:00:35 1.3
--- fscanner.l 2001/06/19 20:04:02 1.4
***************
*** 139,143 ****
/* exclusive start conditions. not available in AT&T lex -> use flex! */
! %x WAS_ENDIF WAS_IDENTIFIER WAS_ESU IN_DQUOTE IN_SQUOTE COMMENT
%%
--- 139,143 ----
/* exclusive start conditions. not available in AT&T lex -> use flex! */
! %x IN_PREPROC WAS_ENDIF WAS_IDENTIFIER WAS_ESU IN_DQUOTE IN_SQUOTE COMMENT
%%
***************
*** 223,229 ****
}
! \#[ \t]*endif(([ \t]|{comment}).*)? { /* #endif */
/* delay treatment of #endif depending on whether an
* #if comes right after it, or not */
BEGIN(WAS_ENDIF);
goto more;
--- 223,245 ----
}
! \#[ \t]* { /* start a preprocessor line */
! if (rules == NO) /* don't consider CPP for lex/yacc rules */
! BEGIN(IN_PREPROC);
! yyleng = 1; /* get rid of the blanks, if any */
! goto more;
! /* NOTREACHED */
! }
! <IN_PREPROC>.|\n |
! <IN_PREPROC>{identifier} { /* unknown preprocessor line */
! BEGIN(INITIAL);
! goto more;
! /* NOTREACHED */
! }
!
! <IN_PREPROC>endif([^a-zA-Z0-9_$\n].*)? { /* #endif */
/* delay treatment of #endif depending on whether an
* #if comes right after it, or not */
+ /* HBB 20010619: new pattern allows trailing garbage
+ * after the #endif */
BEGIN(WAS_ENDIF);
goto more;
***************
*** 267,273 ****
}
! \#[ \t]*ifndef[ \t]+ |
! \#[ \t]*ifdef[ \t]+ |
! \#[ \t]*if[ \t]+ { /* #if directive */
elseelif = NO;
if (pseudoelif == YES) {
--- 283,289 ----
}
! <IN_PREPROC>ifndef[ \t]+ |
! <IN_PREPROC>ifdef[ \t]+ |
! <IN_PREPROC>if[ \t]+ { /* #if directive */
elseelif = NO;
if (pseudoelif == YES) {
***************
*** 285,292 ****
preifbraces[iflevel] = braces;
maxifbraces[iflevel++] = 0;
goto more;
/* NOTREACHED */
}
! \#[ \t]*else([ \t].*)? { /* #else --- eat up whole line */
elseelif = YES;
if (iflevel > 0) {
--- 301,309 ----
preifbraces[iflevel] = braces;
maxifbraces[iflevel++] = 0;
+ BEGIN(INITIAL);
goto more;
/* NOTREACHED */
}
! <IN_PREPROC>else([ \t].*)? { /* #else --- eat up whole line */
elseelif = YES;
if (iflevel > 0) {
***************
*** 299,306 ****
braces = preifbraces[iflevel - 1];
}
goto more;
/* NOTREACHED */
}
! \#[ \t]*elif[ \t]+ { /* #elif */
/* elseelif = YES; --- HBB I doubt this is correct */
elif:
--- 316,324 ----
braces = preifbraces[iflevel - 1];
}
+ BEGIN(INITIAL);
goto more;
/* NOTREACHED */
}
! <IN_PREPROC>elif[ \t]+ { /* #elif */
/* elseelif = YES; --- HBB I doubt this is correct */
elif:
***************
*** 314,321 ****
--- 332,360 ----
braces = preifbraces[iflevel - 1];
}
+ BEGIN(INITIAL);
goto more;
/* NOTREACHED */
}
+ <IN_PREPROC>include[ \t]*\"[^"\n]+\" |
+ <IN_PREPROC>include[ \t]*<[^>\n]+> { /* #include file */
+ char *s;
+ char remember = yytext[yyleng-1];
+
+ my_yymore();
+ s = strpbrk(my_yytext, "\"<");
+ my_yytext[my_yyleng-1] = '\0';
+ incfile(s + 1, s);
+ my_yytext[my_yyleng-1] = remember;
+ first = s - my_yytext;
+ last = my_yyleng - 1;
+ if (compress == YES) {
+ yytext[0] = '\2'; /* compress the keyword */
+ }
+ BEGIN(INITIAL);
+ return(INCLUDE);
+ /* NOTREACHED */
+ }
+
\} {
/* could be the last enum member initializer */
***************
*** 406,410 ****
/* NOTREACHED */
}
! \#[ \t]*define[ \t]+{identifier} {
/* preprocessor macro or constant definition */
--- 445,449 ----
/* NOTREACHED */
}
! <IN_PREPROC>define[ \t]+{identifier} {
/* preprocessor macro or constant definition */
***************
*** 425,428 ****
--- 464,468 ----
++first;
last = my_yyleng;
+ BEGIN(INITIAL);
goto definition;
/* NOTREACHED */
***************
*** 443,451 ****
}
<WAS_ESU>{
! ({whitespace}+{identifier})?{whitespace}*\{ { /* e/s/u definition */
tagdef = my_yytext[ident_start];
BEGIN(WAS_IDENTIFIER);
goto ident;
}
({whitespace}+{identifier})?{whitespace}* |
.|\n { /* e/s/u usage */
--- 483,502 ----
}
<WAS_ESU>{
! ({whitespace}+{identifier}){whitespace}*\{ { /* e/s/u definition */
tagdef = my_yytext[ident_start];
BEGIN(WAS_IDENTIFIER);
goto ident;
}
+ {whitespace}*\{ { /* e/s/u definition without a tag */
+ tagdef = my_yytext[ident_start];
+ BEGIN(INITIAL);
+ if (braces == 0) {
+ esudef = YES;
+ }
+ last = first;
+ yyless(0); /* re-scan all this as normal text */
+ tagdef = '\0';
+ goto more;
+ }
({whitespace}+{identifier})?{whitespace}* |
.|\n { /* e/s/u usage */
***************
*** 467,470 ****
--- 518,522 ----
/* NOTREACHED */
}
+
<WAS_IDENTIFIER>{
[ \t]*\(({whitespace}|{identifier}|[*&[\]=,.])*\)([()]|{whitespace})*[:a-zA-Z_#{] {
***************
*** 726,747 ****
}
! \#[ \t]*include[ \t]*\"[^"\n]+\" |
! \#[ \t]*include[ \t]*<[^>\n]+> { /* #include file */
! char *s;
! char remember = yytext[yyleng-1];
!
! my_yymore();
! s = strpbrk(my_yytext, "\"<");
! my_yytext[my_yyleng-1] = '\0';
! incfile(s + 1, s);
! my_yytext[my_yyleng-1] = remember;
! first = s - my_yytext;
! last = my_yyleng - 1;
! if (compress == YES) {
! yytext[0] = '\2'; /* compress the keyword */
! }
! return(INCLUDE);
! /* NOTREACHED */
! }
"/*" yy_push_state(COMMENT);
--- 778,784 ----
}
! [ \t]{2,} { /* compress sequential whitespace here, not in putcrossref() */
! unput(' ');
! }
"/*" yy_push_state(COMMENT);
***************
*** 766,769 ****
--- 803,807 ----
"//".*\n? {
+ /* C++-style one-line comment */
goto eol;
/* NOTREACHED */
***************
*** 772,776 ****
{number} | /* number */
<SDL>STATE[ \t]+ | /* ... and other syntax error catchers... */
- \#[ \t]*{identifier} | /* unknown preprocessor line */
. { /* punctuation and operators */
more:
--- 810,813 ----
***************
*** 825,829 ****
my_yyleng = 0;
! BEGIN 0;
/* if this is not a C file */
--- 862,866 ----
my_yyleng = 0;
! BEGIN(INITIAL);
/* if this is not a C file */
***************
*** 844,848 ****
if (strcmp(s, "sd") == 0) { /* sdl */
sdl = YES;
! BEGIN SDL;
}
break;
--- 881,885 ----
if (strcmp(s, "sd") == 0) { /* sdl */
sdl = YES;
! BEGIN(SDL);
}
break;
|