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

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

Issue 2837473002: merge fasta.PrecedenceInfo into analyzer.TokenType (Closed)
Patch Set: rebase Created 3 years, 8 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 fasta.scanner.recover; 5 library fasta.scanner.recover;
6 6
7 import '../../scanner/token.dart' show TokenType;
8
7 import '../fasta_codes.dart' 9 import '../fasta_codes.dart'
8 show 10 show
9 FastaCode, 11 FastaCode,
10 codeAsciiControlCharacter, 12 codeAsciiControlCharacter,
11 codeEncoding, 13 codeEncoding,
12 codeExpectedHexDigit, 14 codeExpectedHexDigit,
13 codeMissingExponent, 15 codeMissingExponent,
14 codeNonAsciiIdentifier, 16 codeNonAsciiIdentifier,
15 codeNonAsciiWhitespace, 17 codeNonAsciiWhitespace,
16 codeUnexpectedDollarInString, 18 codeUnexpectedDollarInString,
17 codeUnmatchedToken, 19 codeUnmatchedToken,
18 codeUnterminatedComment, 20 codeUnterminatedComment,
19 codeUnterminatedString; 21 codeUnterminatedString;
20 22
21 import 'token.dart' show StringToken, SymbolToken, Token; 23 import 'token.dart' show StringToken, SymbolToken, Token;
22 24
23 import 'error_token.dart' show NonAsciiIdentifierToken, ErrorToken; 25 import 'error_token.dart' show NonAsciiIdentifierToken, ErrorToken;
24 26
25 import 'precedence.dart' as Precedence; 27 import 'precedence.dart' as Precedence;
26 28
27 import 'precedence.dart' show PrecedenceInfo;
28
29 /// Recover from errors in [tokens]. The original sources are provided as 29 /// Recover from errors in [tokens]. The original sources are provided as
30 /// [bytes]. [lineStarts] are the beginning character offsets of lines, and 30 /// [bytes]. [lineStarts] are the beginning character offsets of lines, and
31 /// must be updated if recovery is performed rewriting the original source 31 /// must be updated if recovery is performed rewriting the original source
32 /// code. 32 /// code.
33 Token defaultRecoveryStrategy( 33 Token defaultRecoveryStrategy(
34 List<int> bytes, Token tokens, List<int> lineStarts) { 34 List<int> bytes, Token tokens, List<int> lineStarts) {
35 // See [Parser.reportErrorToken](../parser/src/parser.dart) for how 35 // See [Parser.reportErrorToken](../parser/src/parser.dart) for how
36 // it currently handles lexical errors. In addition, notice how the parser 36 // it currently handles lexical errors. In addition, notice how the parser
37 // calls [handleInvalidExpression], [handleInvalidFunctionBody], and 37 // calls [handleInvalidExpression], [handleInvalidFunctionBody], and
38 // [handleInvalidTypeReference] to allow the listener to recover its internal 38 // [handleInvalidTypeReference] to allow the listener to recover its internal
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 good.previousToken = errorTail; 223 good.previousToken = errorTail;
224 tail = goodTail; 224 tail = goodTail;
225 } else { 225 } else {
226 tail = errorTail; 226 tail = errorTail;
227 } 227 }
228 if (!tail.isEof) 228 if (!tail.isEof)
229 tail.next = new SymbolToken.eof(tail.end)..previousToken = tail; 229 tail.next = new SymbolToken.eof(tail.end)..previousToken = tail;
230 return error; 230 return error;
231 } 231 }
232 232
233 Token synthesizeToken(int charOffset, String value, PrecedenceInfo info) { 233 Token synthesizeToken(int charOffset, String value, TokenType info) {
234 return new StringToken.fromString(info, value, charOffset); 234 return new StringToken.fromString(info, value, charOffset);
235 } 235 }
236 236
237 Token skipToEof(Token token) { 237 Token skipToEof(Token token) {
238 while (!token.isEof) { 238 while (!token.isEof) {
239 token = token.next; 239 token = token.next;
240 } 240 }
241 return token; 241 return token;
242 } 242 }
243 243
244 String closeBraceFor(String openBrace) { 244 String closeBraceFor(String openBrace) {
245 return const { 245 return const {
246 '(': ')', 246 '(': ')',
247 '[': ']', 247 '[': ']',
248 '{': '}', 248 '{': '}',
249 '<': '>', 249 '<': '>',
250 r'${': '}', 250 r'${': '}',
251 }[openBrace]; 251 }[openBrace];
252 } 252 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/precedence.dart ('k') | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698