@@ -2490,7 +2490,40 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
24902490 // Example : <Capture_Start> <Value> <Comma>
24912491 // idx +1 +2
24922492 bool detected_comma = _ctx->parser .Tokens .Arr [ _ctx->parser .Tokens .Idx + 2 ].Type == Tok_Comma;
2493- if ( detected_capture && ! detected_comma )
2493+
2494+ b32 detected_non_varadic_unpaired_param = detected_comma && nexttok.Type != Tok_Varadic_Argument;
2495+ if (! detected_non_varadic_unpaired_param && nexttok.Type == Tok_Preprocess_Macro_Expr) for ( s32 break_scope = 0 ; break_scope == 0 ; ++ break_scope)
2496+ {
2497+ Macro* macro = lookup_macro ( nexttok.Text );
2498+ if (macro == nullptr || ! macro_is_functional (* macro))
2499+ break ;
2500+
2501+ // ( <Macro_Expr> (
2502+ // Idx +1 +2
2503+ s32 idx = _ctx->parser .Tokens .Idx + 1 ;
2504+ s32 level = 0 ;
2505+
2506+ // Find end of the token expression
2507+ for ( ; idx < array_num (_ctx->parser .Tokens .Arr ); idx++ )
2508+ {
2509+ Token tok = _ctx->parser .Tokens .Arr [ idx ];
2510+
2511+ if ( tok.Type == Tok_Capture_Start )
2512+ level++;
2513+ else if ( tok.Type == Tok_Capture_End && level > 0 )
2514+ level--;
2515+ if (level == 0 && tok.Type == Tok_Capture_End)
2516+ break ;
2517+ }
2518+ ++ idx; // Will incremnt to possible comma position
2519+
2520+ if ( _ctx->parser .Tokens .Arr [ idx ].Type != Tok_Comma )
2521+ break ;
2522+
2523+ detected_non_varadic_unpaired_param = true ;
2524+ }
2525+
2526+ if ( detected_capture && ! detected_non_varadic_unpaired_param )
24942527 {
24952528 // Dealing with a function
24962529 result = cast (Code, parse_function_after_name ( ModuleFlag_None, attributes, specifiers, type, name ));
@@ -2509,7 +2542,7 @@ Code parse_operator_function_or_variable( bool expects_function, CodeAttributes
25092542 }
25102543 }
25112544
2512- parser_pop (& _ctx->parser );
2545+ parser_pop (& _ctx->parser );
25132546 return result;
25142547}
25152548
@@ -3002,7 +3035,7 @@ Code parse_simple_preprocess( TokType which )
30023035 || str_contains (calling_proc, txt (" parse_class_struct_body" ))
30033036 )
30043037 {
3005- if (peektok.Type == Tok_Statement_End)
3038+ if (left && peektok.Type == Tok_Statement_End)
30063039 {
30073040 Token stmt_end = currtok;
30083041 eat ( Tok_Statement_End );
@@ -5015,7 +5048,6 @@ CodeTypedef parser_parse_typedef()
50155048 // valid_macro |= macro && macro_expects_body(* macro));
50165049 // }
50175050
5018- Code macro;
50195051 if ( valid_macro )
50205052#endif
50215053 {
0 commit comments