OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 4532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4543 if (!library_.ImportsCorelib()) { | 4543 if (!library_.ImportsCorelib()) { |
4544 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4544 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
4545 ASSERT(!core_lib.IsNull()); | 4545 ASSERT(!core_lib.IsNull()); |
4546 const Namespace& core_ns = Namespace::Handle( | 4546 const Namespace& core_ns = Namespace::Handle( |
4547 Namespace::New(core_lib, Array::Handle(), Array::Handle())); | 4547 Namespace::New(core_lib, Array::Handle(), Array::Handle())); |
4548 library_.AddImport(core_ns); | 4548 library_.AddImport(core_ns); |
4549 } | 4549 } |
4550 return; | 4550 return; |
4551 } | 4551 } |
4552 | 4552 |
4553 const bool is_script = (script_.kind() == RawScript::kScriptTag); | |
4554 const bool is_library = (script_.kind() == RawScript::kLibraryTag); | |
4555 const bool is_patch = (script_.kind() == RawScript::kPatchTag); | |
4556 ASSERT(script_.kind() != RawScript::kSourceTag); | 4553 ASSERT(script_.kind() != RawScript::kSourceTag); |
4557 | 4554 |
4558 // We may read metadata tokens that are part of the toplevel | 4555 // We may read metadata tokens that are part of the toplevel |
4559 // declaration that follows the library definitions. Therefore, we | 4556 // declaration that follows the library definitions. Therefore, we |
4560 // need to remember the position of the last token that was | 4557 // need to remember the position of the last token that was |
4561 // successfully consumed. | 4558 // successfully consumed. |
4562 intptr_t metadata_pos = TokenPos(); | 4559 intptr_t metadata_pos = TokenPos(); |
4563 SkipMetadata(); | 4560 SkipMetadata(); |
4564 if (CurrentToken() == Token::kLIBRARY) { | 4561 if (CurrentToken() == Token::kLIBRARY) { |
4565 if (is_patch) { | 4562 if (is_patch_source()) { |
4566 ErrorMsg("patch cannot override library name"); | 4563 ErrorMsg("patch cannot override library name"); |
4567 } | 4564 } |
4568 ParseLibraryName(); | 4565 ParseLibraryName(); |
4569 metadata_pos = TokenPos(); | 4566 metadata_pos = TokenPos(); |
4570 SkipMetadata(); | 4567 SkipMetadata(); |
4571 } else if (is_library) { | |
4572 ErrorMsg("library name definition expected"); | |
4573 } | 4568 } |
4574 while ((CurrentToken() == Token::kIMPORT) || | 4569 while ((CurrentToken() == Token::kIMPORT) || |
4575 (CurrentToken() == Token::kEXPORT)) { | 4570 (CurrentToken() == Token::kEXPORT)) { |
4576 if (is_script && (CurrentToken() == Token::kEXPORT)) { | |
4577 ErrorMsg("export not allowed in scripts"); | |
4578 } | |
4579 ParseLibraryImportExport(); | 4571 ParseLibraryImportExport(); |
4580 metadata_pos = TokenPos(); | 4572 metadata_pos = TokenPos(); |
4581 SkipMetadata(); | 4573 SkipMetadata(); |
4582 } | 4574 } |
4583 // Core lib has not been explicitly imported, so we implicitly | 4575 // Core lib has not been explicitly imported, so we implicitly |
4584 // import it here. | 4576 // import it here. |
4585 if (!library_.ImportsCorelib()) { | 4577 if (!library_.ImportsCorelib()) { |
4586 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4578 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
4587 ASSERT(!core_lib.IsNull()); | 4579 ASSERT(!core_lib.IsNull()); |
4588 const Namespace& core_ns = Namespace::Handle( | 4580 const Namespace& core_ns = Namespace::Handle( |
(...skipping 5483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10072 void Parser::SkipQualIdent() { | 10064 void Parser::SkipQualIdent() { |
10073 ASSERT(IsIdentifier()); | 10065 ASSERT(IsIdentifier()); |
10074 ConsumeToken(); | 10066 ConsumeToken(); |
10075 if (CurrentToken() == Token::kPERIOD) { | 10067 if (CurrentToken() == Token::kPERIOD) { |
10076 ConsumeToken(); // Consume the kPERIOD token. | 10068 ConsumeToken(); // Consume the kPERIOD token. |
10077 ExpectIdentifier("identifier expected after '.'"); | 10069 ExpectIdentifier("identifier expected after '.'"); |
10078 } | 10070 } |
10079 } | 10071 } |
10080 | 10072 |
10081 } // namespace dart | 10073 } // namespace dart |
OLD | NEW |