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

Side by Side Diff: lib/compiler/implementation/scanner/parser.dart

Issue 11071015: Fix error reporting on member declarations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename method and add test. 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
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 /** 5 /**
6 * An event generating parser of Dart programs. This parser expects 6 * An event generating parser of Dart programs. This parser expects
7 * all tokens in a linked list (aka a token stream). 7 * all tokens in a linked list (aka a token stream).
8 * 8 *
9 * The class [Scanner] is used to generate a token stream. See the 9 * The class [Scanner] is used to generate a token stream. See the
10 * file scanner.dart. 10 * file scanner.dart.
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 listener.endTopLevelFields(fieldCount, start, token); 637 listener.endTopLevelFields(fieldCount, start, token);
638 } else { 638 } else {
639 token = parseFormalParametersOpt(token); 639 token = parseFormalParametersOpt(token);
640 token = parseFunctionBody(token, false); 640 token = parseFunctionBody(token, false);
641 listener.endTopLevelMethod(start, getOrSet, token); 641 listener.endTopLevelMethod(start, getOrSet, token);
642 } 642 }
643 return token.next; 643 return token.next;
644 } 644 }
645 645
646 Link<Token> findMemberName(Token token) { 646 Link<Token> findMemberName(Token token) {
647 Token start = token;
647 Link<Token> identifiers = const EmptyLink<Token>(); 648 Link<Token> identifiers = const EmptyLink<Token>();
648 while (token.kind !== EOF_TOKEN) { 649 while (token.kind !== EOF_TOKEN) {
649 String value = token.stringValue; 650 String value = token.stringValue;
650 if ((value === '(') || (value === '{') || (value === '=>')) { 651 if ((value === '(') || (value === '{') || (value === '=>')) {
651 // A method. 652 // A method.
652 return identifiers; 653 return identifiers;
653 } else if ((value === '=') || (value === ';') || (value === ',')) { 654 } else if ((value === '=') || (value === ';') || (value === ',')) {
654 // A field or abstract getter. 655 // A field or abstract getter.
655 return identifiers; 656 return identifiers;
656 } 657 }
657 identifiers = identifiers.prepend(token); 658 identifiers = identifiers.prepend(token);
658 if (isValidTypeReference(token)) { 659 if (isValidTypeReference(token)) {
659 // type ... 660 // type ...
660 if (optional('.', token.next)) { 661 if (optional('.', token.next)) {
661 // type '.' ... 662 // type '.' ...
662 if (token.next.next.isIdentifier()) { 663 if (token.next.next.isIdentifier()) {
663 // type '.' identifier 664 // type '.' identifier
664 token = token.next.next; 665 token = token.next.next;
665 } 666 }
666 } 667 }
667 if (optional('<', token.next)) { 668 if (optional('<', token.next)) {
668 if (token.next is BeginGroupToken) { 669 if (token.next is BeginGroupToken) {
669 BeginGroupToken beginGroup = token.next; 670 BeginGroupToken beginGroup = token.next;
670 token = beginGroup.endGroup; 671 token = beginGroup.endGroup;
671 } 672 }
672 } 673 }
673 } 674 }
674 token = token.next; 675 token = token.next;
675 } 676 }
676 return listener.unexpected(token); 677 return listener.expectedDeclaration(start);
677 } 678 }
678 679
679 Token parseVariableInitializerOpt(Token token) { 680 Token parseVariableInitializerOpt(Token token) {
680 if (optional('=', token)) { 681 if (optional('=', token)) {
681 Token assignment = token; 682 Token assignment = token;
682 listener.beginInitializer(token); 683 listener.beginInitializer(token);
683 token = parseExpression(token.next); 684 token = parseExpression(token.next);
684 listener.endInitializer(assignment); 685 listener.endInitializer(assignment);
685 } 686 }
686 return token; 687 return token;
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 } 2090 }
2090 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2091 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2091 return expectSemicolon(token); 2092 return expectSemicolon(token);
2092 } 2093 }
2093 2094
2094 Token parseEmptyStatement(Token token) { 2095 Token parseEmptyStatement(Token token) {
2095 listener.handleEmptyStatement(token); 2096 listener.handleEmptyStatement(token);
2096 return expectSemicolon(token); 2097 return expectSemicolon(token);
2097 } 2098 }
2098 } 2099 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/listener.dart ('k') | tests/language/illegal_declaration_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698