Skip to content

Commit

Permalink
Reduce code duplication when storing clang symbol identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Apr 6, 2024
1 parent ea69f77 commit 9876b78
Showing 1 changed file with 17 additions and 31 deletions.
48 changes: 17 additions & 31 deletions src/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ static void addKnRArgInfo(yyscan_t yyscanner,const QCString &type,const QCString
const QCString &brief,const QCString &docs);
static int yyread(yyscan_t yyscanner,char *buf,int max_size);
static void setJavaProtection(yyscan_t yyscanner);
static void storeClangId(yyscan_t yyscanner,const char *id);

/* ----------------------------------------------------------------- */
#undef YY_INPUT
Expand Down Expand Up @@ -807,10 +808,7 @@ NONLopt [^\n]*
yyextra->current->type = "id";
}
yyextra->current->name = yytext;
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
}
<ObjCMethod>":"{B}* { // start of parameter list
yyextra->current->name += ':';
Expand Down Expand Up @@ -2374,10 +2372,7 @@ NONLopt [^\n]*
BEGIN(yyextra->requiresContext);
}
<FindMembers,FindMemberName>{SCOPENAME} {
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
yyextra->yyBegColNr=yyextra->yyColNr;
yyextra->yyBegLineNr=yyextra->yyLineNr;
lineCount(yyscanner);
Expand Down Expand Up @@ -2748,10 +2743,7 @@ NONLopt [^\n]*
*/
<SDefine>{ID} {
//printf("Define '%s' without args\n",yytext);
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
yyextra->current->bodyLine = yyextra->yyLineNr;
yyextra->current->bodyColumn = yyextra->yyColNr;
yyextra->current->name = yytext;
Expand Down Expand Up @@ -3976,10 +3968,7 @@ NONLopt [^\n]*
}
<Sharp>. { yyextra->current->type += *yytext ; }
<FindFields>{ID} {
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
yyextra->current->bodyLine = yyextra->yyLineNr;
yyextra->current->bodyColumn = yyextra->yyColNr;
yyextra->current->name = yytext;
Expand Down Expand Up @@ -5970,10 +5959,7 @@ NONLopt [^\n]*
}
<CompoundName>{SCOPENAME} {
yyextra->current->name = yytext ;
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
lineCount(yyscanner);
if (yyextra->current->spec.isProtocol())
{
Expand Down Expand Up @@ -6038,12 +6024,7 @@ NONLopt [^\n]*
<ClassVar>({ID}{BN}*"::"{BN}*)+{ID} {
yyextra->yyBegColNr=yyextra->yyColNr;
yyextra->yyBegLineNr=yyextra->yyLineNr;

if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}

storeClangId(yyscanner,yytext);
lineCount(yyscanner);
if (yyextra->current->section.isEnum())
{ // found "enum a N::b" -> variable
Expand All @@ -6061,11 +6042,7 @@ NONLopt [^\n]*
<ClassVar>{ID} {
yyextra->yyBegColNr=yyextra->yyColNr;
yyextra->yyBegLineNr=yyextra->yyLineNr;

if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,yytext);
}
storeClangId(yyscanner,yytext);
if (yyextra->insideIDL && qstrcmp(yytext,"switch")==0)
{
// Corba IDL style union
Expand Down Expand Up @@ -7509,6 +7486,15 @@ static void initEntry(yyscan_t yyscanner)
//-----------------------------------------------------------------------------
static void storeClangId(yyscan_t yyscanner,const char *id)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (yyextra->clangParser && (yyextra->insideCpp || yyextra->insideObjC))
{
yyextra->current->id = yyextra->clangParser->lookup(yyextra->yyLineNr,id);
}
}
static void lineCount(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
Expand Down

0 comments on commit 9876b78

Please sign in to comment.