Skip to content

Commit 4170fa1

Browse files
committed
fix macro parsing bugs
1 parent 9c919e2 commit 4170fa1

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

4coder_fleury_lang_cpp.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11

22
internal void
3-
F4_CPP_ParseMacroDefinition(F4_Index_ParseCtx *ctx, F4_Index_TokenSkipFlags flags)
3+
F4_CPP_ParseMacroDefinition(F4_Index_ParseCtx *ctx)
44
{
55
Token *name = 0;
6-
if(F4_Index_RequireTokenKind(ctx, TokenBaseKind_Identifier, &name, flags))
6+
if(F4_Index_ParsePattern(ctx, "%k", TokenBaseKind_Identifier, &name))
77
{
88
F4_Index_MakeNote(ctx->app, ctx->file, 0, F4_Index_StringFromToken(ctx, name),
99
F4_Index_NoteKind_Macro, 0, Ii64(name));
10-
}
11-
for(;!ctx->done;)
12-
{
13-
Token *token = token_it_read(&ctx->it);
14-
if(!(token->flags & TokenBaseFlag_PreprocessorBody) ||
15-
token->kind == TokenBaseKind_Preprocessor)
16-
{
17-
break;
18-
}
19-
F4_Index_ParseCtx_IncWs(ctx);
10+
F4_Index_SkipSoftTokens(ctx, 1);
2011
}
2112
}
2213

@@ -36,7 +27,7 @@ F4_CPP_SkipParseBody(F4_Index_ParseCtx *ctx)
3627
}
3728
else if(F4_Index_ParsePattern(ctx, "%b", TokenCppKind_PPDefine, &name))
3829
{
39-
F4_CPP_ParseMacroDefinition(ctx, F4_Index_TokenSkipFlag_SkipWhitespace);
30+
F4_CPP_ParseMacroDefinition(ctx);
4031
}
4132
else if(F4_Index_ParsePattern(ctx, "%t", "{"))
4233
{
@@ -389,12 +380,10 @@ internal F4_LANGUAGE_INDEXFILE(F4_CPP_IndexFile)
389380
}
390381

391382
//~ NOTE(rjf): Macros
392-
else if(F4_Index_ParsePattern(ctx, "%b%k", TokenCppKind_PPDefine, (Token **)0, TokenBaseKind_Identifier, &name))
383+
else if(F4_Index_ParsePattern(ctx, "%b", TokenCppKind_PPDefine, &name))
393384
{
394385
handled = 1;
395-
F4_Index_MakeNote(ctx->app, ctx->file, 0, F4_Index_StringFromToken(ctx, name),
396-
F4_Index_NoteKind_Macro, 0, Ii64(name));
397-
F4_Index_SkipSoftTokens(ctx, 1);
386+
F4_CPP_ParseMacroDefinition(ctx);
398387
}
399388

400389

0 commit comments

Comments
 (0)