summaryrefslogtreecommitdiff
path: root/src/macros.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros.hpp')
-rw-r--r--src/macros.hpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/macros.hpp b/src/macros.hpp
index b2aeda53..4de41782 100644
--- a/src/macros.hpp
+++ b/src/macros.hpp
@@ -9,13 +9,19 @@
class MacroExpander;
-class MacroRuleEnt
+class MacroRuleEnt:
+ public Serialisable
{
friend class MacroExpander;
Token tok;
::std::string name;
public:
+ MacroRuleEnt():
+ tok(TOK_NULL),
+ name("")
+ {
+ }
MacroRuleEnt(Token tok):
tok(tok),
name("")
@@ -25,11 +31,17 @@ public:
name(name)
{
}
+
+ SERIALISABLE_PROTOTYPES();
};
-struct MacroPatEnt
+struct MacroPatEnt:
+ public Serialisable
{
- Token tok;
::std::string name;
+ Token tok;
+
+ ::std::vector<MacroPatEnt> subpats;
+
enum Type {
PAT_TOKEN,
PAT_TT,
@@ -38,22 +50,46 @@ struct MacroPatEnt
PAT_EXPR,
PAT_STMT,
PAT_BLOCK,
+ PAT_LOOP, // Enables use of subpats
} type;
+ MacroPatEnt():
+ tok(TOK_NULL),
+ type(PAT_TOKEN)
+ {
+ }
+ MacroPatEnt(Token tok):
+ tok(tok),
+ type(PAT_TOKEN)
+ {
+ }
+
MacroPatEnt(::std::string name, Type type):
- tok(),
name(name),
+ tok(),
type(type)
{
}
+
+ MacroPatEnt(Token sep, ::std::vector<MacroPatEnt> ents):
+ tok(sep),
+ subpats( move(ents) ),
+ type(PAT_LOOP)
+ {
+ }
+
+ SERIALISABLE_PROTOTYPES();
};
/// A rule within a macro_rules! blcok
-class MacroRule
+class MacroRule:
+ public Serialisable
{
public:
::std::vector<MacroPatEnt> m_pattern;
::std::vector<MacroRuleEnt> m_contents;
+
+ SERIALISABLE_PROTOTYPES();
};
/// A sigle 'macro_rules!' block
@@ -92,6 +128,7 @@ public:
virtual Token realGetToken() override;
};
+extern void Macro_SetModule(const LList<AST::Module*>& mod);
extern MacroExpander Macro_Invoke(const char* name, TokenTree input);
#endif // MACROS_HPP_INCLUDED