| 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 import '../../scanner/token.dart' show TokenType; | 7 import '../../scanner/token.dart' show TokenType; |
| 8 | 8 |
| 9 import '../fasta_codes.dart' | 9 import '../fasta_codes.dart' |
| 10 show | 10 show |
| 11 FastaCode, | 11 FastaCode, |
| 12 codeAsciiControlCharacter, | 12 codeAsciiControlCharacter, |
| 13 codeEncoding, | 13 codeEncoding, |
| 14 codeExpectedHexDigit, | 14 codeExpectedHexDigit, |
| 15 codeMissingExponent, | 15 codeMissingExponent, |
| 16 codeNonAsciiIdentifier, | 16 codeNonAsciiIdentifier, |
| 17 codeNonAsciiWhitespace, | 17 codeNonAsciiWhitespace, |
| 18 codeUnexpectedDollarInString, | 18 codeUnexpectedDollarInString, |
| 19 codeUnmatchedToken, | 19 codeUnmatchedToken, |
| 20 codeUnterminatedComment, | 20 codeUnterminatedComment, |
| 21 codeUnterminatedString, | 21 codeUnterminatedString, |
| 22 codeUnterminatedToken; | 22 codeUnterminatedToken; |
| 23 | 23 |
| 24 import '../scanner.dart' | 24 import '../scanner.dart' |
| 25 show BeginGroupToken, Token, unicodeReplacementCharacter; | 25 show BeginGroupToken, Token, unicodeReplacementCharacter; |
| 26 | 26 |
| 27 import 'precedence.dart' show BAD_INPUT_INFO; | |
| 28 | |
| 29 ErrorToken buildUnexpectedCharacterToken(int character, int charOffset) { | 27 ErrorToken buildUnexpectedCharacterToken(int character, int charOffset) { |
| 30 if (character < 0x1f) { | 28 if (character < 0x1f) { |
| 31 return new AsciiControlCharacterToken(character, charOffset); | 29 return new AsciiControlCharacterToken(character, charOffset); |
| 32 } | 30 } |
| 33 switch (character) { | 31 switch (character) { |
| 34 case unicodeReplacementCharacter: | 32 case unicodeReplacementCharacter: |
| 35 return new EncodingErrorToken(charOffset); | 33 return new EncodingErrorToken(charOffset); |
| 36 | 34 |
| 37 /// See [General Punctuation] | 35 /// See [General Punctuation] |
| 38 /// (http://www.unicode.org/charts/PDF/U2000.pdf). | 36 /// (http://www.unicode.org/charts/PDF/U2000.pdf). |
| (...skipping 25 matching lines...) Expand all Loading... |
| 64 } | 62 } |
| 65 } | 63 } |
| 66 | 64 |
| 67 /// Common superclass for all error tokens. | 65 /// Common superclass for all error tokens. |
| 68 /// | 66 /// |
| 69 /// It's considered an implementation error to access [lexeme] of an | 67 /// It's considered an implementation error to access [lexeme] of an |
| 70 /// [ErrorToken]. | 68 /// [ErrorToken]. |
| 71 abstract class ErrorToken extends Token { | 69 abstract class ErrorToken extends Token { |
| 72 ErrorToken(int charOffset) : super(charOffset); | 70 ErrorToken(int charOffset) : super(charOffset); |
| 73 | 71 |
| 74 TokenType get info => BAD_INPUT_INFO; | 72 TokenType get info => TokenType.BAD_INPUT; |
| 75 | 73 |
| 76 String get lexeme => throw assertionMessage; | 74 String get lexeme => throw assertionMessage; |
| 77 | 75 |
| 78 String get stringValue => null; | 76 String get stringValue => null; |
| 79 | 77 |
| 80 bool isIdentifier() => false; | 78 bool isIdentifier() => false; |
| 81 | 79 |
| 82 String get assertionMessage; | 80 String get assertionMessage; |
| 83 | 81 |
| 84 FastaCode get errorCode; | 82 FastaCode get errorCode; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 UnmatchedToken(BeginGroupToken begin) | 217 UnmatchedToken(BeginGroupToken begin) |
| 220 : this.begin = begin, | 218 : this.begin = begin, |
| 221 super(begin.charOffset); | 219 super(begin.charOffset); |
| 222 | 220 |
| 223 String toString() => "UnmatchedToken(${begin.lexeme})"; | 221 String toString() => "UnmatchedToken(${begin.lexeme})"; |
| 224 | 222 |
| 225 String get assertionMessage => "'$begin' isn't closed."; | 223 String get assertionMessage => "'$begin' isn't closed."; |
| 226 | 224 |
| 227 FastaCode get errorCode => codeUnmatchedToken; | 225 FastaCode get errorCode => codeUnmatchedToken; |
| 228 } | 226 } |
| OLD | NEW |