summaryrefslogtreecommitdiff
path: root/src/expand/mod.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-10 09:33:34 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-10 09:33:34 +0800
commit874994e677c48689036587033831af56f78797c8 (patch)
tree3bf94cf6bb51343d7f612c2798f8fa8d28dd4ee5 /src/expand/mod.cpp
parent1e8587f474adb1c37147da8d25c4fb364f8fde1c (diff)
downloadmrust-874994e677c48689036587033831af56f78797c8.tar.gz
Expand - Macro cleanup, add cfg! macro (stubbed)
Diffstat (limited to 'src/expand/mod.cpp')
-rw-r--r--src/expand/mod.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp
index d77650d0..33f982da 100644
--- a/src/expand/mod.cpp
+++ b/src/expand/mod.cpp
@@ -56,7 +56,7 @@ void Expand_Attrs(const ::AST::MetaItems& attrs, AttrStage stage, ::AST::Crate&
{
if( name == m.first && m.second->expand_early() == is_early )
{
- auto e = m.second->expand(input_ident, input_tt, mod);
+ auto e = m.second->expand(mi_span, input_ident, input_tt, mod);
return e;
}
}
@@ -155,16 +155,19 @@ void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> m
void visit(::AST::ExprNode_Macro& node) override {
auto ttl = Expand_Macro(
- false, modstack, *(::AST::Module*)(modstack.m_item),
+ is_early, modstack, *(::AST::Module*)(modstack.m_item),
Span(node.get_pos()),
node.m_name, node.m_ident, node.m_tokens
);
- // Reparse as expression / item
- auto newexpr = Parse_Expr0(*ttl);
- // Then call visit on it again
- this->visit(newexpr);
- // And schedule it to replace the previous
- replacement = mv$(newexpr);
+ if( ttl.get() != nullptr && ttl->lookahead(0) != TOK_EOF )
+ {
+ // Reparse as expression / item
+ auto newexpr = Parse_Expr0(*ttl);
+ // Then call visit on it again
+ this->visit(newexpr);
+ // And schedule it to replace the previous
+ replacement = mv$(newexpr);
+ }
}
void visit(::AST::ExprNode_Block& node) override {