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

Side by Side Diff: pkg/analyzer/lib/src/fasta/token_utils.dart

Issue 2837473002: merge fasta.PrecedenceInfo into analyzer.TokenType (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.analyzer.token_utils; 5 library fasta.analyzer.token_utils;
6 6
7 import 'package:front_end/src/fasta/scanner/error_token.dart' show ErrorToken; 7 import 'package:front_end/src/fasta/scanner/error_token.dart' show ErrorToken;
8 8
9 import 'package:front_end/src/scanner/token.dart' show Keyword; 9 import 'package:front_end/src/scanner/token.dart' show Keyword;
10 10
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 translateComments(analyzerToken.precedingComments); 270 translateComments(analyzerToken.precedingComments);
271 tokenTail.next.next = tokenTail.next; 271 tokenTail.next.next = tokenTail.next;
272 return tokenHead.next; 272 return tokenHead.next;
273 } 273 }
274 analyzerToken = translateAndAppend(analyzerToken); 274 analyzerToken = translateAndAppend(analyzerToken);
275 } 275 }
276 } 276 }
277 277
278 /// Converts a single analyzer token into a Fasta token. 278 /// Converts a single analyzer token into a Fasta token.
279 Token fromAnalyzerToken(analyzer.Token token) { 279 Token fromAnalyzerToken(analyzer.Token token) {
280 Token beginGroup(PrecedenceInfo info) => 280 Token beginGroup(TokenType info) => new BeginGroupToken(info, token.offset);
281 new BeginGroupToken(info, token.offset); 281 Token string(TokenType info) =>
282 Token string(PrecedenceInfo info) =>
283 new StringToken.fromString(info, token.lexeme, token.offset); 282 new StringToken.fromString(info, token.lexeme, token.offset);
284 Token symbol(PrecedenceInfo info) => new SymbolToken(info, token.offset); 283 Token symbol(TokenType info) => new SymbolToken(info, token.offset);
285 switch (token.type) { 284 switch (token.type) {
286 case TokenType.DOUBLE: 285 case TokenType.DOUBLE:
287 return string(DOUBLE_INFO); 286 return string(DOUBLE_INFO);
288 case TokenType.HEXADECIMAL: 287 case TokenType.HEXADECIMAL:
289 return string(HEXADECIMAL_INFO); 288 return string(HEXADECIMAL_INFO);
290 case TokenType.IDENTIFIER: 289 case TokenType.IDENTIFIER:
291 // Certain identifiers have special grammatical meanings even though they 290 // Certain identifiers have special grammatical meanings even though they
292 // are neither keywords nor built-in identifiers (e.g. "async"). Analyzer 291 // are neither keywords nor built-in identifiers (e.g. "async"). Analyzer
293 // represents these as identifiers. Fasta represents them as keywords 292 // represents these as identifiers. Fasta represents them as keywords
294 // with the "isPseudo" property. 293 // with the "isPseudo" property.
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 case PERIOD_PERIOD_PERIOD_TOKEN: 744 case PERIOD_PERIOD_PERIOD_TOKEN:
746 return TokenType.PERIOD_PERIOD_PERIOD; 745 return TokenType.PERIOD_PERIOD_PERIOD;
747 case GENERIC_METHOD_TYPE_LIST_TOKEN: 746 case GENERIC_METHOD_TYPE_LIST_TOKEN:
748 return TokenType.GENERIC_METHOD_TYPE_LIST; 747 return TokenType.GENERIC_METHOD_TYPE_LIST;
749 case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: 748 case GENERIC_METHOD_TYPE_ASSIGN_TOKEN:
750 return TokenType.GENERIC_METHOD_TYPE_ASSIGN; 749 return TokenType.GENERIC_METHOD_TYPE_ASSIGN;
751 default: 750 default:
752 return internalError("Unhandled token ${token.info}"); 751 return internalError("Unhandled token ${token.info}");
753 } 752 }
754 } 753 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698