From 4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4 Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Fri, 18 Jul 2014 00:56:56 +0200 Subject: Implement new mod import sugar Implements RFC #168. --- src/libsyntax/parse/parser.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/parse') 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), -- cgit 1.4.1-3-g733a5