diff options
| author | John Clements <clements@racket-lang.org> | 2013-04-23 16:47:47 -0700 |
|---|---|---|
| committer | John Clements <clements@racket-lang.org> | 2013-04-28 09:49:20 -0700 |
| commit | 28b285764cd6d9b184584756177199d0f1c32ce3 (patch) | |
| tree | 148a73d40d20814a333da557ba60cac3dae5bcf0 /src/libsyntax/parse | |
| parent | 50a7f5483b4f474d7469ea7709aed8e370eab5ba (diff) | |
| download | rust-28b285764cd6d9b184584756177199d0f1c32ce3.tar.gz rust-28b285764cd6d9b184584756177199d0f1c32ce3.zip | |
comments, helper function for tests, more informative error message
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 0063c7ea876..9381358e161 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -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 () { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0afef442efc..c843698a1dc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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(); |
