diff options
| author | Jakub Wieczorek <jakub@jakub.cc> | 2014-07-18 00:56:56 +0200 |
|---|---|---|
| committer | Jakub Wieczorek <jakub@jakub.cc> | 2014-07-20 12:40:08 +0200 |
| commit | 4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4 (patch) | |
| tree | ada16b620d93f1ae709185df0986c58a62614e8d /src/libsyntax/parse/parser.rs | |
| parent | 50481f55030f02543e1b3b6ae008d77b1cef3e98 (diff) | |
| download | rust-4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4.tar.gz rust-4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4.zip | |
Implement new mod import sugar
Implements RFC #168.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 394288bd9f2..73de47e7b12 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -537,12 +537,16 @@ impl<'a> Parser<'a> { } } - pub fn parse_path_list_ident(&mut self) -> ast::PathListIdent { + pub fn parse_path_list_item(&mut self) -> ast::PathListItem { let lo = self.span.lo; - let ident = self.parse_ident(); + let node = if self.eat_keyword(keywords::Mod) { + ast::PathListMod { id: ast::DUMMY_NODE_ID } + } else { + let ident = self.parse_ident(); + ast::PathListIdent { name: ident, id: ast::DUMMY_NODE_ID } + }; let hi = self.last_span.hi; - spanned(lo, hi, ast::PathListIdent_ { name: ident, - id: ast::DUMMY_NODE_ID }) + spanned(lo, hi, node) } /// Consume token 'tok' if it exists. Returns true if the given @@ -5176,7 +5180,7 @@ impl<'a> Parser<'a> { let idents = self.parse_unspanned_seq( &token::LBRACE, &token::RBRACE, seq_sep_trailing_allowed(token::COMMA), - |p| p.parse_path_list_ident()); + |p| p.parse_path_list_item()); let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, @@ -5232,7 +5236,7 @@ impl<'a> Parser<'a> { &token::LBRACE, &token::RBRACE, seq_sep_trailing_allowed(token::COMMA), - |p| p.parse_path_list_ident() + |p| p.parse_path_list_item() ); let path = ast::Path { span: mk_sp(lo, self.span.hi), |
