summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-13 10:50:16 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-13 10:50:16 +0200
commit6cb5c0980a14aaad0c676a88160726de52cac456 (patch)
treefedeab05fa4ac7578c99351c14bf4cda12079225 /src/comp/syntax
parent6914d32accd7cc3c29697bf0e2974e654558fe07 (diff)
downloadrust-6cb5c0980a14aaad0c676a88160726de52cac456.tar.gz
rust-6cb5c0980a14aaad0c676a88160726de52cac456.zip
box patterns, expect for the trans part
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast.rs2
-rw-r--r--src/comp/syntax/fold.rs1
-rw-r--r--src/comp/syntax/parse/parser.rs11
-rw-r--r--src/comp/syntax/print/pprust.rs4
-rw-r--r--src/comp/syntax/visit.rs1
-rw-r--r--src/comp/syntax/walk.rs1
6 files changed, 17 insertions, 3 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index fb0f474c084..3280c50e3da 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -126,6 +126,7 @@ tag pat_ {
     pat_lit(@lit);
     pat_tag(path, (@pat)[]);
     pat_rec(field_pat[], bool);
+    pat_box(@pat);
 }
 
 type pat_id_map = std::map::hashmap[str, ast::node_id];
@@ -143,6 +144,7 @@ fn pat_id_map(&@pat pat) -> pat_id_map {
             pat_rec(?fields, _) {
                 for (field_pat f in fields) { walk(map, f.pat); }
             }
+            pat_box(?inner) { walk(map, inner); }
             _ {}
         }
     }
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index 93c51b9baf8..ca2688d33e9 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -292,6 +292,7 @@ fn noop_fold_pat(&pat_ p, ast_fold fld) -> pat_ {
             }
             pat_rec(fs, etc)
         }
+        case (pat_box(?inner)) { pat_box(fld.fold_pat(inner)) }
     };
 }
 
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index ba6813cd6ce..fb9eca8640d 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1459,6 +1459,12 @@ fn parse_pat(&parser p) -> @ast::pat {
                 }
             }
         }
+        case (token::AT) {
+            p.bump();
+            auto sub = parse_pat(p);
+            pat = ast::pat_box(sub);
+            hi = sub.span.hi;
+        }
         case (token::LBRACE) {
             p.bump();
             auto fields = ~[];
@@ -2313,9 +2319,8 @@ fn parse_rest_import_name(&parser p, ast::ident first,
         }
         alt (p.peek()) {
             case (token::IDENT(_, _)) { identifiers += ~[parse_ident(p)]; }
-            case (
-                 //the lexer can't tell the different kinds of stars apart ) :
-                 token::BINOP(token::STAR)) {
+            //the lexer can't tell the different kinds of stars apart ) :
+            case (token::BINOP(token::STAR)) {
                 glob = true;
                 p.bump();
             }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 8875208e2a8..df573020618 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1136,6 +1136,10 @@ fn print_pat(&ps s, &@ast::pat pat) {
             }
             word(s.s, "}");
         }
+        case (ast::pat_box(?inner)) {
+            word(s.s, "@");
+            print_pat(s, inner);
+        }
     }
     s.ann.post(ann_node);
 }
diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs
index 5198130c2fb..83bf548efee 100644
--- a/src/comp/syntax/visit.rs
+++ b/src/comp/syntax/visit.rs
@@ -200,6 +200,7 @@ fn visit_pat[E](&@pat p, &E e, &vt[E] v) {
         case (pat_rec(?fields, _)) {
             for (field_pat f in fields) { v.visit_pat(f.pat, e, v); }
         }
+        case (pat_box(?inner)) { v.visit_pat(inner, e, v); }
         case (_) { }
     }
 }
diff --git a/src/comp/syntax/walk.rs b/src/comp/syntax/walk.rs
index 540905893a7..ad2edb980b1 100644
--- a/src/comp/syntax/walk.rs
+++ b/src/comp/syntax/walk.rs
@@ -192,6 +192,7 @@ fn walk_pat(&ast_visitor v, &@ast::pat p) {
         case (ast::pat_rec(?fields, _)) {
             for (ast::field_pat f in fields) { walk_pat(v, f.pat); }
         }
+        case (ast::pat_box(?inner)) { walk_pat(v, inner); }
         case (_) { }
     }
     v.visit_pat_post(p);