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

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

Issue 2662433002: Fix some bugs related to the covariant keyword (Closed)
Patch Set: Created 3 years, 10 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
« 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 library analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 3830 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 } 3841 }
3842 } else if (keyword == Keyword.CONST) { 3842 } else if (keyword == Keyword.CONST) {
3843 if (modifiers.constKeyword != null) { 3843 if (modifiers.constKeyword != null) {
3844 _reportErrorForCurrentToken( 3844 _reportErrorForCurrentToken(
3845 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]); 3845 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
3846 _advance(); 3846 _advance();
3847 } else { 3847 } else {
3848 modifiers.constKeyword = getAndAdvance(); 3848 modifiers.constKeyword = getAndAdvance();
3849 } 3849 }
3850 } else if (keyword == Keyword.COVARIANT) { 3850 } else if (keyword == Keyword.COVARIANT) {
3851 if (modifiers.constKeyword != null) { 3851 if (modifiers.covariantKeyword != null) {
3852 _reportErrorForCurrentToken( 3852 _reportErrorForCurrentToken(
3853 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]); 3853 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
3854 _advance(); 3854 _advance();
3855 } else { 3855 } else {
3856 modifiers.covariantKeyword = getAndAdvance(); 3856 modifiers.covariantKeyword = getAndAdvance();
3857 } 3857 }
3858 } else if (keyword == Keyword.EXTERNAL) { 3858 } else if (keyword == Keyword.EXTERNAL) {
3859 if (modifiers.externalKeyword != null) { 3859 if (modifiers.externalKeyword != null) {
3860 _reportErrorForCurrentToken( 3860 _reportErrorForCurrentToken(
3861 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]); 3861 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 if (_matchesKeyword(Keyword.COVARIANT)) { 4145 if (_matchesKeyword(Keyword.COVARIANT)) {
4146 // Check to ensure that 'covariant' isn't being used as the parameter name . 4146 // Check to ensure that 'covariant' isn't being used as the parameter name .
4147 Token next = _peek(); 4147 Token next = _peek();
4148 if (_tokenMatchesKeyword(next, Keyword.FINAL) || 4148 if (_tokenMatchesKeyword(next, Keyword.FINAL) ||
4149 _tokenMatchesKeyword(next, Keyword.CONST) || 4149 _tokenMatchesKeyword(next, Keyword.CONST) ||
4150 _tokenMatchesKeyword(next, Keyword.VAR) || 4150 _tokenMatchesKeyword(next, Keyword.VAR) ||
4151 _tokenMatchesKeyword(next, Keyword.THIS) || 4151 _tokenMatchesKeyword(next, Keyword.THIS) ||
4152 _tokenMatchesIdentifier(next)) { 4152 _tokenMatchesIdentifier(next)) {
4153 covariantKeyword = getAndAdvance(); 4153 covariantKeyword = getAndAdvance();
4154 } 4154 }
4155 while (_matchesKeyword(Keyword.COVARIANT)) {
4156 _reportErrorForCurrentToken(
4157 ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexeme]);
4158 _advance();
4159 }
4155 } 4160 }
4156 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType, 4161 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType,
4157 inFunctionType: inFunctionType); 4162 inFunctionType: inFunctionType);
4158 Token thisKeyword = null; 4163 Token thisKeyword = null;
4159 Token period = null; 4164 Token period = null;
4160 if (_matchesKeyword(Keyword.THIS)) { 4165 if (_matchesKeyword(Keyword.THIS)) {
4161 thisKeyword = getAndAdvance(); 4166 thisKeyword = getAndAdvance();
4162 period = _expect(TokenType.PERIOD); 4167 period = _expect(TokenType.PERIOD);
4163 } 4168 }
4164 if (!_matchesIdentifier() && inFunctionType) { 4169 if (!_matchesIdentifier() && inFunctionType) {
(...skipping 4340 matching lines...) Expand 10 before | Expand all | Expand 10 after
8505 */ 8510 */
8506 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 8511 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8507 : super(keyword, offset); 8512 : super(keyword, offset);
8508 8513
8509 @override 8514 @override
8510 int get length => 0; 8515 int get length => 0;
8511 8516
8512 @override 8517 @override
8513 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 8518 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8514 } 8519 }
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