about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorEric Holk <eric.holk@gmail.com>2012-07-05 23:14:27 -0700
committerEric Holk <eric.holk@gmail.com>2012-07-06 10:42:41 -0700
commit7b03832c958826b27ea77df91f2d2ac276bb7411 (patch)
tree37832e91fead2552b564a56b7da753b80103bd29 /src/libsyntax
parentfa4134611dfc54e117f196644d30948a75b7b9eb (diff)
downloadrust-7b03832c958826b27ea77df91f2d2ac276bb7411.tar.gz
rust-7b03832c958826b27ea77df91f2d2ac276bb7411.zip
Updating tests to use pipes.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/pipes/parse_proto.rs58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs
index 919960f4c82..abf19825fdd 100644
--- a/src/libsyntax/ext/pipes/parse_proto.rs
+++ b/src/libsyntax/ext/pipes/parse_proto.rs
@@ -10,11 +10,10 @@ impl proto_parser for parser {
     fn parse_proto(id: ident) -> protocol {
         let proto = protocol(id);
 
-        self.expect(token::LBRACE);
-
-        while self.token != token::RBRACE {
-            self.parse_state(proto);
-        }
+        self.parse_unspanned_seq(token::LBRACE,
+                                 token::RBRACE,
+                                 {sep: none, trailing_sep_allowed: false},
+                                 |self| self.parse_state(proto));
 
         ret proto;
     }
@@ -35,29 +34,44 @@ impl proto_parser for parser {
           _ { fail }
         };
 
-        let state = proto.add_state(id, dir);
-        // TODO: add typarams too.
+        let typarms = if self.token == token::LT {
+            self.parse_ty_params()
+        }
+        else { ~[] };
+
+        let state = proto.add_state_poly(id, dir, typarms);
 
-        self.expect(token::LBRACE);
+        // parse the messages
+        self.parse_unspanned_seq(
+            token::LBRACE, token::RBRACE,
+            {sep: some(token::COMMA), trailing_sep_allowed: true},
+            |self| {
+                let mname = self.parse_ident();
 
-        while self.token != token::RBRACE {
-            let mname = self.parse_ident();
+                let args = if self.token == token::LPAREN {
+                    self.parse_unspanned_seq(token::LPAREN,
+                                             token::RPAREN,
+                                             {sep: some(token::COMMA),
+                                              trailing_sep_allowed: true},
+                                             |p| p.parse_ty(false))
+                }
+                else { ~[] };
 
-            // TODO: parse data
+                self.expect(token::RARROW);
 
-            self.expect(token::RARROW);
+                let next = self.parse_ident();
 
-            let next = self.parse_ident();
-            // TODO: parse next types
+                let ntys = if self.token == token::LT {
+                    self.parse_unspanned_seq(token::LT,
+                                             token::GT,
+                                             {sep: some(token::COMMA),
+                                              trailing_sep_allowed: true},
+                                             |p| p.parse_ty(false))
+                }
+                else { ~[] };
 
-            state.add_message(mname, ~[], next, ~[]);
+                state.add_message(mname, args, next, ntys);
 
-            alt copy self.token {
-              token::COMMA { self.bump() }
-              token::RBRACE { }
-              _ { fail }
-            }
-        }
-        self.bump();
+            });
     }
 }