| OLD | NEW |
| 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 '../parser/error_kind.dart' show ErrorKind; | 7 import '../parser/error_kind.dart' show ErrorKind; |
| 8 | 8 |
| 9 import '../scanner/error_token.dart' show ErrorToken; | 9 import '../scanner/error_token.dart' show ErrorToken; |
| 10 | 10 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 Token translateComments(analyzer.Token token) { | 276 Token translateComments(analyzer.Token token) { |
| 277 if (token == null) { | 277 if (token == null) { |
| 278 return null; | 278 return null; |
| 279 } | 279 } |
| 280 Token head = fromAnalyzerToken(token); | 280 Token head = fromAnalyzerToken(token); |
| 281 Token tail = head; | 281 Token tail = head; |
| 282 token = token.next; | 282 token = token.next; |
| 283 while (token != null) { | 283 while (token != null) { |
| 284 tail.next = fromAnalyzerToken(token); | 284 tail.next = fromAnalyzerToken(token); |
| 285 tail.next.previousToken = tail; |
| 285 tail = tail.next; | 286 tail = tail.next; |
| 286 token = token.next; | 287 token = token.next; |
| 287 } | 288 } |
| 288 return head; | 289 return head; |
| 289 } | 290 } |
| 290 | 291 |
| 291 analyzer.Token translateAndAppend(analyzer.Token analyzerToken) { | 292 analyzer.Token translateAndAppend(analyzer.Token analyzerToken) { |
| 292 var token = fromAnalyzerToken(analyzerToken); | 293 var token = fromAnalyzerToken(analyzerToken); |
| 293 token.precedingComments = | 294 token.precedingComments = |
| 294 translateComments(analyzerToken.precedingComments); | 295 translateComments(analyzerToken.precedingComments); |
| 295 tokenTail.next = token; | 296 tokenTail.next = token; |
| 297 tokenTail.next.previousToken = tokenTail; |
| 296 tokenTail = token; | 298 tokenTail = token; |
| 297 matchGroups(analyzerToken, token); | 299 matchGroups(analyzerToken, token); |
| 298 return analyzerToken.next; | 300 return analyzerToken.next; |
| 299 } | 301 } |
| 300 | 302 |
| 301 while (true) { | 303 while (true) { |
| 302 // TODO(paulberry): join up begingroup/endgroup. | 304 // TODO(paulberry): join up begingroup/endgroup. |
| 303 if (analyzerToken.type == TokenType.EOF) { | 305 if (analyzerToken.type == TokenType.EOF) { |
| 304 tokenTail.next = new SymbolToken(EOF_INFO, analyzerToken.offset); | 306 tokenTail.next = new SymbolToken(EOF_INFO, analyzerToken.offset); |
| 307 tokenTail.next.previousToken = tokenTail; |
| 305 tokenTail.next.precedingComments = | 308 tokenTail.next.precedingComments = |
| 306 translateComments(analyzerToken.precedingComments); | 309 translateComments(analyzerToken.precedingComments); |
| 307 return tokenHead.next; | 310 return tokenHead.next; |
| 308 } | 311 } |
| 309 analyzerToken = translateAndAppend(analyzerToken); | 312 analyzerToken = translateAndAppend(analyzerToken); |
| 310 } | 313 } |
| 311 } | 314 } |
| 312 | 315 |
| 313 /// Converts a single analyzer token into a Fasta token. | 316 /// Converts a single analyzer token into a Fasta token. |
| 314 Token fromAnalyzerToken(analyzer.Token token) { | 317 Token fromAnalyzerToken(analyzer.Token token) { |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 case PERIOD_PERIOD_PERIOD_TOKEN: | 778 case PERIOD_PERIOD_PERIOD_TOKEN: |
| 776 return TokenType.PERIOD_PERIOD_PERIOD; | 779 return TokenType.PERIOD_PERIOD_PERIOD; |
| 777 // case GENERIC_METHOD_TYPE_LIST_TOKEN: | 780 // case GENERIC_METHOD_TYPE_LIST_TOKEN: |
| 778 // return TokenType.GENERIC_METHOD_TYPE_LIST; | 781 // return TokenType.GENERIC_METHOD_TYPE_LIST; |
| 779 // case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: | 782 // case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: |
| 780 // return TokenType.GENERIC_METHOD_TYPE_ASSIGN; | 783 // return TokenType.GENERIC_METHOD_TYPE_ASSIGN; |
| 781 default: | 784 default: |
| 782 return internalError("Unhandled token ${token.info}"); | 785 return internalError("Unhandled token ${token.info}"); |
| 783 } | 786 } |
| 784 } | 787 } |
| OLD | NEW |