Skip to content

Commit

Permalink
Avoid code duplication and make the keyword matching more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Sep 24, 2019
1 parent 661a537 commit fe66145
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/code.l
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,14 @@ static bool skipLanguageSpecificKeyword(const QCString &kw)
return g_insideCpp && (kw == "remove" || kw == "set" || kw == "get");
}

static bool isCastKeyword(const QCString &s)
{
int i=s.find('<');
if (i==-1) return FALSE;
QCString kw = s.left(i).stripWhiteSpace();
return kw=="const_cast" || kw=="static_cast" || kw=="dynamic_cast" || kw=="reinterpret_cast";
}

/* -----------------------------------------------------------------
*/
#undef YY_INPUT
Expand Down Expand Up @@ -2619,9 +2627,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_name+=yytext+7;
}
<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>\(]*">"("::"{ID})*/{B}* { // A<T> *pt;
int i=QCString(yytext).find('<');
QCString kw = QCString(yytext).left(i).stripWhiteSpace();
if (kw.right(5)=="_cast" && YY_START==Body)
if (isCastKeyword(yytext) && YY_START==Body)
{
REJECT;
}
Expand Down Expand Up @@ -2651,9 +2657,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
}
<Body>{SCOPETNAME}{B}*"<"[^\n\/\-\.\{\"\>]*">"/{BN}*"(" |
<Body>{SCOPETNAME}/{BN}*"(" { // a() or c::a() or t<A,B>::a() or A\B\foo()
int i=QCString(yytext).find('<');
QCString kw = QCString(yytext).left(i).stripWhiteSpace();
if (kw.right(5)=="_cast" && YY_START==Body)
if (isCastKeyword(yytext))
{
REJECT;
}
Expand Down Expand Up @@ -3068,9 +3072,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
endFontClass();
}
<MemberCall2,FuncCall>{ID}(({B}*"<"[^\n\[\](){}<>]*">")?({B}*"::"{B}*{ID})?)* {
int i=QCString(yytext).find('<');
QCString kw = QCString(yytext).left(i).stripWhiteSpace();
if (kw.right(5)=="_cast")
if (isCastKeyword(yytext))
{
REJECT;
}
Expand Down

0 comments on commit fe66145

Please sign in to comment.