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

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

Issue 2996673002: translate missing ">" fasta error code to analyzer error (Closed)
Patch Set: address comments Created 3 years, 4 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
« no previous file with comments | « pkg/analyzer/test/generated/scanner_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'package:front_end/src/base/errors.dart'; 5 import 'package:front_end/src/base/errors.dart';
6 import 'package:front_end/src/fasta/fasta_codes.dart'; 6 import 'package:front_end/src/fasta/fasta_codes.dart';
7 import 'package:front_end/src/fasta/scanner/error_token.dart'; 7 import 'package:front_end/src/fasta/scanner/error_token.dart';
8 import 'package:front_end/src/scanner/token.dart' show Token, TokenType; 8 import 'package:front_end/src/scanner/token.dart' show Token, TokenType;
9 import 'package:front_end/src/fasta/scanner/token_constants.dart'; 9 import 'package:front_end/src/fasta/scanner/token_constants.dart';
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (type == TokenType.OPEN_CURLY_BRACKET || 134 if (type == TokenType.OPEN_CURLY_BRACKET ||
135 type == TokenType.STRING_INTERPOLATION_EXPRESSION) { 135 type == TokenType.STRING_INTERPOLATION_EXPRESSION) {
136 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['}']); 136 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['}']);
137 } 137 }
138 if (type == TokenType.OPEN_SQUARE_BRACKET) { 138 if (type == TokenType.OPEN_SQUARE_BRACKET) {
139 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [']']); 139 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [']']);
140 } 140 }
141 if (type == TokenType.OPEN_PAREN) { 141 if (type == TokenType.OPEN_PAREN) {
142 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [')']); 142 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [')']);
143 } 143 }
144 if (type == TokenType.LT) {
145 return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['>']);
146 }
144 } else if (errorCode == codeUnexpectedDollarInString) { 147 } else if (errorCode == codeUnexpectedDollarInString) {
145 return _makeError(ScannerErrorCode.MISSING_IDENTIFIER, null); 148 return _makeError(ScannerErrorCode.MISSING_IDENTIFIER, null);
146 } 149 }
147 throw new UnimplementedError('$errorCode'); 150 throw new UnimplementedError('$errorCode');
148 } 151 }
149 } 152 }
150 153
151 /** 154 /**
152 * Determines whether the given [charOffset], which came from the non-EOF token 155 * Determines whether the given [charOffset], which came from the non-EOF token
153 * [token], represents the end of the input. 156 * [token], represents the end of the input.
154 */ 157 */
155 bool _isAtEnd(Token token, int charOffset) { 158 bool _isAtEnd(Token token, int charOffset) {
156 while (true) { 159 while (true) {
157 // Skip to the next token. 160 // Skip to the next token.
158 token = token.next; 161 token = token.next;
159 // If we've found an EOF token, its charOffset indicates where the end of 162 // If we've found an EOF token, its charOffset indicates where the end of
160 // the input is. 163 // the input is.
161 if (token.isEof) return token.charOffset == charOffset; 164 if (token.isEof) return token.charOffset == charOffset;
162 // If we've found a non-error token, then we know there is additional input 165 // If we've found a non-error token, then we know there is additional input
163 // text after [charOffset]. 166 // text after [charOffset].
164 if (token.type.kind != BAD_INPUT_TOKEN) return false; 167 if (token.type.kind != BAD_INPUT_TOKEN) return false;
165 // Otherwise keep looking. 168 // Otherwise keep looking.
166 } 169 }
167 } 170 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/scanner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698