blob: cbb5c65c7ff48338a1be88602552f37663a4e31b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* MRustC - Rust Compiler
* - By John Hodge (Mutabah/thePowersGang)
*
* expand/stringify.cpp
* - stringify! macro
*/
#include <synext.hpp>
#include "../parse/common.hpp"
#include "../parse/ttstream.hpp"
class CExpander:
public ExpandProcMacro
{
::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
{
Token tok;
::std::string rv;
auto lex = TTStream(tt);
while( GET_TOK(tok, lex) != TOK_EOF )
{
if(!rv.empty())
rv += " ";
rv += tok.to_str();
}
return box$( TTStreamO(TokenTree(Token(TOK_STRING, mv$(rv)))) );
}
};
STATIC_MACRO("stringify", CExpander);
|