| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 licenset hat can be found in the LICENSE file. | 3 // BSD-style licenset hat can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart_scanner.error_token; | 5 library dart_scanner.error_token; |
| 6 | 6 |
| 7 // TODO(ahe): ErrorKind doesn't belong in dart_parser. Move to compiler_util or | 7 // TODO(ahe): ErrorKind doesn't belong in dart_parser. Move to compiler_util or |
| 8 // this package? | 8 // this package? |
| 9 import '../parser/error_kind.dart' show ErrorKind; | 9 import '../parser/error_kind.dart' show ErrorKind; |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 case 0xFEFF: // Zero width no-break space. | 48 case 0xFEFF: // Zero width no-break space. |
| 49 return new NonAsciiWhitespaceToken(character, charOffset); | 49 return new NonAsciiWhitespaceToken(character, charOffset); |
| 50 | 50 |
| 51 default: | 51 default: |
| 52 return new NonAsciiIdentifierToken(character, charOffset); | 52 return new NonAsciiIdentifierToken(character, charOffset); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 /// Common superclass for all error tokens. | 56 /// Common superclass for all error tokens. |
| 57 /// | 57 /// |
| 58 /// It's considered an implementation error to access [value] of an | 58 /// It's considered an implementation error to access [lexeme] of an |
| 59 /// [ErrorToken]. | 59 /// [ErrorToken]. |
| 60 abstract class ErrorToken extends Token { | 60 abstract class ErrorToken extends Token { |
| 61 ErrorToken(int charOffset) : super(charOffset); | 61 ErrorToken(int charOffset) : super(charOffset); |
| 62 | 62 |
| 63 PrecedenceInfo get info => BAD_INPUT_INFO; | 63 PrecedenceInfo get info => BAD_INPUT_INFO; |
| 64 | 64 |
| 65 String get value => throw assertionMessage; | 65 String get lexeme => throw assertionMessage; |
| 66 | 66 |
| 67 String get stringValue => null; | 67 String get stringValue => null; |
| 68 | 68 |
| 69 bool isIdentifier() => false; | 69 bool isIdentifier() => false; |
| 70 | 70 |
| 71 String get assertionMessage; | 71 String get assertionMessage; |
| 72 | 72 |
| 73 ErrorKind get errorCode; | 73 ErrorKind get errorCode; |
| 74 | 74 |
| 75 int get character => null; | 75 int get character => null; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 /// | 197 /// |
| 198 /// In this case, brace means any of `(`, `{`, `[`, and `<`, parenthesis, curly | 198 /// In this case, brace means any of `(`, `{`, `[`, and `<`, parenthesis, curly |
| 199 /// brace, square brace, and angle brace, respectively. | 199 /// brace, square brace, and angle brace, respectively. |
| 200 class UnmatchedToken extends ErrorToken { | 200 class UnmatchedToken extends ErrorToken { |
| 201 final BeginGroupToken begin; | 201 final BeginGroupToken begin; |
| 202 | 202 |
| 203 UnmatchedToken(BeginGroupToken begin) | 203 UnmatchedToken(BeginGroupToken begin) |
| 204 : this.begin = begin, | 204 : this.begin = begin, |
| 205 super(begin.charOffset); | 205 super(begin.charOffset); |
| 206 | 206 |
| 207 String toString() => "UnmatchedToken(${begin.value})"; | 207 String toString() => "UnmatchedToken(${begin.lexeme})"; |
| 208 | 208 |
| 209 String get assertionMessage => "'$begin' isn't closed."; | 209 String get assertionMessage => "'$begin' isn't closed."; |
| 210 | 210 |
| 211 ErrorKind get errorCode => ErrorKind.UnmatchedToken; | 211 ErrorKind get errorCode => ErrorKind.UnmatchedToken; |
| 212 } | 212 } |
| OLD | NEW |