@@ -3286,17 +3286,18 @@ namespace simplecpp {
32863286 }
32873287
32883288 /* *
3289- * The replacement list of the macro, with the parameters replaced by the arguments.
3289+ * Tokens of the replacement list of the macro, with the parameters replaced by the
3290+ * arguments and ## done.
32903291 * @param result destination tokenlist
32913292 * @param macro the macro
32923293 * @param call the macro call
3294+ * @param begin first token in the replacement list
3295+ * @param end the token after the last one
32933296 */
3294- void substitute (TokenList &result, const Macro ¯o, const MacroCall &call) const {
3295- if (macro.variadicOpt )
3296- throw unsupported (loc, " __VA_OPT__" );
3297+ void substituteRange (TokenList &result, const Macro ¯o, const MacroCall &call, const Token *begin, const Token *end) const {
32973298 const Token *hashHash = nullptr ; // the ## before the current operand
32983299 bool previousEmpty = false ; // the previous operand was empty, it is a placemarker
3299- for (const Token *tok = macro. valueToken ; tok != macro. endToken ; tok = tok->next ) {
3300+ for (const Token *tok = begin ; tok != end ; tok = tok->next ) {
33003301 if (isHashHash (macro, tok)) {
33013302 if (!result.back () && !previousEmpty)
33023303 throw Macro::invalidHashHash (tok->location , macro.name (), " Missing first argument" );
@@ -3323,6 +3324,18 @@ namespace simplecpp {
33233324 }
33243325 if (hashHash)
33253326 throw Macro::invalidHashHash::unexpectedNewline (hashHash->location , macro.name ());
3327+ }
3328+
3329+ /* *
3330+ * The replacement list of the macro, with the parameters replaced by the arguments.
3331+ * @param result destination tokenlist
3332+ * @param macro the macro
3333+ * @param call the macro call
3334+ */
3335+ void substitute (TokenList &result, const Macro ¯o, const MacroCall &call) const {
3336+ if (macro.variadicOpt )
3337+ throw unsupported (loc, " __VA_OPT__" );
3338+ substituteRange (result, macro, call, macro.valueToken , macro.endToken );
33263339 for (Token *tok = result.front (); tok; tok = tok->next ) {
33273340 tok->location = loc;
33283341 tok->addToHideSet (call.hideSet );
0 commit comments