Updating tests to use pipes.

This commit is contained in:
Eric Holk 2012-07-05 23:14:27 -07:00
parent fa4134611d
commit 7b03832c95
8 changed files with 76 additions and 492 deletions

View file

@ -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.
self.expect(token::LBRACE);
while self.token != token::RBRACE {
let mname = self.parse_ident();
// TODO: parse data
self.expect(token::RARROW);
let next = self.parse_ident();
// TODO: parse next types
state.add_message(mname, ~[], next, ~[]);
alt copy self.token {
token::COMMA { self.bump() }
token::RBRACE { }
_ { fail }
}
let typarms = if self.token == token::LT {
self.parse_ty_params()
}
self.bump();
else { ~[] };
let state = proto.add_state_poly(id, dir, typarms);
// 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();
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 { ~[] };
self.expect(token::RARROW);
let next = self.parse_ident();
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, args, next, ntys);
});
}
}