|
From: Hans-Bernhard B. <br...@us...> - 2002-06-20 16:25:37
|
Update of /cvsroot/cscope/cscope/src
In directory usw-pr-cvs1:/tmp/cvs-serv26864/src
Modified Files:
fscanner.l
Log Message:
Make flex scanner more tolerant to unexpected whitespace characters
Index: fscanner.l
===================================================================
RCS file: /cvsroot/cscope/cscope/src/fscanner.l,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** fscanner.l 13 Sep 2001 16:44:52 -0000 1.8
--- fscanner.l 20 Jun 2002 16:25:33 -0000 1.9
***************
*** 129,133 ****
number \.?[0-9][.0-9a-fA-FlLuUxX]*
comment "/*"([^*]*("*"+[^/])?)*"*/"|"//"[^\n]*\n
! whitespace [ \t\n]|{comment}
/* flex options: stack of start conditions, and don't use yywrap() */
--- 129,134 ----
number \.?[0-9][.0-9a-fA-FlLuUxX]*
comment "/*"([^*]*("*"+[^/])?)*"*/"|"//"[^\n]*\n
! ws [ \t\r\v\f]
! wsnl [ \t\n]|{comment}
/* flex options: stack of start conditions, and don't use yywrap() */
***************
*** 224,228 ****
}
! \#[ \t]* { /* start a preprocessor line */
if (rules == NO) /* don't consider CPP for lex/yacc rules */
BEGIN(IN_PREPROC);
--- 225,229 ----
}
! \#{ws}* { /* start a preprocessor line */
if (rules == NO) /* don't consider CPP for lex/yacc rules */
BEGIN(IN_PREPROC);
***************
*** 240,244 ****
/* NOTREACHED */
}
! <WAS_ENDIF>\n{whitespace}*#[ \t]*if(ndef|def)?[ \t]+ {
/* attempt to correct erroneous brace count caused by:
*
--- 241,245 ----
/* NOTREACHED */
}
! <WAS_ENDIF>\n{wsnl}*#{ws}*if(ndef|def)?{ws}+ {
/* attempt to correct erroneous brace count caused by:
*
***************
*** 262,266 ****
/* NOTREACHED */
}
! <WAS_ENDIF>\n{whitespace}* { /* an #endif with no #if right after it */
endif:
if (iflevel > 0) {
--- 263,267 ----
/* NOTREACHED */
}
! <WAS_ENDIF>\n{wsnl}* { /* an #endif with no #if right after it */
endif:
if (iflevel > 0) {
***************
*** 277,283 ****
}
! <IN_PREPROC>ifndef[ \t]+ |
! <IN_PREPROC>ifdef[ \t]+ |
! <IN_PREPROC>if[ \t]+ { /* #if directive */
elseelif = NO;
if (pseudoelif == YES) {
--- 278,284 ----
}
! <IN_PREPROC>ifndef{ws}+ |
! <IN_PREPROC>ifdef{ws}+ |
! <IN_PREPROC>if{ws}+ { /* #if directive */
elseelif = NO;
if (pseudoelif == YES) {
***************
*** 299,303 ****
/* NOTREACHED */
}
! <IN_PREPROC>else([ \t].*)? { /* #else --- eat up whole line */
elseelif = YES;
if (iflevel > 0) {
--- 300,304 ----
/* NOTREACHED */
}
! <IN_PREPROC>else({ws}.*)? { /* #else --- eat up whole line */
elseelif = YES;
if (iflevel > 0) {
***************
*** 314,318 ****
/* NOTREACHED */
}
! <IN_PREPROC>elif[ \t]+ { /* #elif */
/* elseelif = YES; --- HBB I doubt this is correct */
elif:
--- 315,319 ----
/* NOTREACHED */
}
! <IN_PREPROC>elif{ws}+ { /* #elif */
/* elseelif = YES; --- HBB I doubt this is correct */
elif:
***************
*** 331,336 ****
}
! <IN_PREPROC>include[ \t]*\"[^"\n]+\" |
! <IN_PREPROC>include[ \t]*<[^>\n]+> { /* #include file */
char *s;
char remember = yytext[yyleng-1];
--- 332,337 ----
}
! <IN_PREPROC>include{ws}*\"[^"\n]+\" |
! <IN_PREPROC>include{ws}*<[^>\n]+> { /* #include file */
char *s;
char remember = yytext[yyleng-1];
***************
*** 439,443 ****
/* NOTREACHED */
}
! <IN_PREPROC>define[ \t]+{identifier} {
/* preprocessor macro or constant definition */
--- 440,444 ----
/* NOTREACHED */
}
! <IN_PREPROC>define{ws}+{identifier} {
/* preprocessor macro or constant definition */
***************
*** 469,473 ****
}
! class{whitespace}+{identifier}({whitespace}|{identifier}|[():])*\{ { /* class definition */
classdef = YES;
tagdef = 'c';
--- 470,474 ----
}
! class{wsnl}+{identifier}({wsnl}|{identifier}|[():])*\{ { /* class definition */
classdef = YES;
tagdef = 'c';
***************
*** 484,493 ****
}
<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);
--- 485,494 ----
}
<WAS_ESU>{
! ({wsnl}+{identifier}){wsnl}*\{ { /* e/s/u definition */
tagdef = my_yytext[ident_start];
BEGIN(WAS_IDENTIFIER);
goto ident;
}
! {wsnl}*\{ { /* e/s/u definition without a tag */
tagdef = my_yytext[ident_start];
BEGIN(INITIAL);
***************
*** 500,504 ****
goto more;
}
! ({whitespace}+{identifier})?{whitespace}* |
.|\n { /* e/s/u usage */
BEGIN(WAS_IDENTIFIER);
--- 501,505 ----
goto more;
}
! ({wsnl}+{identifier})?{wsnl}* |
.|\n { /* e/s/u usage */
BEGIN(WAS_IDENTIFIER);
***************
*** 507,511 ****
}
! if{whitespace}*\( { /* ignore 'if' */
yyless(2);
yy_set_bol(0);
--- 508,512 ----
}
! if{wsnl}*\( { /* ignore 'if' */
yyless(2);
yy_set_bol(0);
***************
*** 521,525 ****
<WAS_IDENTIFIER>{
! [ \t]*\(({whitespace}|{identifier}|[*&[\]=,.])*\)([()]|{whitespace})*[:a-zA-Z_#{] {
/* a function definition */
/* note: "#define a (b) {" and "#if defined(a)\n#"
--- 522,526 ----
<WAS_IDENTIFIER>{
! {ws}*\(({wsnl}|{identifier}|[*&[\]=,.])*\)([()]|{wsnl})*[:a-zA-Z_#{] {
/* a function definition */
/* note: "#define a (b) {" and "#if defined(a)\n#"
***************
*** 543,547 ****
/* NOTREACHED */
}
! [ \t]*\(([*&[\]=,.]|{identifier}|{whitespace})* { /* function call */
fcncal: if (fcndef == YES || ppdefine == YES || rules == YES) {
token = FCNCALL;
--- 544,548 ----
/* NOTREACHED */
}
! {ws}*\(([*&[\]=,.]|{identifier}|{wsnl})* { /* function call */
fcncal: if (fcndef == YES || ppdefine == YES || rules == YES) {
token = FCNCALL;
***************
*** 556,560 ****
/* NOTREACHED */
}
! ("*"|{whitespace})+{identifier} { /* typedef name or modifier use */
goto ident;
/* NOTREACHED */
--- 557,561 ----
/* NOTREACHED */
}
! ("*"|{wsnl})+{identifier} { /* typedef name or modifier use */
goto ident;
/* NOTREACHED */
***************
*** 769,773 ****
/* NOTREACHED */
}
! \\\n { /* line continuation inside a string! */
myylineno++;
goto more;
--- 770,774 ----
/* NOTREACHED */
}
! \\\n { /* line continuation inside a string! */
myylineno++;
goto more;
***************
*** 776,783 ****
}
! ^[ \t\f]+ { /* don't save leading white space */
}
! [ \t]{2,} { /* compress sequential whitespace here, not in putcrossref() */
unput(' ');
}
--- 777,793 ----
}
! ^{ws}+ { /* don't save leading white space */
! }
!
! {ws}+\n { /* eat whitespace at end of line */
! unput('\n');
! }
!
! [\t\r\v\f]+ { /* eat non-blank whitespace sequences, replace
! * by single blank */
! unput(' ');
}
! {ws}{2,} { /* compress sequential whitespace here, not in putcrossref() */
unput(' ');
}
|