@@ -1991,13 +1991,16 @@ local function doLateExpansionsResources(tokensToExpand, fileBuffers, params, st
19911991 -- @insert identifier ( argument1, ... )
19921992 -- @insert identifier " ... "
19931993 -- @insert identifier { ... }
1994+ -- @insert identifier !( ... )
1995+ -- @insert identifier !!( ... )
19941996 elseif ppKeywordTok .value == " insert" and isTokenAndNotNil (tokNext , " identifier" ) and tokNext .file == ppKeywordTok .file then
19951997 local identTok = tokNext
19961998 tokNext , iNext = getNextUsableToken (tokenStack , iNext - 1 , nil , - 1 )
19971999
19982000 if not (tokNext and (
19992001 tokNext .type == " string"
20002002 or (tokNext .type == " punctuation" and isAny (tokNext .value , " (" ," {" ," ." ," :" ," [" ))
2003+ or tokNext .type == " pp_entry"
20012004 )) then
20022005 errorAtToken (fileBuffers , identTok , identTok .position +# identTok .representation , " Macro" , " Syntax error: Expected '(' after macro name '%s'." , identTok .value )
20032006 end
@@ -2406,6 +2409,24 @@ local function expandMacro(tokens, fileBuffers, tokenStack, macroStartTok, isNes
24062409 -- Add ')' for end of call.
24072410 tableInsert (tokens , tableRemove (tokenStack )) -- ')'
24082411
2412+ -- @insert identifier !( ... )
2413+ -- @insert identifier !!( ... )
2414+ elseif isTokenAndNotNil (tokNext , " pp_entry" ) then
2415+ popTokens (tokenStack , iNext + 1 ) -- until '!' or '!!'
2416+
2417+ -- Add '(' for start of call.
2418+ if not isTokenAndNotNil (tokenStack [# tokenStack - 1 ], " punctuation" , " (" ) then
2419+ local tok = (tokenStack [# tokenStack - 1 ] or tokenStack [# tokenStack ])
2420+ errorAtToken (fileBuffers , tok , nil , " Macro" , " Expected '(' after '!'." )
2421+ end
2422+ tableInsert (tokens , newTokenAt ({type = " punctuation" , value = " (" , representation = " (" }, tokNext ))
2423+
2424+ processPreprocessorBlockInMacroArgument (tokens , fileBuffers , tokenStack )
2425+
2426+ -- Add ')' for end of call.
2427+ assert (isTokenAndNotNil (tokens [# tokens ], " punctuation" , " )" ))
2428+ tableInsert (tokens , newTokenAt ({type = " punctuation" , value = " )" , representation = " )" }, tokens [# tokens ]))
2429+
24092430 else
24102431 errorAfterToken (fileBuffers , lastCalleeTok , " Macro" , " Syntax error: Expected '(' after macro name." )
24112432 end
@@ -2424,6 +2445,8 @@ local function doLateExpansionsMacros(tokensToExpand, fileBuffers, params, stats
24242445 -- @insert identifier ( argument1, ... )
24252446 -- @insert identifier " ... "
24262447 -- @insert identifier { ... }
2448+ -- @insert identifier !( ... )
2449+ -- @insert identifier !!( ... )
24272450 --
24282451 if not stats .hasPreprocessorCode then
24292452 return tokensToExpand
@@ -2446,6 +2469,8 @@ local function doLateExpansionsMacros(tokensToExpand, fileBuffers, params, stats
24462469 -- @insert identifier ( argument1, ... )
24472470 -- @insert identifier " ... "
24482471 -- @insert identifier { ... }
2472+ -- @insert identifier !( ... )
2473+ -- @insert identifier !!( ... )
24492474 if ppKeywordTok .value == " insert" then
24502475 expandMacro (tokens , fileBuffers , tokenStack , ppKeywordTok , false )
24512476
0 commit comments