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

Side by Side Diff: runtime/vm/parser.cc

Issue 10989010: Implement part header (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4335 matching lines...) Expand 10 before | Expand all | Expand 10 after
4346 metadata_pos = TokenPos(); 4346 metadata_pos = TokenPos();
4347 SkipMetadata(); 4347 SkipMetadata();
4348 } 4348 }
4349 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { 4349 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) {
4350 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); 4350 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString());
4351 } 4351 }
4352 SetPosition(metadata_pos); 4352 SetPosition(metadata_pos);
4353 } 4353 }
4354 4354
4355 4355
4356 void Parser::ParsePartHeader() {
4357 intptr_t metadata_pos = TokenPos();
4358 SkipMetadata();
4359 // TODO(hausner): Once support for old #source directive is removed
4360 // from the compiler, add an error message here if we don't find
4361 // a 'part of' directive.
4362 if (IsLiteral("part")) {
4363 ConsumeToken();
4364 if (!IsLiteral("of")) {
4365 ErrorMsg("'part of' expected");
4366 }
4367 ConsumeToken();
4368 // TODO(hausner): Exact syntax of library name still unclear: identifier,
4369 // qualified identifier or even multiple dots allowed? For now we just
4370 // accept simple identifiers.
4371 // The VM is not required to check that the library name matches the
4372 // name of the current library, so we ignore it.
4373 ExpectIdentifier("library name expected");
4374 ExpectSemicolon();
4375 } else {
4376 SetPosition(metadata_pos);
4377 }
4378 }
4379
4380
4356 void Parser::ParseTopLevel() { 4381 void Parser::ParseTopLevel() {
4357 TRACE_PARSER("ParseTopLevel"); 4382 TRACE_PARSER("ParseTopLevel");
4358 // Collect the classes found at the top level in this growable array. 4383 // Collect the classes found at the top level in this growable array.
4359 // They need to be registered with class finalization after parsing 4384 // They need to be registered with class finalization after parsing
4360 // has been completed. 4385 // has been completed.
4361 Isolate* isolate = Isolate::Current(); 4386 Isolate* isolate = Isolate::Current();
4362 ObjectStore* object_store = isolate->object_store(); 4387 ObjectStore* object_store = isolate->object_store();
4363 const GrowableObjectArray& pending_classes = 4388 const GrowableObjectArray& pending_classes =
4364 GrowableObjectArray::Handle(isolate, object_store->pending_classes()); 4389 GrowableObjectArray::Handle(isolate, object_store->pending_classes());
4365 SetPosition(0); 4390 SetPosition(0);
4366 is_top_level_ = true; 4391 is_top_level_ = true;
4367 TopLevel top_level; 4392 TopLevel top_level;
4368 Class& toplevel_class = Class::Handle( 4393 Class& toplevel_class = Class::Handle(
4369 Class::New(String::Handle(Symbols::TopLevel()), script_, TokenPos())); 4394 Class::New(String::Handle(Symbols::TopLevel()), script_, TokenPos()));
4370 toplevel_class.set_library(library_); 4395 toplevel_class.set_library(library_);
4371 4396
4372 if (is_library_source()) { 4397 if (is_library_source()) {
4373 ParseLibraryDefinition(); 4398 ParseLibraryDefinition();
4399 } else if (is_part_source()) {
4400 ParsePartHeader();
4374 } 4401 }
4375 4402
4376 while (true) { 4403 while (true) {
4377 set_current_class(Class::Handle()); // No current class. 4404 set_current_class(Class::Handle()); // No current class.
4378 SkipMetadata(); 4405 SkipMetadata();
4379 if (CurrentToken() == Token::kCLASS) { 4406 if (CurrentToken() == Token::kCLASS) {
4380 ParseClassDefinition(pending_classes); 4407 ParseClassDefinition(pending_classes);
4381 } else if ((CurrentToken() == Token::kTYPEDEF) && 4408 } else if ((CurrentToken() == Token::kTYPEDEF) &&
4382 (LookaheadToken(1) != Token::kLPAREN)) { 4409 (LookaheadToken(1) != Token::kLPAREN)) {
4383 ParseFunctionTypeAlias(pending_classes); 4410 ParseFunctionTypeAlias(pending_classes);
(...skipping 5287 matching lines...) Expand 10 before | Expand all | Expand 10 after
9671 void Parser::SkipQualIdent() { 9698 void Parser::SkipQualIdent() {
9672 ASSERT(IsIdentifier()); 9699 ASSERT(IsIdentifier());
9673 ConsumeToken(); 9700 ConsumeToken();
9674 if (CurrentToken() == Token::kPERIOD) { 9701 if (CurrentToken() == Token::kPERIOD) {
9675 ConsumeToken(); // Consume the kPERIOD token. 9702 ConsumeToken(); // Consume the kPERIOD token.
9676 ExpectIdentifier("identifier expected after '.'"); 9703 ExpectIdentifier("identifier expected after '.'");
9677 } 9704 }
9678 } 9705 }
9679 9706
9680 } // namespace dart 9707 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698