Skip to content

Commit 28b2857

Browse files
committed
comments, helper function for tests, more informative error message
1 parent 50a7f54 commit 28b2857

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/libsyntax/parse/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ mod test {
354354
use core::option::None;
355355
use core::int;
356356
use core::num::NumCast;
357+
use core::path::Path;
357358
use codemap::{dummy_sp, CodeMap, span, BytePos, spanned};
358359
use opt_vec;
359360
use ast;
@@ -546,6 +547,10 @@ mod test {
546547
547548
}
548549
550+
fn parser_done(p: Parser){
551+
assert_eq!(*p.token,token::EOF);
552+
}
553+
549554
#[test] fn parse_ident_pat () {
550555
let parser = string_to_parser(@~"b");
551556
assert_eq!(parser.parse_pat(false),
@@ -560,7 +565,7 @@ mod test {
560565
None // no idea
561566
),
562567
span: sp(0,1)});
563-
assert_eq!(*parser.token,token::EOF);
568+
parser_done(parser);
564569
}
565570
566571
#[test] fn parse_arg () {

src/libsyntax/parse/parser.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,9 @@ pub impl Parser {
10561056
}
10571057
}
10581058

1059+
// matches lifetimes = ( lifetime ) | ( lifetime , lifetimes )
1060+
// actually, it matches the empty one too, but putting that in there
1061+
// messes up the grammar....
10591062
fn parse_lifetimes(&self) -> OptVec<ast::Lifetime> {
10601063
/*!
10611064
*
@@ -1081,7 +1084,8 @@ pub impl Parser {
10811084
token::GT => { return res; }
10821085
token::BINOP(token::SHR) => { return res; }
10831086
_ => {
1084-
self.fatal(~"expected `,` or `>` after lifetime name");
1087+
self.fatal(fmt!("expected `,` or `>` after lifetime name, got: %?",
1088+
*self.token));
10851089
}
10861090
}
10871091
}
@@ -2741,6 +2745,11 @@ pub impl Parser {
27412745
if self.eat_keyword(&~"once") { ast::Once } else { ast::Many }
27422746
}
27432747

2748+
// matches optbounds = ( ( : ( boundseq )? )? )
2749+
// where boundseq = ( bound + boundseq ) | bound
2750+
// and bound = ( 'static ) | ty
2751+
// you might want to insist on the boundseq having seen the colon, but
2752+
// that's not currently in place.
27442753
fn parse_optional_ty_param_bounds(&self) -> @OptVec<TyParamBound> {
27452754
if !self.eat(&token::COLON) {
27462755
return @opt_vec::Empty;
@@ -2801,6 +2810,7 @@ pub impl Parser {
28012810
return @result;
28022811
}
28032812

2813+
// matches typaram = IDENT optbounds
28042814
fn parse_ty_param(&self) -> TyParam {
28052815
let ident = self.parse_ident();
28062816
let bounds = self.parse_optional_ty_param_bounds();

0 commit comments

Comments
 (0)