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

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

Issue 749283007: Fix for issue 18598 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('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) 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 6188 matching lines...) Expand 10 before | Expand all | Expand 10 after
6199 * <pre> 6199 * <pre>
6200 * exportDirective ::= 6200 * exportDirective ::=
6201 * metadata 'export' stringLiteral combinator*';' 6201 * metadata 'export' stringLiteral combinator*';'
6202 * </pre> 6202 * </pre>
6203 * 6203 *
6204 * @param commentAndMetadata the metadata to be associated with the directive 6204 * @param commentAndMetadata the metadata to be associated with the directive
6205 * @return the export directive that was parsed 6205 * @return the export directive that was parsed
6206 */ 6206 */
6207 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) { 6207 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) {
6208 Token exportKeyword = _expectKeyword(Keyword.EXPORT); 6208 Token exportKeyword = _expectKeyword(Keyword.EXPORT);
6209 StringLiteral libraryUri = parseStringLiteral(); 6209 StringLiteral libraryUri = _parseUri();
6210 List<Combinator> combinators = _parseCombinators(); 6210 List<Combinator> combinators = _parseCombinators();
6211 Token semicolon = _expectSemicolon(); 6211 Token semicolon = _expectSemicolon();
6212 return new ExportDirective( 6212 return new ExportDirective(
6213 commentAndMetadata.comment, 6213 commentAndMetadata.comment,
6214 commentAndMetadata.metadata, 6214 commentAndMetadata.metadata,
6215 exportKeyword, 6215 exportKeyword,
6216 libraryUri, 6216 libraryUri,
6217 combinators, 6217 combinators,
6218 semicolon); 6218 semicolon);
6219 } 6219 }
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
6896 * <pre> 6896 * <pre>
6897 * importDirective ::= 6897 * importDirective ::=
6898 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' 6898 * metadata 'import' stringLiteral ('as' identifier)? combinator*';'
6899 * </pre> 6899 * </pre>
6900 * 6900 *
6901 * @param commentAndMetadata the metadata to be associated with the directive 6901 * @param commentAndMetadata the metadata to be associated with the directive
6902 * @return the import directive that was parsed 6902 * @return the import directive that was parsed
6903 */ 6903 */
6904 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) { 6904 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) {
6905 Token importKeyword = _expectKeyword(Keyword.IMPORT); 6905 Token importKeyword = _expectKeyword(Keyword.IMPORT);
6906 StringLiteral libraryUri = parseStringLiteral(); 6906 StringLiteral libraryUri = _parseUri();
6907 Token deferredToken = null; 6907 Token deferredToken = null;
6908 Token asToken = null; 6908 Token asToken = null;
6909 SimpleIdentifier prefix = null; 6909 SimpleIdentifier prefix = null;
6910 if (_matchesKeyword(Keyword.DEFERRED)) { 6910 if (_matchesKeyword(Keyword.DEFERRED)) {
6911 if (_parseDeferredLibraries) { 6911 if (_parseDeferredLibraries) {
6912 deferredToken = andAdvance; 6912 deferredToken = andAdvance;
6913 } else { 6913 } else {
6914 _reportErrorForCurrentToken( 6914 _reportErrorForCurrentToken(
6915 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED); 6915 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED);
6916 _advance(); 6916 _advance();
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
7757 ofKeyword); 7757 ofKeyword);
7758 Token semicolon = _expect(TokenType.SEMICOLON); 7758 Token semicolon = _expect(TokenType.SEMICOLON);
7759 return new PartOfDirective( 7759 return new PartOfDirective(
7760 commentAndMetadata.comment, 7760 commentAndMetadata.comment,
7761 commentAndMetadata.metadata, 7761 commentAndMetadata.metadata,
7762 partKeyword, 7762 partKeyword,
7763 ofKeyword, 7763 ofKeyword,
7764 libraryName, 7764 libraryName,
7765 semicolon); 7765 semicolon);
7766 } 7766 }
7767 StringLiteral partUri = parseStringLiteral(); 7767 StringLiteral partUri = _parseUri();
7768 Token semicolon = _expect(TokenType.SEMICOLON); 7768 Token semicolon = _expect(TokenType.SEMICOLON);
7769 return new PartDirective( 7769 return new PartDirective(
7770 commentAndMetadata.comment, 7770 commentAndMetadata.comment,
7771 commentAndMetadata.metadata, 7771 commentAndMetadata.metadata,
7772 partKeyword, 7772 partKeyword,
7773 partUri, 7773 partUri,
7774 semicolon); 7774 semicolon);
7775 } 7775 }
7776 7776
7777 /** 7777 /**
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
8615 } else if (_matches(TokenType.PLUS)) { 8615 } else if (_matches(TokenType.PLUS)) {
8616 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); 8616 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
8617 return _createSyntheticIdentifier(); 8617 return _createSyntheticIdentifier();
8618 } else if (_matchesString(_AWAIT)) { 8618 } else if (_matchesString(_AWAIT)) {
8619 return _parseAwaitExpression(); 8619 return _parseAwaitExpression();
8620 } 8620 }
8621 return _parsePostfixExpression(); 8621 return _parsePostfixExpression();
8622 } 8622 }
8623 8623
8624 /** 8624 /**
8625 * Parse a string literal representing a URI.
8626 */
8627 StringLiteral _parseUri() {
8628 bool iskeywordAfterUri(Token token) =>
8629 token.lexeme == Keyword.AS.syntax ||
8630 token.lexeme == _HIDE ||
8631 token.lexeme == _SHOW;
8632 if (!_matches(TokenType.STRING) &&
8633 !_matches(TokenType.SEMICOLON) &&
8634 !iskeywordAfterUri(_currentToken)) {
8635 // Attempt to recover in the case where the URI was not enclosed in
8636 // quotes.
8637 Token token = _currentToken;
8638 while ((_tokenMatchesIdentifier(token) && !iskeywordAfterUri(token)) ||
8639 _tokenMatches(token, TokenType.COLON) ||
8640 _tokenMatches(token, TokenType.SLASH) ||
8641 _tokenMatches(token, TokenType.PERIOD) ||
8642 _tokenMatches(token, TokenType.PERIOD_PERIOD) ||
8643 _tokenMatches(token, TokenType.PERIOD_PERIOD_PERIOD) ||
8644 _tokenMatches(token, TokenType.INT) ||
8645 _tokenMatches(token, TokenType.DOUBLE)) {
8646 token = token.next;
8647 }
8648 if (_tokenMatches(token, TokenType.SEMICOLON) ||
8649 iskeywordAfterUri(token)) {
8650 Token endToken = token.previous;
8651 token = _currentToken;
8652 int endOffset = token.end;
8653 StringBuffer buffer = new StringBuffer();
8654 buffer.write(token.lexeme);
8655 while (token != endToken) {
8656 token = token.next;
8657 if (token.offset != endOffset || token.precedingComments != null) {
8658 return parseStringLiteral();
8659 }
8660 buffer.write(token.lexeme);
8661 endOffset = token.end;
8662 }
8663 String value = buffer.toString();
8664 Token newToken =
8665 new StringToken(TokenType.STRING, "'$value'", _currentToken.offset);
8666 _reportErrorForToken(
8667 ParserErrorCode.NON_STRING_LITERAL_AS_URI,
8668 newToken);
8669 _currentToken = endToken.next;
8670 return new SimpleStringLiteral(newToken, value);
8671 }
8672 }
8673 return parseStringLiteral();
8674 }
8675
8676 /**
8625 * Parse a variable declaration. 8677 * Parse a variable declaration.
8626 * 8678 *
8627 * <pre> 8679 * <pre>
8628 * variableDeclaration ::= 8680 * variableDeclaration ::=
8629 * identifier ('=' expression)? 8681 * identifier ('=' expression)?
8630 * </pre> 8682 * </pre>
8631 * 8683 *
8632 * @return the variable declaration that was parsed 8684 * @return the variable declaration that was parsed
8633 */ 8685 */
8634 VariableDeclaration _parseVariableDeclaration() { 8686 VariableDeclaration _parseVariableDeclaration() {
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
10471 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = 10523 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME =
10472 const ParserErrorCode( 10524 const ParserErrorCode(
10473 'NON_IDENTIFIER_LIBRARY_NAME', 10525 'NON_IDENTIFIER_LIBRARY_NAME',
10474 "The name of a library must be an identifier"); 10526 "The name of a library must be an identifier");
10475 10527
10476 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = 10528 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART =
10477 const ParserErrorCode( 10529 const ParserErrorCode(
10478 'NON_PART_OF_DIRECTIVE_IN_PART', 10530 'NON_PART_OF_DIRECTIVE_IN_PART',
10479 "The part-of directive must be the only directive in a part"); 10531 "The part-of directive must be the only directive in a part");
10480 10532
10533 static const ParserErrorCode NON_STRING_LITERAL_AS_URI =
10534 const ParserErrorCode(
10535 'NON_STRING_LITERAL_AS_URI',
10536 "The URI must be a string literal",
10537 "Enclose the URI in either single or double quotes.");
10538
10481 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR = 10539 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR =
10482 const ParserErrorCode( 10540 const ParserErrorCode(
10483 'NON_USER_DEFINABLE_OPERATOR', 10541 'NON_USER_DEFINABLE_OPERATOR',
10484 "The operator '{0}' is not user definable"); 10542 "The operator '{0}' is not user definable");
10485 10543
10486 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = 10544 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS =
10487 const ParserErrorCode( 10545 const ParserErrorCode(
10488 'NORMAL_BEFORE_OPTIONAL_PARAMETERS', 10546 'NORMAL_BEFORE_OPTIONAL_PARAMETERS',
10489 "Normal parameters must occur before optional parameters"); 10547 "Normal parameters must occur before optional parameters");
10490 10548
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
12036 * Copy resolution data from one node to another. 12094 * Copy resolution data from one node to another.
12037 * 12095 *
12038 * @param fromNode the node from which resolution information will be copied 12096 * @param fromNode the node from which resolution information will be copied
12039 * @param toNode the node to which resolution information will be copied 12097 * @param toNode the node to which resolution information will be copied
12040 */ 12098 */
12041 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 12099 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
12042 ResolutionCopier copier = new ResolutionCopier(); 12100 ResolutionCopier copier = new ResolutionCopier();
12043 copier._isEqualNodes(fromNode, toNode); 12101 copier._isEqualNodes(fromNode, toNode);
12044 } 12102 }
12045 } 12103 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698