Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit aa93e83

Browse files
committed
Handle typedef unions/structs separately
Separate the handling of unions/structs vs typedef unions/struct account for the trailing typename.
1 parent d09dc7b commit aa93e83

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

4coder_fleury_lang_cpp.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,38 @@ internal F4_LANGUAGE_INDEXFILE(F4_CPP_IndexFile)
220220
}
221221

222222
//~ NOTE(rjf): Structs
223-
else if(F4_Index_ParsePattern(ctx, "%t", "struct") ||
224-
F4_Index_ParsePattern(ctx, "%t%t", "typedef", "struct"))
223+
else if(F4_Index_ParsePattern(ctx, "%t", "struct"))
224+
{
225+
handled = 1;
226+
F4_CPP_ParseStructOrUnionBodyIFuckingHateCPlusPlus(ctx, F4_Index_NoteFlag_ProductType);
227+
}
228+
else if(F4_Index_ParsePattern(ctx, "%t%t", "typedef", "struct"))
225229
{
226230
handled = 1;
227231
F4_CPP_ParseStructOrUnionBodyIFuckingHateCPlusPlus(ctx, 0);
232+
if (F4_Index_ParsePattern(ctx, "%k", TokenBaseKind_Identifier, &name))
233+
{
234+
F4_Index_MakeNote(ctx->app, ctx->file, 0, F4_Index_StringFromToken(ctx, name),
235+
F4_Index_NoteKind_Type, F4_Index_NoteFlag_ProductType, Ii64(name));
236+
}
228237
}
229238

230239
//~ NOTE(rjf): Unions
231-
else if(F4_Index_ParsePattern(ctx, "%t", "union") ||
232-
F4_Index_ParsePattern(ctx, "%t%t", "typedef", "union"))
240+
else if(F4_Index_ParsePattern(ctx, "%t", "union"))
233241
{
234242
handled = 1;
235243
F4_CPP_ParseStructOrUnionBodyIFuckingHateCPlusPlus(ctx, F4_Index_NoteFlag_SumType);
236244
}
245+
else if (F4_Index_ParsePattern(ctx, "%t%t", "typedef", "union"))
246+
{
247+
handled = 1;
248+
F4_CPP_ParseStructOrUnionBodyIFuckingHateCPlusPlus(ctx, F4_Index_NoteFlag_SumType);
249+
if (F4_Index_ParsePattern(ctx, "%k", TokenBaseKind_Identifier, &name))
250+
{
251+
F4_Index_MakeNote(ctx->app, ctx->file, 0, F4_Index_StringFromToken(ctx, name),
252+
F4_Index_NoteKind_Type, F4_Index_NoteFlag_SumType, Ii64(name));
253+
}
254+
}
237255

238256
//~ NOTE(rjf): Typedef'd Enums
239257
else if(F4_Index_ParsePattern(ctx, "%t%t%k", "typedef", "enum", TokenBaseKind_Identifier, &name) ||

0 commit comments

Comments
 (0)