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

Side by Side Diff: pkg/front_end/lib/src/fasta/scanner/error_token.dart

Issue 2890523002: merge fasta.Token into analyzer.Token (Closed)
Patch Set: Created 3 years, 7 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) 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, TokenWithComment;
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,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 default: 60 default:
61 return new NonAsciiIdentifierToken(character, charOffset); 61 return new NonAsciiIdentifierToken(character, charOffset);
62 } 62 }
63 } 63 }
64 64
65 /// Common superclass for all error tokens. 65 /// Common superclass for all error tokens.
66 /// 66 ///
67 /// It's considered an implementation error to access [lexeme] of an 67 /// It's considered an implementation error to access [lexeme] of an
68 /// [ErrorToken]. 68 /// [ErrorToken].
69 abstract class ErrorToken extends Token { 69 abstract class ErrorToken extends TokenWithComment {
70 ErrorToken(int charOffset) : super(charOffset); 70 ErrorToken(int offset) : super(TokenType.BAD_INPUT, offset, null);
71
72 TokenType get type => TokenType.BAD_INPUT;
73 71
74 /// This is a token that wraps around an error message. Return 1 72 /// This is a token that wraps around an error message. Return 1
75 /// instead of the size of the length of the error message. 73 /// instead of the size of the length of the error message.
76 @override 74 @override
77 int get charCount => 1; 75 int get length => 1;
78 76
79 String get lexeme => throw assertionMessage; 77 String get lexeme => throw assertionMessage;
80 78
81 bool get isIdentifier => false;
82
83 String get assertionMessage; 79 String get assertionMessage;
84 80
85 FastaCode get errorCode; 81 FastaCode get errorCode;
86 82
87 int get character => null; 83 int get character => null;
88 84
89 String get start => null; 85 String get start => null;
90 86
91 int get endOffset => null; 87 int get endOffset => null;
92 88
93 BeginGroupToken get begin => null; 89 BeginGroupToken get begin => null;
94 90
95 @override 91 @override
96 Token copyWithoutComments() { 92 Token copy() {
97 throw 'unsupported operation'; 93 throw 'unsupported operation';
98 } 94 }
99 } 95 }
100 96
101 /// Represents an encoding error. 97 /// Represents an encoding error.
102 class EncodingErrorToken extends ErrorToken { 98 class EncodingErrorToken extends ErrorToken {
103 EncodingErrorToken(int charOffset) : super(charOffset); 99 EncodingErrorToken(int charOffset) : super(charOffset);
104 100
105 String toString() => "EncodingErrorToken()"; 101 String toString() => "EncodingErrorToken()";
106 102
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 UnmatchedToken(BeginGroupToken begin) 216 UnmatchedToken(BeginGroupToken begin)
221 : this.begin = begin, 217 : this.begin = begin,
222 super(begin.charOffset); 218 super(begin.charOffset);
223 219
224 String toString() => "UnmatchedToken(${begin.lexeme})"; 220 String toString() => "UnmatchedToken(${begin.lexeme})";
225 221
226 String get assertionMessage => "'$begin' isn't closed."; 222 String get assertionMessage => "'$begin' isn't closed.";
227 223
228 FastaCode get errorCode => codeUnmatchedToken; 224 FastaCode get errorCode => codeUnmatchedToken;
229 } 225 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart ('k') | pkg/front_end/lib/src/fasta/scanner/recover.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698