about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-08-14 11:23:25 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-08-14 11:23:25 -0700
commit30e243a5aa876153081d5451e14286b00ad2c8b1 (patch)
tree3d9c74de7185ad3fa8d04da28fb6f8069a4321fd /src/libsyntax/parse
parent81e6bb1b4bd5c3ad93da6151b52fa0dbf7c5c98a (diff)
downloadrust-30e243a5aa876153081d5451e14286b00ad2c8b1.tar.gz
rust-30e243a5aa876153081d5451e14286b00ad2c8b1.zip
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;"
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs24
1 files changed, 24 insertions, 0 deletions
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)) {