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

Side by Side Diff: pkg/compiler/lib/src/parser/parser.dart

Issue 1943723003: Report UNMATCHED_TOKEN instead of EXTRANEOUS_MODIFIER (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add test from bug report Created 4 years, 7 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 | tests/compiler/dart2js/error_token_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) 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 library dart2js.parser; 5 library dart2js.parser;
6 6
7 import '../options.dart' show ParserOptions; 7 import '../options.dart' show ParserOptions;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../tokens/keyword.dart' show Keyword; 9 import '../tokens/keyword.dart' show Keyword;
10 import '../tokens/precedence.dart' show PrecedenceInfo; 10 import '../tokens/precedence.dart' show PrecedenceInfo;
(...skipping 10 matching lines...) Expand all
21 OPEN_SQUARE_BRACKET_INFO, 21 OPEN_SQUARE_BRACKET_INFO,
22 PERIOD_INFO, 22 PERIOD_INFO,
23 PLUS_PLUS_INFO, 23 PLUS_PLUS_INFO,
24 POSTFIX_PRECEDENCE, 24 POSTFIX_PRECEDENCE,
25 QUESTION_INFO, 25 QUESTION_INFO,
26 QUESTION_PERIOD_INFO, 26 QUESTION_PERIOD_INFO,
27 RELATIONAL_PRECEDENCE; 27 RELATIONAL_PRECEDENCE;
28 import '../tokens/token.dart' 28 import '../tokens/token.dart'
29 show 29 show
30 BeginGroupToken, 30 BeginGroupToken,
31 ErrorToken,
31 isUserDefinableOperator, 32 isUserDefinableOperator,
32 KeywordToken, 33 KeywordToken,
33 SymbolToken, 34 SymbolToken,
34 Token; 35 Token;
35 import '../tokens/token_constants.dart' 36 import '../tokens/token_constants.dart'
36 show 37 show
37 BAD_INPUT_TOKEN, 38 BAD_INPUT_TOKEN,
38 COMMA_TOKEN, 39 COMMA_TOKEN,
39 DOUBLE_TOKEN, 40 DOUBLE_TOKEN,
40 EOF_TOKEN, 41 EOF_TOKEN,
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 parseModifier(varFinalOrConst); 994 parseModifier(varFinalOrConst);
994 modifierCount++; 995 modifierCount++;
995 hasTypeOrModifier = true; 996 hasTypeOrModifier = true;
996 modifierList.remove(varFinalOrConst); 997 modifierList.remove(varFinalOrConst);
997 } 998 }
998 listener.handleModifiers(modifierCount); 999 listener.handleModifiers(modifierCount);
999 var kind = hasTypeOrModifier 1000 var kind = hasTypeOrModifier
1000 ? MessageKind.EXTRANEOUS_MODIFIER 1001 ? MessageKind.EXTRANEOUS_MODIFIER
1001 : MessageKind.EXTRANEOUS_MODIFIER_REPLACE; 1002 : MessageKind.EXTRANEOUS_MODIFIER_REPLACE;
1002 for (Token modifier in modifierList) { 1003 for (Token modifier in modifierList) {
1003 listener.reportError(modifier, kind, {'modifier': modifier}); 1004 if (modifier is ErrorToken) {
ahe 2016/05/03 11:11:38 Modify Listenener.reportError instead.
Johnni Winther 2016/05/04 08:07:31 Done.
1005 listener.reportErrorToken(modifier);
1006 } else {
1007 listener.reportError(modifier, kind, {'modifier': modifier});
1008 }
1004 } 1009 }
1005 return null; 1010 return null;
1006 } 1011 }
1007 1012
1008 Token parseFields(Token start, Link<Token> modifiers, Token type, 1013 Token parseFields(Token start, Link<Token> modifiers, Token type,
1009 Token getOrSet, Token name, bool isTopLevel) { 1014 Token getOrSet, Token name, bool isTopLevel) {
1010 bool hasType = type != null; 1015 bool hasType = type != null;
1011 Token varFinalOrConst = 1016 Token varFinalOrConst =
1012 expectVarFinalOrConst(modifiers, hasType, !isTopLevel); 1017 expectVarFinalOrConst(modifiers, hasType, !isTopLevel);
1013 bool isVar = false; 1018 bool isVar = false;
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 } 2987 }
2983 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2988 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2984 return expectSemicolon(token); 2989 return expectSemicolon(token);
2985 } 2990 }
2986 2991
2987 Token parseEmptyStatement(Token token) { 2992 Token parseEmptyStatement(Token token) {
2988 listener.handleEmptyStatement(token); 2993 listener.handleEmptyStatement(token);
2989 return expectSemicolon(token); 2994 return expectSemicolon(token);
2990 } 2995 }
2991 } 2996 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/error_token_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698