@@ -705,6 +705,7 @@ pub impl Parser {
705705        @Ty  { id :  self . get_id ( ) ,  node :  t,  span :  sp} 
706706    } 
707707
708+     // parse the type following a @ or a ~ 
708709    fn  parse_box_or_uniq_pointee ( 
709710        & self , 
710711        sigil :  ast:: Sigil , 
@@ -988,12 +989,8 @@ pub impl Parser {
988989                     .. copy * path } 
989990    } 
990991
992+     /// parses 0 or 1 lifetime 
991993fn  parse_opt_lifetime ( & self )  -> Option < @ast:: Lifetime >  { 
992-         /*! 
993-          * 
994-          * Parses 0 or 1 lifetime. 
995-          */ 
996- 
997994        match  * self . token  { 
998995            token:: LIFETIME ( * )  => { 
999996                Some ( @self . parse_lifetime ( ) ) 
@@ -1022,12 +1019,9 @@ pub impl Parser {
10221019        } 
10231020    } 
10241021
1022+     /// Parses a single lifetime 
1023+ // matches lifetime = ( LIFETIME ) | ( IDENT / ) 
10251024    fn  parse_lifetime ( & self )  -> ast:: Lifetime  { 
1026-         /*! 
1027-          * 
1028-          * Parses a single lifetime. 
1029-          */ 
1030- 
10311025        match  * self . token  { 
10321026            token:: LIFETIME ( i)  => { 
10331027                let  span = copy self . span ; 
@@ -1147,6 +1141,9 @@ pub impl Parser {
11471141        } 
11481142    } 
11491143
1144+     // at the bottom (top?) of the precedence hierarchy, 
1145+     // parse things like parenthesized exprs, 
1146+     // macros, return, etc. 
11501147    fn  parse_bottom_expr( & self )  -> @expr  { 
11511148        maybe_whole_expr!( self ) ; 
11521149
@@ -1350,6 +1347,7 @@ pub impl Parser {
13501347        return  self . mk_expr ( blk. span . lo ,  blk. span . hi ,  expr_block ( blk) ) ; 
13511348    } 
13521349
1350+     // parse a.b or a(13) or just a 
13531351    fn  parse_dot_or_call_expr ( & self )  -> @expr { 
13541352        let  b = self . parse_bottom_expr ( ) ; 
13551353        self . parse_dot_or_call_expr_with ( b) 
@@ -1618,7 +1616,7 @@ pub impl Parser {
16181616        return  spanned ( lo,  self . span . hi ,  m) ; 
16191617    } 
16201618
1621- 
1619+      // parse a prefix-operator expr 
16221620    fn  parse_prefix_expr ( & self )  -> @expr { 
16231621        let  lo = self . span . lo ; 
16241622        let  mut  hi; 
@@ -2552,11 +2550,14 @@ pub impl Parser {
25522550    } 
25532551
25542552    fn  parse_block ( & self )  -> blk  { 
2553+         // disallow inner attrs: 
25552554        let  ( attrs,  blk)  = self . parse_inner_attrs_and_block ( false ) ; 
25562555        assert ! ( vec:: is_empty( attrs) ) ; 
25572556        return  blk; 
25582557    } 
25592558
2559+     // I claim the existence of the 'parse_attrs' flag strongly 
2560+     // suggests a name-change or refactoring for this function. 
25602561    fn  parse_inner_attrs_and_block( & self ,  parse_attrs :  bool ) 
25612562        -> ( ~[ attribute ] ,  blk )  { 
25622563
@@ -2597,6 +2598,7 @@ pub impl Parser {
25972598        self . parse_block_tail_ ( lo,  s,  ~[ ] ) 
25982599    } 
25992600
2601+     // parse the rest of a block expression or function body 
26002602    fn  parse_block_tail_ ( & self ,  lo :  BytePos ,  s :  blk_check_mode , 
26012603                         +first_item_attrs :  ~[ attribute ] )  -> blk  { 
26022604        let  mut  stmts = ~[ ] ; 
@@ -2793,6 +2795,10 @@ pub impl Parser {
27932795        ast:: TyParam  {  ident :  ident,  id :  self . get_id ( ) ,  bounds :  bounds } 
27942796    } 
27952797
2798+     // parse a set of optional generic type parameter declarations 
2799+     // matches generics = ( ) | ( < > ) | ( < typaramseq ( , )? > ) | ( < lifetimes ( , )? > ) 
2800+     //                  | ( < lifetimes , typaramseq ( , )? > ) 
2801+     // where   typaramseq = ( typaram ) | ( typaram , typaramseq ) 
27962802    fn  parse_generics ( & self )  -> ast:: Generics  { 
27972803        if  self . eat ( & token:: LT )  { 
27982804            let  lifetimes = self . parse_lifetimes ( ) ; 
@@ -2805,6 +2811,7 @@ pub impl Parser {
28052811        } 
28062812    } 
28072813
2814+     // parse a generic use site 
28082815    fn  parse_generic_values ( 
28092816        & self )  -> ( OptVec < ast:: Lifetime > ,  ~[ @Ty ] ) 
28102817    { 
@@ -3095,6 +3102,7 @@ pub impl Parser {
30953102        } 
30963103    } 
30973104
3105+     // parse trait Foo { ... } 
30983106    fn  parse_item_trait ( & self )  -> item_info  { 
30993107        let  ident = self . parse_ident ( ) ; 
31003108        self . parse_region_param ( ) ; 
@@ -3173,13 +3181,15 @@ pub impl Parser {
31733181        ( ident,  item_impl ( generics,  opt_trait,  ty,  meths) ,  None ) 
31743182    } 
31753183
3184+     // parse a::B<~str,int> 
31763185    fn  parse_trait_ref ( & self )  -> @trait_ref  { 
31773186        @ast:: trait_ref  { 
31783187            path :  self . parse_path_with_tps ( false ) , 
31793188            ref_id :  self . get_id ( ) , 
31803189        } 
31813190    } 
31823191
3192+     // parse B + C<~str,int> + D 
31833193    fn  parse_trait_ref_list ( & self ,  ket :  & token:: Token )  -> ~[ @trait_ref ]  { 
31843194        self . parse_seq_to_before_end ( 
31853195            ket, 
@@ -3188,6 +3198,7 @@ pub impl Parser {
31883198        ) 
31893199    } 
31903200
3201+     // parse struct Foo { ... } 
31913202    fn  parse_item_struct ( & self )  -> item_info  { 
31923203        let  class_name = self . parse_ident ( ) ; 
31933204        self . parse_region_param ( ) ; 
@@ -3437,6 +3448,7 @@ pub impl Parser {
34373448        ( id,  item_const ( ty,  e) ,  None ) 
34383449    } 
34393450
3451+     // parse a mod { ...}  item 
34403452    fn  parse_item_mod ( & self ,  outer_attrs :  ~[ ast:: attribute ] )  -> item_info  { 
34413453        let  id_span = * self . span ; 
34423454        let  id = self . parse_ident ( ) ; 
@@ -3693,7 +3705,7 @@ pub impl Parser {
36933705            } 
36943706        } ; 
36953707
3696-         // extern mod { ... } 
3708+         // extern mod foo { ... } or extern  { ... } 
36973709        if  items_allowed && self . eat ( & token:: LBRACE )  { 
36983710            let  abis = opt_abis. get_or_default ( AbiSet :: C ( ) ) ; 
36993711
@@ -3728,6 +3740,7 @@ pub impl Parser {
37283740        ( lo,  id) 
37293741    } 
37303742
3743+     // parse type Foo = Bar; 
37313744    fn parse_item_type ( & self )  -> item_info  { 
37323745        let( _,  ident)  = self . parse_type_decl ( ) ; 
37333746        self . parse_region_param ( ) ; 
@@ -3738,6 +3751,7 @@ pub impl Parser {
37383751        ( ident,  item_ty ( ty,  tps) ,  None ) 
37393752    } 
37403753
3754+     // parse obsolete region parameter 
37413755    fn  parse_region_param( & self )  { 
37423756        if  self . eat ( & token:: BINOP ( token:: SLASH ) )  { 
37433757            self . obsolete ( * self . last_span ,  ObsoleteLifetimeNotation ) ; 
@@ -3855,6 +3869,7 @@ pub impl Parser {
38553869        let  generics = self . parse_generics ( ) ; 
38563870        // Newtype syntax 
38573871        if  * self . token  == token:: EQ  { 
3872+             // enum x = ty; 
38583873            self . bump ( ) ; 
38593874            let  ty = self . parse_ty ( false ) ; 
38603875            self . expect ( & token:: SEMI ) ; 
@@ -3879,6 +3894,7 @@ pub impl Parser {
38793894                None 
38803895            ) ; 
38813896        } 
3897+         // enum X { ... } 
38823898        self . expect ( & token:: LBRACE ) ; 
38833899
38843900        let  enum_definition = self . parse_enum_def ( & generics) ; 
@@ -3982,7 +3998,7 @@ pub impl Parser {
39823998                ( self . is_keyword ( & ~"const ")  ||
39833999                ( self . is_keyword ( & ~"static ")  &&
39844000                    !self . token_is_keyword ( & ~"fn ",  & self . look_ahead ( 1 ) ) ) )  { 
3985-             // CONST ITEM 
4001+             // CONST / STATIC  ITEM 
39864002            if  self . is_keyword ( & ~"const ")  { 
39874003                self . obsolete ( * self . span ,  ObsoleteConstItem ) ; 
39884004            } 
@@ -3998,10 +4014,9 @@ pub impl Parser {
39984014            let  item = self . parse_item_foreign_const ( visibility,  attrs) ; 
39994015            return  iovi_foreign_item ( item) ; 
40004016        } 
4001-         if  items_allowed &&
4002-             // FUNCTION ITEM (not sure about lookahead condition...) 
4003-             self . is_keyword ( & ~"fn ")  &&
4017+         if  items_allowed && self . is_keyword ( & ~"fn ")  &&
40044018            !self . fn_expr_lookahead ( self . look_ahead ( 1 u) )  { 
4019+             // FUNCTION ITEM 
40054020            self . bump ( ) ; 
40064021            let  ( ident,  item_,  extra_attrs)  =
40074022                self . parse_item_fn ( impure_fn,  AbiSet :: Rust ( ) ) ; 
@@ -4010,7 +4025,7 @@ pub impl Parser {
40104025                                          maybe_append ( attrs,  extra_attrs) ) ) ; 
40114026        } 
40124027        if  items_allowed && self . eat_keyword ( & ~"pure")  { 
4013-             // PURE FUNCTION ITEM 
4028+             // PURE FUNCTION ITEM (obsolete)  
40144029            self . obsolete ( * self . last_span ,  ObsoletePurity ) ; 
40154030            self . expect_keyword ( & ~"fn ") ; 
40164031            let  ( ident,  item_,  extra_attrs)  =
@@ -4188,6 +4203,12 @@ pub impl Parser {
41884203        return  view_item_use ( self . parse_view_paths ( ) ) ; 
41894204    } 
41904205
4206+ 
4207+     // matches view_path : MOD? IDENT EQ non_global_path 
4208+     // | MOD? non_global_path MOD_SEP LBRACE RBRACE 
4209+     // | MOD? non_global_path MOD_SEP LBRACE ident_seq RBRACE 
4210+     // | MOD? non_global_path MOD_SEP STAR 
4211+     // | MOD? non_global_path 
41914212    fn  parse_view_path ( & self )  -> @view_path  { 
41924213        let  lo = self . span . lo ; 
41934214
@@ -4277,6 +4298,7 @@ pub impl Parser {
42774298                     view_path_simple ( last,  path,  namespace,  self . get_id ( ) ) ) ; 
42784299    } 
42794300
4301+     // matches view_paths = view_path | view_path , view_paths 
42804302    fn  parse_view_paths ( & self )  -> ~[ @view_path ]  { 
42814303        let  mut  vp = ~[ self . parse_view_path ( ) ] ; 
42824304        while  * self . token  == token:: COMMA  { 
@@ -4326,6 +4348,9 @@ pub impl Parser {
43264348
43274349    // Parses a sequence of items. Stops when it finds program 
43284350    // text that can't be parsed as an item 
4351+     // - mod_items uses VIEW_ITEMS_AND_ITEMS_ALLOWED 
4352+     // - block_tail_ uses IMPORTS_AND_ITEMS_ALLOWED 
4353+     // - foreign_mod_items uses FOREIGN_ITEMS_ALLOWED 
43294354    fn  parse_items_and_view_items ( & self ,  +first_item_attrs:  ~[ attribute] , 
43304355                                  mode:  view_item_parse_mode, 
43314356                                  macros_allowed:  bool ) 
0 commit comments