@@ -2183,29 +2183,58 @@ fn parse_use(&parser p) -> @ast::view_item {
2183
2183
}
2184
2184
2185
2185
fn parse_rest_import_name ( & parser p, ast:: ident first,
2186
- option:: t[ ast:: ident ] def_ident )
2186
+ option:: t[ ast:: ident ] def_ident )
2187
2187
-> @ast:: view_item {
2188
2188
auto lo = p. get_lo_pos ( ) ;
2189
2189
let vec[ ast:: ident] identifiers = [ first] ;
2190
- while ( p. peek ( ) != token:: SEMI ) {
2191
- expect ( p, token:: MOD_SEP ) ;
2192
- auto i = parse_ident ( p) ;
2193
- identifiers += [ i] ;
2190
+ let bool glob = false ;
2191
+
2192
+ while ( true ) {
2193
+ alt ( p. peek ( ) ) {
2194
+ case ( token:: SEMI ) {
2195
+ p. bump ( ) ;
2196
+ break ;
2197
+ }
2198
+ case ( token:: MOD_SEP ) {
2199
+ if ( glob) { p. err ( "cannot path into a glob" ) ; }
2200
+ p. bump ( ) ;
2201
+ }
2202
+ case ( _) { p. err ( "expecting '::' or ';'" ) ; }
2203
+ }
2204
+ alt ( p. peek ( ) ) {
2205
+ case ( token:: IDENT ( _, _) ) {
2206
+ identifiers += [ parse_ident ( p) ] ;
2207
+ }
2208
+ //the lexer can't tell the different kinds of stars apart ) :
2209
+ case ( token:: BINOP ( token:: STAR ) ) {
2210
+ glob = true ;
2211
+ p. bump ( ) ;
2212
+ }
2213
+ case ( _) { p. err ( "expecting an identifier, or '*'" ) ; }
2214
+ }
2194
2215
}
2195
2216
auto hi = p. get_hi_pos ( ) ;
2196
- p. bump ( ) ;
2197
- auto defined_id;
2217
+ auto import_decl;
2198
2218
alt ( def_ident) {
2199
2219
case ( some[ ast:: ident] ( ?i) ) {
2200
- defined_id = i;
2220
+ if ( glob) {
2221
+ p. err ( "globbed imports can't be renamed" ) ;
2222
+ }
2223
+ import_decl = ast:: view_item_import ( i, identifiers,
2224
+ p. next_def_id ( ) ) ;
2201
2225
}
2202
2226
case ( _) {
2203
- auto len = vec:: len[ ast:: ident] ( identifiers) ;
2204
- defined_id = identifiers. ( len - 1 u) ;
2227
+ if ( glob) {
2228
+ import_decl = ast:: view_item_import_glob ( identifiers,
2229
+ p. next_def_id ( ) ) ;
2230
+ } else {
2231
+ auto len = vec:: len[ ast:: ident] ( identifiers) ;
2232
+ import_decl = ast:: view_item_import ( identifiers. ( len - 1 u) ,
2233
+ identifiers,
2234
+ p. next_def_id ( ) ) ;
2235
+ }
2205
2236
}
2206
2237
}
2207
- auto import_decl = ast:: view_item_import ( defined_id, identifiers,
2208
- p. next_def_id ( ) ) ;
2209
2238
ret @spanned ( lo, hi, import_decl) ;
2210
2239
}
2211
2240
0 commit comments