Index: compiler/java/com/google/dart/compiler/parser/DartParser.java |
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java |
index a79148c2fa09144518d66679bebd9128e61ff3b8..cb52309bd66fd727043491ff837782a8366501b8 100644 |
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java |
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java |
@@ -532,6 +532,7 @@ public class DartParser extends CompletionHooksParserBase { |
private void parseDirectives(DartUnit unit) { |
List<DartAnnotation> metadata = parseMetadata(); |
+ boolean hasLibraryDirective = false; |
if (peekPseudoKeyword(0, LIBRARY_KEYWORD)) { |
DartLibraryDirective libraryDirective = parseLibraryDirective(); |
for (DartDirective directive : unit.getDirectives()) { |
@@ -542,6 +543,7 @@ public class DartParser extends CompletionHooksParserBase { |
} |
setMetadata(libraryDirective, metadata); |
unit.getDirectives().add(libraryDirective); |
+ hasLibraryDirective = true; |
} |
while (peekPseudoKeyword(0, IMPORT_KEYWORD) || peekPseudoKeyword(0, EXPORT_KEYWORD)) { |
if (peekPseudoKeyword(0, IMPORT_KEYWORD)) { |
@@ -552,6 +554,9 @@ public class DartParser extends CompletionHooksParserBase { |
DartExportDirective exportDirective = parseExportDirective(); |
setMetadata(exportDirective, metadata); |
unit.getDirectives().add(exportDirective); |
+ if (!hasLibraryDirective) { |
+ reportError(exportDirective, ParserErrorCode.EXPORT_WITHOUT_LIBRARY_DIRECTIVE); |
+ } |
} |
} |
while (peekPseudoKeyword(0, PART_KEYWORD)) { |