From b7b634f517967da41befff67d579c5a1afa8d016 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 19 Aug 2016 11:15:45 +0800 Subject: AST - Macro invocations in item list --- src/parse/root.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/parse') 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(mv$(inv)), false) ); + continue ; + } + bool is_specialisable = false; if( tok.type() == TOK_IDENT && tok.str() == "default" ) { is_specialisable = true; -- cgit v1.2.3