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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1062343002: improve parser recovery for import directives (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser; 8 library engine.parser;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 5934 matching lines...) Expand 10 before | Expand all | Expand 10 after
5945 } 5945 }
5946 return new IfStatement(ifKeyword, leftParenthesis, condition, 5946 return new IfStatement(ifKeyword, leftParenthesis, condition,
5947 rightParenthesis, thenStatement, elseKeyword, elseStatement); 5947 rightParenthesis, thenStatement, elseKeyword, elseStatement);
5948 } 5948 }
5949 5949
5950 /** 5950 /**
5951 * Parse an import directive. The [commentAndMetadata] is the metadata to be 5951 * Parse an import directive. The [commentAndMetadata] is the metadata to be
5952 * associated with the directive. Return the import directive that was parsed. 5952 * associated with the directive. Return the import directive that was parsed.
5953 * 5953 *
5954 * importDirective ::= 5954 * importDirective ::=
5955 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' 5955 * metadata 'import' stringLiteral (deferred)? ('as' identifier)? comb inator*';'
5956 */ 5956 */
5957 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) { 5957 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) {
5958 Token importKeyword = _expectKeyword(Keyword.IMPORT); 5958 Token importKeyword = _expectKeyword(Keyword.IMPORT);
5959 StringLiteral libraryUri = _parseUri(); 5959 StringLiteral libraryUri = _parseUri();
5960 Token deferredToken = null; 5960 Token deferredToken = null;
5961 Token asToken = null; 5961 Token asToken = null;
5962 SimpleIdentifier prefix = null; 5962 SimpleIdentifier prefix = null;
5963 if (_matchesKeyword(Keyword.DEFERRED)) { 5963 if (_matchesKeyword(Keyword.DEFERRED)) {
5964 deferredToken = getAndAdvance(); 5964 deferredToken = getAndAdvance();
5965 } 5965 }
5966 if (_matchesKeyword(Keyword.AS)) { 5966 if (_matchesKeyword(Keyword.AS)) {
5967 asToken = getAndAdvance(); 5967 asToken = getAndAdvance();
5968 prefix = parseSimpleIdentifier(); 5968 prefix = parseSimpleIdentifier();
5969 } else if (deferredToken != null) { 5969 } else if (deferredToken != null) {
5970 _reportErrorForCurrentToken( 5970 _reportErrorForCurrentToken(
5971 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT); 5971 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT);
5972 } else if (!_matches(TokenType.SEMICOLON) &&
5973 _tokenMatchesKeyword(_peek(), Keyword.AS)) {
Brian Wilkerson 2015/04/07 23:09:14 We might want to allow either 'as', 'show' or 'hid
danrubel 2015/04/08 14:51:25 Good suggestion. https://codereview.chromium.org/1
5974 _reportErrorForCurrentToken(
5975 ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken]);
5976 _advance();
5977 asToken = getAndAdvance();
5978 prefix = parseSimpleIdentifier();
5972 } 5979 }
5973 List<Combinator> combinators = _parseCombinators(); 5980 List<Combinator> combinators = _parseCombinators();
5974 Token semicolon = _expectSemicolon(); 5981 Token semicolon = _expectSemicolon();
5975 return new ImportDirective(commentAndMetadata.comment, 5982 return new ImportDirective(commentAndMetadata.comment,
5976 commentAndMetadata.metadata, importKeyword, libraryUri, deferredToken, 5983 commentAndMetadata.metadata, importKeyword, libraryUri, deferredToken,
5977 asToken, prefix, combinators, semicolon); 5984 asToken, prefix, combinators, semicolon);
5978 } 5985 }
5979 5986
5980 /** 5987 /**
5981 * Parse a list of initialized identifiers. The [commentAndMetadata] is the 5988 * Parse a list of initialized identifiers. The [commentAndMetadata] is the
(...skipping 4581 matching lines...) Expand 10 before | Expand all | Expand 10 after
10563 } 10570 }
10564 10571
10565 /** 10572 /**
10566 * Copy resolution data from the [fromNode] to the [toNode]. 10573 * Copy resolution data from the [fromNode] to the [toNode].
10567 */ 10574 */
10568 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 10575 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
10569 ResolutionCopier copier = new ResolutionCopier(); 10576 ResolutionCopier copier = new ResolutionCopier();
10570 copier._isEqualNodes(fromNode, toNode); 10577 copier._isEqualNodes(fromNode, toNode);
10571 } 10578 }
10572 } 10579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698