@@ -31,25 +31,25 @@ import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
31
31
expr_rec, expr_ret, expr_swap, expr_struct, expr_tup, expr_unary,
32
32
expr_unary_move, expr_vec, expr_vstore, expr_while, extern_fn,
33
33
field, fn_decl, foreign_item, foreign_item_fn, foreign_mod,
34
- ident, impure_fn, infer, init_assign , init_move , initializer ,
35
- instance_var, item, item_, item_class, item_const, item_enum ,
36
- item_fn, item_foreign_mod, item_impl, item_mac, item_mod ,
37
- item_trait, item_ty, lit, lit_, lit_bool, lit_float, lit_int ,
38
- lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const ,
39
- m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis,
40
- mac_invoc , mac_invoc_tt, mac_var, matcher, match_nonterminal,
41
- match_seq , match_tok, method, mode, mt, mul, mutability, neg,
42
- noreturn , not , pat, pat_box, pat_enum, pat_ident, pat_lit,
43
- pat_range , pat_rec , pat_tup, pat_uniq, pat_wild, path, private,
44
- proto , proto_any , proto_bare, proto_block, proto_box, proto_uniq,
45
- provided , public , pure_fn, purity, re_anon, re_named, region,
46
- rem , required , ret_style, return_val, self_ty, shl, shr, stmt,
47
- stmt_decl , stmt_expr, stmt_semi, subtract, sty_box, sty_by_ref,
48
- sty_region , sty_uniq, sty_value, token_tree, trait_method,
49
- trait_ref , tt_delim, tt_seq, tt_tok, tt_nonterminal, ty, ty_,
50
- ty_bot , ty_box, ty_field, ty_fn, ty_infer, ty_mac, ty_method,
51
- ty_nil , ty_param, ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup,
52
- ty_u32 , ty_uniq, ty_vec, ty_fixed_length, unchecked_blk, uniq,
34
+ ident, impure_fn, infer, inherited , init_assign , init_move ,
35
+ initializer , instance_var, item, item_, item_class, item_const,
36
+ item_enum , item_fn, item_foreign_mod, item_impl, item_mac,
37
+ item_mod , item_trait, item_ty, lit, lit_, lit_bool, lit_float,
38
+ lit_int , lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local,
39
+ m_const , m_imm, m_mutbl, mac_, mac_aq, mac_ellipsis, mac_invoc ,
40
+ mac_invoc_tt, mac_var, matcher, match_nonterminal, match_seq ,
41
+ match_tok, method, mode, mt, mul, mutability, neg, noreturn , not ,
42
+ pat, pat_box, pat_enum, pat_ident, pat_lit, pat_range , pat_rec ,
43
+ pat_tup, pat_uniq, pat_wild, path, private, proto , proto_any ,
44
+ proto_bare, proto_block, proto_box, proto_uniq, provided , public ,
45
+ pure_fn, purity, re_anon, re_named, region, rem , required ,
46
+ ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl ,
47
+ stmt_expr, stmt_semi, subtract, sty_box, sty_by_ref, sty_region ,
48
+ sty_uniq, sty_value, token_tree, trait_method, trait_ref ,
49
+ tt_delim, tt_seq, tt_tok, tt_nonterminal, ty, ty_, ty_bot ,
50
+ ty_box, ty_field, ty_fn, ty_infer, ty_mac, ty_method, ty_nil ,
51
+ ty_param, ty_path, ty_ptr, ty_rec, ty_rptr, ty_tup, ty_u32 ,
52
+ ty_uniq, ty_vec, ty_fixed_length, unchecked_blk, uniq,
53
53
unsafe_blk, unsafe_fn, variant, view_item, view_item_,
54
54
view_item_export, view_item_import, view_item_use, view_path,
55
55
view_path_glob, view_path_list, view_path_simple, visibility,
@@ -273,7 +273,7 @@ class parser {
273
273
let pur = p. parse_fn_purity ( ) ;
274
274
// NB: at the moment, trait methods are public by default; this
275
275
// could change.
276
- let vis = p. parse_visibility ( public ) ;
276
+ let vis = p. parse_visibility ( ) ;
277
277
let ident = p. parse_method_name ( ) ;
278
278
let tps = p. parse_ty_params ( ) ;
279
279
let d = p. parse_ty_fn_decl ( pur) ;
@@ -1873,7 +1873,7 @@ class parser {
1873
1873
1874
1874
let item_attrs = vec:: append ( first_item_attrs, item_attrs) ;
1875
1875
1876
- alt self. parse_item ( item_attrs, public ) {
1876
+ alt self. parse_item ( item_attrs) {
1877
1877
some ( i) {
1878
1878
let mut hi = i. span . hi ;
1879
1879
let decl = @spanned ( lo, hi, decl_item ( i) ) ;
@@ -2459,8 +2459,7 @@ class parser {
2459
2459
}
2460
2460
}
2461
2461
2462
- fn parse_single_class_item(vis: visibility)
2463
- -> @class_member {
2462
+ fn parse_single_class_item(vis: visibility) -> @class_member {
2464
2463
if (self.eat_keyword(~" let") ||
2465
2464
self . token_is_keyword( ~"mut ", copy self . token) ||
2466
2465
!self . is_any_keyword( copy self . token) ) &&
@@ -2491,17 +2490,27 @@ class parser {
2491
2490
dtor_decl( body, attrs, mk_sp( lo, self . last_span. hi) )
2492
2491
}
2493
2492
2494
- fn parse_class_item( class_name_with_tps: @path)
2495
- -> class_contents {
2496
-
2493
+ fn parse_class_item( class_name_with_tps: @path) -> class_contents {
2497
2494
if self . eat_keyword( ~"priv") {
2498
- self . expect( token:: LBRACE ) ;
2499
- let mut results = ~[ ] ;
2500
- while self . token != token:: RBRACE {
2501
- vec:: push( results, self . parse_single_class_item( private) ) ;
2495
+ // XXX: Remove after snapshot.
2496
+ match self . token {
2497
+ token:: LBRACE => {
2498
+ self . bump( ) ;
2499
+ let mut results = ~[ ] ;
2500
+ while self . token != token:: RBRACE {
2501
+ vec:: push( results,
2502
+ self . parse_single_class_item( private) ) ;
2503
+ }
2504
+ self . bump( ) ;
2505
+ return members( results) ;
2506
+ }
2507
+ _ =>
2508
+ return members( ~[ self . parse_single_class_item( private) ] )
2502
2509
}
2503
- self . bump( ) ;
2504
- return members( results) ;
2510
+ }
2511
+
2512
+ if self . eat_keyword( ~"pub ") {
2513
+ return members( ~[ self . parse_single_class_item( public) ] ) ;
2505
2514
}
2506
2515
2507
2516
let attrs = self . parse_outer_attributes( ) ;
@@ -2515,14 +2524,14 @@ class parser {
2515
2524
return self . parse_dtor( attrs) ;
2516
2525
}
2517
2526
else {
2518
- return members( ~[ self . parse_single_class_item( public ) ] ) ;
2527
+ return members( ~[ self . parse_single_class_item( inherited ) ] ) ;
2519
2528
}
2520
2529
}
2521
2530
2522
- fn parse_visibility( def : visibility ) -> visibility {
2531
+ fn parse_visibility( ) -> visibility {
2523
2532
if self . eat_keyword( ~"pub ") { public }
2524
2533
else if self . eat_keyword( ~"priv") { private }
2525
- else { def }
2534
+ else { inherited }
2526
2535
}
2527
2536
2528
2537
fn parse_mod_items( term: token:: token,
@@ -2539,8 +2548,7 @@ class parser {
2539
2548
first = false;
2540
2549
}
2541
2550
debug!{ "parse_mod_items: parse_item( attrs=%?) ", attrs} ;
2542
- let vis = self . parse_visibility( private) ;
2543
- alt self . parse_item( attrs, vis) {
2551
+ alt self . parse_item( attrs) {
2544
2552
some( i) { vec:: push( items, i) ; }
2545
2553
_ {
2546
2554
self . fatal( ~"expected item but found `" +
@@ -2661,7 +2669,7 @@ class parser {
2661
2669
}
2662
2670
}
2663
2671
2664
- fn parse_item_enum ( default_vis : visibility ) -> item_info {
2672
+ fn parse_item_enum ( ) -> item_info {
2665
2673
let id = self . parse_ident ( ) ;
2666
2674
self . parse_region_param ( ) ;
2667
2675
let ty_params = self . parse_ty_params ( ) ;
@@ -2689,7 +2697,7 @@ class parser {
2689
2697
while self . token != token:: RBRACE {
2690
2698
let variant_attrs = self . parse_outer_attributes ( ) ;
2691
2699
let vlo = self . span . lo ;
2692
- let vis = self . parse_visibility ( default_vis ) ;
2700
+ let vis = self . parse_visibility ( ) ;
2693
2701
let ident = self . parse_value_ident ( ) ;
2694
2702
let mut args = ~[ ] , disr_expr = none;
2695
2703
if self . token == token:: LPAREN {
@@ -2752,11 +2760,19 @@ class parser {
2752
2760
}
2753
2761
}
2754
2762
2755
- fn parse_item( +attrs : ~[ attribute ] , vis : visibility )
2756
- -> option<@item> {
2757
-
2763
+ fn parse_item( +attrs : ~[ attribute ] ) -> option<@item> {
2758
2764
maybe_whole ! { some self , nt_item} ;
2759
2765
let lo = self . span . lo ;
2766
+
2767
+ let visibility;
2768
+ if self . eat_keyword ( ~"pub ") {
2769
+ visibility = public;
2770
+ } else if self . eat_keyword ( ~"priv") {
2771
+ visibility = private;
2772
+ } else {
2773
+ visibility = inherited;
2774
+ }
2775
+
2760
2776
let ( ident, item_, extra_attrs) = if self . eat_keyword ( ~"const ") {
2761
2777
self . parse_item_const ( )
2762
2778
} else if self . is_keyword ( ~"fn ") &&
@@ -2782,7 +2798,7 @@ class parser {
2782
2798
} else if self . eat_keyword ( ~"type ") {
2783
2799
self . parse_item_type ( )
2784
2800
} else if self . eat_keyword ( ~"enum ") {
2785
- self . parse_item_enum ( vis )
2801
+ self . parse_item_enum ( )
2786
2802
} else if self . eat_keyword ( ~"iface") {
2787
2803
self . warn ( ~"`iface` is deprecated; use `trait `") ;
2788
2804
self . parse_item_trait ( )
@@ -2816,7 +2832,7 @@ class parser {
2816
2832
expn_info : none} } ;
2817
2833
( id, item_mac ( m) , none)
2818
2834
} else { return none; } ;
2819
- some( self . mk_item( lo, self . last_span. hi , ident , item_ , vis ,
2835
+ some( self . mk_item( lo, self . last_span. hi , ident , item_ , visibility ,
2820
2836
alt extra_attrs {
2821
2837
some ( as) { vec:: append ( attrs, as) }
2822
2838
none { attrs }
@@ -2917,7 +2933,7 @@ class parser {
2917
2933
}
2918
2934
2919
2935
fn parse_view_item ( +attrs : ~[ attribute ] ) -> @view_item {
2920
- let lo = self . span . lo , vis = self . parse_visibility ( private ) ;
2936
+ let lo = self . span . lo , vis = self . parse_visibility ( ) ;
2921
2937
let node = if self . eat_keyword ( ~"use ") {
2922
2938
self . parse_use ( )
2923
2939
} else if self . eat_keyword ( ~"import") {
0 commit comments