| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4212 ConsumeToken(); | 4212 ConsumeToken(); |
| 4213 } | 4213 } |
| 4214 | 4214 |
| 4215 // TODO(hausner): Remove support for old library definition syntax. | 4215 // TODO(hausner): Remove support for old library definition syntax. |
| 4216 if ((CurrentToken() == Token::kLIBRARY) || | 4216 if ((CurrentToken() == Token::kLIBRARY) || |
| 4217 (CurrentToken() == Token::kIMPORT) || | 4217 (CurrentToken() == Token::kIMPORT) || |
| 4218 (CurrentToken() == Token::kSOURCE)) { | 4218 (CurrentToken() == Token::kSOURCE)) { |
| 4219 ParseLibraryNameObsoleteSyntax(); | 4219 ParseLibraryNameObsoleteSyntax(); |
| 4220 ParseLibraryImportObsoleteSyntax(); | 4220 ParseLibraryImportObsoleteSyntax(); |
| 4221 ParseLibraryIncludeObsoleteSyntax(); | 4221 ParseLibraryIncludeObsoleteSyntax(); |
| 4222 // Core lib has not been explicitly imported, so we implicitly |
| 4223 // import it here. |
| 4224 if (!library_.ImportsCorelib()) { |
| 4225 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4226 ASSERT(!core_lib.IsNull()); |
| 4227 library_.AddImport(core_lib); |
| 4228 } |
| 4222 return; | 4229 return; |
| 4223 } | 4230 } |
| 4224 | 4231 |
| 4225 // We may read metadata tokens that are part of the toplevel | 4232 // We may read metadata tokens that are part of the toplevel |
| 4226 // declaration that follows the library definitions. Therefore, we | 4233 // declaration that follows the library definitions. Therefore, we |
| 4227 // need to remember the position of the last token that was | 4234 // need to remember the position of the last token that was |
| 4228 // successfully consumed. | 4235 // successfully consumed. |
| 4229 intptr_t metadata_pos = TokenPos(); | 4236 intptr_t metadata_pos = TokenPos(); |
| 4230 SkipMetadata(); | 4237 SkipMetadata(); |
| 4231 if (IsLiteral("library")) { | 4238 if (IsLiteral("library")) { |
| 4232 ParseLibraryName(); | 4239 ParseLibraryName(); |
| 4233 metadata_pos = TokenPos(); | 4240 metadata_pos = TokenPos(); |
| 4234 SkipMetadata(); | 4241 SkipMetadata(); |
| 4235 } else if (script_.kind() == RawScript::kLibraryTag) { | 4242 } else if (script_.kind() == RawScript::kLibraryTag) { |
| 4236 ErrorMsg("library name definition expected"); | 4243 ErrorMsg("library name definition expected"); |
| 4237 } | 4244 } |
| 4238 while (IsLiteral("import") || IsLiteral("export")) { | 4245 while (IsLiteral("import") || IsLiteral("export")) { |
| 4239 ParseLibraryImportExport(); | 4246 ParseLibraryImportExport(); |
| 4240 metadata_pos = TokenPos(); | 4247 metadata_pos = TokenPos(); |
| 4241 SkipMetadata(); | 4248 SkipMetadata(); |
| 4242 } | 4249 } |
| 4250 // Core lib has not been explicitly imported, so we implicitly |
| 4251 // import it here. |
| 4252 if (!library_.ImportsCorelib()) { |
| 4253 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4254 ASSERT(!core_lib.IsNull()); |
| 4255 library_.AddImport(core_lib); |
| 4256 } |
| 4243 while (IsLiteral("part")) { | 4257 while (IsLiteral("part")) { |
| 4244 ParseLibraryPart(); | 4258 ParseLibraryPart(); |
| 4245 metadata_pos = TokenPos(); | 4259 metadata_pos = TokenPos(); |
| 4246 SkipMetadata(); | 4260 SkipMetadata(); |
| 4247 } | 4261 } |
| 4248 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { | 4262 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { |
| 4249 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); | 4263 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); |
| 4250 } | 4264 } |
| 4251 SetPosition(metadata_pos); | 4265 SetPosition(metadata_pos); |
| 4252 } | 4266 } |
| (...skipping 5262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9515 void Parser::SkipQualIdent() { | 9529 void Parser::SkipQualIdent() { |
| 9516 ASSERT(IsIdentifier()); | 9530 ASSERT(IsIdentifier()); |
| 9517 ConsumeToken(); | 9531 ConsumeToken(); |
| 9518 if (CurrentToken() == Token::kPERIOD) { | 9532 if (CurrentToken() == Token::kPERIOD) { |
| 9519 ConsumeToken(); // Consume the kPERIOD token. | 9533 ConsumeToken(); // Consume the kPERIOD token. |
| 9520 ExpectIdentifier("identifier expected after '.'"); | 9534 ExpectIdentifier("identifier expected after '.'"); |
| 9521 } | 9535 } |
| 9522 } | 9536 } |
| 9523 | 9537 |
| 9524 } // namespace dart | 9538 } // namespace dart |
| OLD | NEW |