Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: runtime/vm/parser.cc

Issue 11312197: Enforce proper library/import syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 14798)
+++ runtime/vm/parser.cc (working copy)
@@ -4333,6 +4333,9 @@
void Parser::ParseIdentList(GrowableObjectArray* names) {
+ if (!IsIdentifier()) {
+ ErrorMsg("identifier expected");
+ }
while (IsIdentifier()) {
names->Add(*CurrentLiteral());
ConsumeToken(); // Identifier.
@@ -4474,6 +4477,10 @@
return;
}
+ const bool is_script = (script_.kind() == RawScript::kScriptTag);
+ const bool is_library = (script_.kind() == RawScript::kLibraryTag);
+ ASSERT(script_.kind() != RawScript::kSourceTag);
+
// We may read metadata tokens that are part of the toplevel
// declaration that follows the library definitions. Therefore, we
// need to remember the position of the last token that was
@@ -4484,11 +4491,14 @@
ParseLibraryName();
metadata_pos = TokenPos();
SkipMetadata();
- } else if (script_.kind() == RawScript::kLibraryTag) {
+ } else if (is_library) {
ErrorMsg("library name definition expected");
}
while ((CurrentToken() == Token::kIMPORT) ||
(CurrentToken() == Token::kEXPORT)) {
+ if (is_script && (CurrentToken() == Token::kEXPORT)) {
+ ErrorMsg("export not allowed in scripts");
+ }
ParseLibraryImportExport();
metadata_pos = TokenPos();
SkipMetadata();
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698