| OLD | NEW |
| 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 fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../scanner.dart' show | 7 import '../scanner.dart' show |
| 8 ErrorToken; | 8 ErrorToken; |
| 9 | 9 |
| 10 import '../scanner/recover.dart' show | 10 import '../scanner/recover.dart' show |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3279 } else { | 3279 } else { |
| 3280 arguments ??= {}; | 3280 arguments ??= {}; |
| 3281 listener.handleRecoverableError(token, kind, arguments); | 3281 listener.handleRecoverableError(token, kind, arguments); |
| 3282 } | 3282 } |
| 3283 } | 3283 } |
| 3284 | 3284 |
| 3285 Token reportErrorToken(ErrorToken token, bool isRecoverable) { | 3285 Token reportErrorToken(ErrorToken token, bool isRecoverable) { |
| 3286 ErrorKind kind = token.errorCode; | 3286 ErrorKind kind = token.errorCode; |
| 3287 Map arguments = const {}; | 3287 Map arguments = const {}; |
| 3288 switch (kind) { | 3288 switch (kind) { |
| 3289 case ErrorKind.AsciiControlCharacter: |
| 3289 case ErrorKind.NonAsciiIdentifier: | 3290 case ErrorKind.NonAsciiIdentifier: |
| 3291 case ErrorKind.NonAsciiWhitespace: |
| 3292 case ErrorKind.Encoding: |
| 3290 String hex = token.character.toRadixString(16); | 3293 String hex = token.character.toRadixString(16); |
| 3291 if (hex.length < 4) { | 3294 if (hex.length < 4) { |
| 3292 String padding = "0000".substring(hex.length); | 3295 String padding = "0000".substring(hex.length); |
| 3293 hex = "$padding$hex"; | 3296 hex = "$padding$hex"; |
| 3294 } | 3297 } |
| 3295 arguments = {'characterHex': hex}; | 3298 arguments = {'characterHex': hex}; |
| 3296 break; | 3299 break; |
| 3297 | 3300 |
| 3298 case ErrorKind.UnterminatedString: | 3301 case ErrorKind.UnterminatedString: |
| 3299 arguments = {'quote': token.start}; | 3302 arguments = {'quote': token.start}; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3313 break; | 3316 break; |
| 3314 } | 3317 } |
| 3315 if (isRecoverable) { | 3318 if (isRecoverable) { |
| 3316 listener.handleRecoverableError(token, kind, arguments); | 3319 listener.handleRecoverableError(token, kind, arguments); |
| 3317 return null; | 3320 return null; |
| 3318 } else { | 3321 } else { |
| 3319 return listener.handleUnrecoverableError(token, kind, arguments); | 3322 return listener.handleUnrecoverableError(token, kind, arguments); |
| 3320 } | 3323 } |
| 3321 } | 3324 } |
| 3322 } | 3325 } |
| OLD | NEW |