summaryrefslogtreecommitdiff
path: root/src/macro_rules/mod.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-14 00:08:59 +0800
committerJohn Hodge <tpg@mutabah.net>2016-07-14 00:08:59 +0800
commit87f293aeef783ecafef49ed280709d125f9c1f4f (patch)
treeaa6e4e1386f1083cc1f94167dfb00b1b8756cbb9 /src/macro_rules/mod.cpp
parente353e6f88b4a694e1e93a1f09c84d086cc4a826d (diff)
downloadmrust-87f293aeef783ecafef49ed280709d125f9c1f4f.tar.gz
Macro Rules - Rewrite, take 3 - Incomplete
Diffstat (limited to 'src/macro_rules/mod.cpp')
-rw-r--r--src/macro_rules/mod.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/macro_rules/mod.cpp b/src/macro_rules/mod.cpp
index 24e877dc..4e914066 100644
--- a/src/macro_rules/mod.cpp
+++ b/src/macro_rules/mod.cpp
@@ -181,20 +181,33 @@ SERIALISE_TYPE_S(MacroPatEnt, {
return os;
}
-SERIALISE_TYPE_S(MacroRuleEnt, {
- s.item(name);
- s.item(tok);
- s.item(subpats);
-});
+SERIALISE_TU(MacroExpansionEnt, "MacroExpansionEnt", e,
+(Token,
+ s.item(e);
+ ),
+(NamedValue,
+ s.item(e);
+ ),
+(Loop,
+ s.item(e.entries);
+ s.item(e.joiner);
+ //s.item(e.variables);
+ )
+);
-::std::ostream& operator<<(::std::ostream& os, const MacroRuleEnt& x)
+::std::ostream& operator<<(::std::ostream& os, const MacroExpansionEnt& x)
{
- if(x.name.size())
- os << "$"<<x.name;
- else if( x.subpats.size() )
- os << "expand w/ " << x.tok << " [" << x.subpats << "]";
- else
- os << "=" << x.tok;
+ TU_MATCH( MacroExpansionEnt, (x), (e),
+ (Token,
+ os << "=" << e;
+ ),
+ (NamedValue,
+ os << "$" << e;
+ ),
+ (Loop,
+ os << "${" << *e.variables.begin() << "}(" << e.entries << ") " << e.joiner;
+ )
+ )
return os;
}