diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-19 11:15:45 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-19 11:15:45 +0800 |
commit | b7b634f517967da41befff67d579c5a1afa8d016 (patch) | |
tree | 60f279e93a05d51acb94637c21cf5a0110bb008a /src/parse | |
parent | a3e8257c4f77f197c9be2dbae7aaddb81257abb2 (diff) | |
download | mrust-b7b634f517967da41befff67d579c5a1afa8d016.tar.gz |
AST - Macro invocations in item list
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/root.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 87d1e9c3..b932bf1a 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -582,6 +582,7 @@ AST::Trait Parse_TraitDef(TokenStream& lex, AST::Module& mod, const AST::MetaIte CHECK_TOK(tok, TOK_BRACE_OPEN);
while( GET_TOK(tok, lex) != TOK_BRACE_CLOSE )
{
+
AST::MetaItems item_attrs;
while( tok.type() == TOK_ATTR_OPEN )
{
@@ -591,6 +592,17 @@ AST::Trait Parse_TraitDef(TokenStream& lex, AST::Module& mod, const AST::MetaIte }
SET_ATTRS(lex, item_attrs);
+ auto ps = lex.start_span();
+ if( tok.type() == TOK_MACRO ) {
+ auto inv = Parse_MacroInvocation( ps, AST::MetaItems(), mv$(tok.str()), lex );
+ // - Silently consume ';' after the macro
+ if( GET_TOK(tok, lex) != TOK_SEMICOLON )
+ PUTBACK(tok, lex);
+
+ trait.items().push_back( AST::Named<AST::Item>("", AST::Item(mv$(inv)), false) );
+ continue ;
+ }
+
bool is_specialisable = false;
if( tok.type() == TOK_IDENT && tok.str() == "default" ) {
is_specialisable = true;
|