From 30e243a5aa876153081d5451e14286b00ad2c8b1 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 14 Aug 2012 11:23:25 -0700 Subject: libsyntax: Give a nice error message when view items are used anywhere other than the top of a module. This is a step on the way to parsing "extern mod foo;" --- src/libsyntax/parse/parser.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2a23ace632c..ae899a91bfa 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3119,6 +3119,30 @@ class parser { return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs))); + } else if self.eat_keyword(~"use") { + let view_item = self.parse_use(); + return iovi_view_item(@{ + node: view_item, + attrs: attrs, + vis: visibility, + span: mk_sp(lo, self.last_span.hi) + }); + } else if self.eat_keyword(~"import") { + let view_paths = self.parse_view_paths(); + return iovi_view_item(@{ + node: view_item_import(view_paths), + attrs: attrs, + vis: visibility, + span: mk_sp(lo, self.last_span.hi) + }); + } else if self.eat_keyword(~"export") { + let view_paths = self.parse_view_paths(); + return iovi_view_item(@{ + node: view_item_export(view_paths), + attrs: attrs, + vis: visibility, + span: mk_sp(lo, self.last_span.hi) + }); } else if !self.is_any_keyword(copy self.token) && self.look_ahead(1) == token::NOT && is_plain_ident(self.look_ahead(2)) { -- cgit 1.4.1-3-g733a5