summaryrefslogtreecommitdiff
path: root/src/expand/macro_rules.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/expand/macro_rules.cpp')
-rw-r--r--src/expand/macro_rules.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp
new file mode 100644
index 00000000..d860aaa3
--- /dev/null
+++ b/src/expand/macro_rules.cpp
@@ -0,0 +1,28 @@
+
+#include <synext.hpp>
+#include "../ast/expr.hpp"
+#include "../ast/ast.hpp"
+#include "../parse/common.hpp"
+
+class CMacroRulesExpander:
+ public ExpandProcMacro
+{
+ bool expand_early() const override { return true; }
+
+ AST::Expr expand(const ::std::string& ident, const TokenTree& tt, AST::Module& mod, MacroPosition position)
+ {
+ if( ident == "" ) {
+ throw ::std::runtime_error( "ERROR: macro_rules! requires an identifier" );
+ }
+
+ TTStream lex(tt);
+ auto mac = Parse_MacroRules(lex);
+ // TODO: Place into current module using `ident` as the name
+
+ return AST::Expr();
+ }
+};
+
+
+STATIC_MACRO("macro_rules", CMacroRulesExpander);
+