summaryrefslogtreecommitdiff
path: root/src/ast
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-02-18 21:34:00 +1100
committerJohn Hodge <tpg@mutabah.net>2016-02-18 21:34:00 +1100
commite674cb99edf50de91f8f5aed3188e30ffb7c88d7 (patch)
treece0dac42a5798b247ad8f9ee24842f5d0c2e4531 /src/ast
parentcf87314dde3af9468f3e24e29191412e8a2d19f7 (diff)
downloadmrust-e674cb99edf50de91f8f5aed3188e30ffb7c88d7.tar.gz
Parser - box Patterns, edge bug fix
Diffstat (limited to 'src/ast')
-rw-r--r--src/ast/pattern.cpp9
-rw-r--r--src/ast/pattern.hpp6
2 files changed, 15 insertions, 0 deletions
diff --git a/src/ast/pattern.cpp b/src/ast/pattern.cpp
index 1b189fa9..f2279a55 100644
--- a/src/ast/pattern.cpp
+++ b/src/ast/pattern.cpp
@@ -21,6 +21,9 @@ namespace AST {
(MaybeBind,
os << "?";
),
+ (Box,
+ os << "box " << *ent.sub;
+ ),
(Ref,
os << "&" << (ent.mut ? "mut " : "") << *ent.sub;
),
@@ -59,6 +62,9 @@ SERIALISE_TYPE(Pattern::, "Pattern", {
),
(MaybeBind,
),
+ (Box,
+ s << e.sub;
+ ),
(Ref,
s << e.mut;
s << e.sub;
@@ -88,6 +94,9 @@ SERIALISE_TYPE(Pattern::, "Pattern", {
_D(Any, )
_D(MaybeBind,
)
+ _D(Box,
+ s.item( ent.sub );
+ )
_D(Ref,
s.item( ent.mut );
s.item( ent.sub );
diff --git a/src/ast/pattern.hpp b/src/ast/pattern.hpp
index 6b89aa35..f28fe8e3 100644
--- a/src/ast/pattern.hpp
+++ b/src/ast/pattern.hpp
@@ -21,6 +21,7 @@ public:
TAGGED_UNION(Data, Any,
(Any, () ),
(MaybeBind, () ),
+ (Box, (unique_ptr<Pattern> sub;) ),
(Ref, (bool mut; unique_ptr<Pattern> sub;) ),
(Value, (unique_ptr<ExprNode> start; unique_ptr<ExprNode> end;) ),
(Tuple, (::std::vector<Pattern> sub_patterns;) ),
@@ -52,6 +53,11 @@ public:
m_data( Data::make_MaybeBind({}) )
{}
+ struct TagBox {};
+ Pattern(TagBox, Pattern sub):
+ m_data( Data::make_Box({ unique_ptr<Pattern>(new Pattern(mv$(sub))) }) )
+ {}
+
struct TagValue {};
Pattern(TagValue, unique_ptr<ExprNode> node, unique_ptr<ExprNode> node2 = 0):
m_data( Data::make_Value({ ::std::move(node), ::std::move(node2) }) )