comments, helper function for tests, more informative error message
This commit is contained in:
parent
50a7f5483b
commit
28b285764c
@ -354,6 +354,7 @@ mod test {
|
||||
use core::option::None;
|
||||
use core::int;
|
||||
use core::num::NumCast;
|
||||
use core::path::Path;
|
||||
use codemap::{dummy_sp, CodeMap, span, BytePos, spanned};
|
||||
use opt_vec;
|
||||
use ast;
|
||||
@ -546,6 +547,10 @@ mod test {
|
||||
|
||||
}
|
||||
|
||||
fn parser_done(p: Parser){
|
||||
assert_eq!(*p.token,token::EOF);
|
||||
}
|
||||
|
||||
#[test] fn parse_ident_pat () {
|
||||
let parser = string_to_parser(@~"b");
|
||||
assert_eq!(parser.parse_pat(false),
|
||||
@ -560,7 +565,7 @@ mod test {
|
||||
None // no idea
|
||||
),
|
||||
span: sp(0,1)});
|
||||
assert_eq!(*parser.token,token::EOF);
|
||||
parser_done(parser);
|
||||
}
|
||||
|
||||
#[test] fn parse_arg () {
|
||||
|
@ -1056,6 +1056,9 @@ pub impl Parser {
|
||||
}
|
||||
}
|
||||
|
||||
// matches lifetimes = ( lifetime ) | ( lifetime , lifetimes )
|
||||
// actually, it matches the empty one too, but putting that in there
|
||||
// messes up the grammar....
|
||||
fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
|
||||
/*!
|
||||
*
|
||||
@ -1081,7 +1084,8 @@ pub impl Parser {
|
||||
token::GT => { return res; }
|
||||
token::BINOP(token::SHR) => { return res; }
|
||||
_ => {
|
||||
self.fatal(~"expected `,` or `>` after lifetime name");
|
||||
self.fatal(fmt!("expected `,` or `>` after lifetime name, got: %?",
|
||||
*self.token));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2741,6 +2745,11 @@ pub impl Parser {
|
||||
if self.eat_keyword(&~"once") { ast::Once } else { ast::Many }
|
||||
}
|
||||
|
||||
// matches optbounds = ( ( : ( boundseq )? )? )
|
||||
// where boundseq = ( bound + boundseq ) | bound
|
||||
// and bound = ( 'static ) | ty
|
||||
// you might want to insist on the boundseq having seen the colon, but
|
||||
// that's not currently in place.
|
||||
fn parse_optional_ty_param_bounds(&self) -> @OptVec<TyParamBound> {
|
||||
if !self.eat(&token::COLON) {
|
||||
return @opt_vec::Empty;
|
||||
@ -2801,6 +2810,7 @@ pub impl Parser {
|
||||
return @result;
|
||||
}
|
||||
|
||||
// matches typaram = IDENT optbounds
|
||||
fn parse_ty_param(&self) -> TyParam {
|
||||
let ident = self.parse_ident();
|
||||
let bounds = self.parse_optional_ty_param_bounds();
|
||||
|
Loading…
x
Reference in New Issue
Block a user