diff options
-rw-r--r-- | src/expand/mod.cpp | 15 | ||||
-rw-r--r-- | src/parse/common.hpp | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index fe7507fb..d77650d0 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -159,9 +159,12 @@ void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> m Span(node.get_pos()), node.m_name, node.m_ident, node.m_tokens ); - // TODO: Reparse as expression / item - // TODO: Then call visit on it again - BUG(node.get_pos(), "TODO: Expand expression macros"); + // 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 { @@ -355,6 +358,8 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo } void Expand(::AST::Crate& crate) { + auto modstack = LList<const ::AST::Module*>(nullptr, &crate.m_root_module); + // 1. Crate attributes for( auto& a : crate.m_attrs.m_items ) { @@ -376,8 +381,8 @@ void Expand(::AST::Crate& crate) } // 3. Module tree - Expand_Mod(true , crate, LList<const ::AST::Module*>(nullptr, &crate.m_root_module), ::AST::Path(), crate.m_root_module); - Expand_Mod(false, crate, LList<const ::AST::Module*>(nullptr, &crate.m_root_module), ::AST::Path(), crate.m_root_module); + Expand_Mod(true , crate, modstack, ::AST::Path(), crate.m_root_module); + Expand_Mod(false, crate, modstack, ::AST::Path(), crate.m_root_module); // Post-process #if 0 diff --git a/src/parse/common.hpp b/src/parse/common.hpp index 57d11bf6..837bd104 100644 --- a/src/parse/common.hpp +++ b/src/parse/common.hpp @@ -59,6 +59,7 @@ extern AST::Function Parse_FunctionDef(TokenStream& lex, ::std::string abi, A extern AST::Function Parse_FunctionDefWithCode(TokenStream& lex, ::std::string abi, AST::MetaItems attrs, bool allow_self);
extern AST::Expr Parse_Expr(TokenStream& lex, bool const_only);
extern AST::Expr Parse_ExprBlock(TokenStream& lex);
+extern AST::ExprNodeP Parse_Expr0(TokenStream& lex);
extern bool Parse_IsTokValue(eTokenType tok_type);
|