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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/token_stream_rewriter.dart

Issue 2767083002: fasta scanner recovery and error code translation improvements (Closed)
Patch Set: revert address comments and fix for token_stream_rewriter test Created 3 years, 9 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/lib/src/fasta/token_utils.dart ('k') | pkg/front_end/lib/src/fasta/scanner.dart » ('j') | 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) 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 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/fasta/errors.dart'; 5 import 'package:front_end/src/fasta/errors.dart';
6 import 'package:front_end/src/fasta/scanner/precedence.dart'; 6 import 'package:front_end/src/fasta/scanner/precedence.dart';
7 import 'package:front_end/src/fasta/scanner/token.dart'; 7 import 'package:front_end/src/fasta/scanner/token.dart';
8 8
9 /// Provides the capability of inserting tokens into a token stream by rewriting 9 /// Provides the capability of inserting tokens into a token stream by rewriting
10 /// the previous token to point to the inserted token. 10 /// the previous token to point to the inserted token.
(...skipping 10 matching lines...) Expand all
21 21
22 /// The token whose "next" pointer was updated in the last call to 22 /// The token whose "next" pointer was updated in the last call to
23 /// [insertTokenBefore]. This can often be used as a starting point to find 23 /// [insertTokenBefore]. This can often be used as a starting point to find
24 /// the a future insertion point quickly. 24 /// the a future insertion point quickly.
25 Token _lastPreviousToken; 25 Token _lastPreviousToken;
26 26
27 /// Creates a [TokenStreamRewriter] which is prepared to rewrite the token 27 /// Creates a [TokenStreamRewriter] which is prepared to rewrite the token
28 /// stream whose first token is [firstToken]. 28 /// stream whose first token is [firstToken].
29 TokenStreamRewriter(Token firstToken) 29 TokenStreamRewriter(Token firstToken)
30 : _head = firstToken.previousToken ?? 30 : _head = firstToken.previousToken ??
31 (new SymbolToken(EOF_INFO, -1)..next = firstToken); 31 (new SymbolToken.eof(-1)..next = firstToken);
32 32
33 /// Gets the first token in the stream (which may not be the same token that 33 /// Gets the first token in the stream (which may not be the same token that
34 /// was passed to the constructor, if something was inserted before it). 34 /// was passed to the constructor, if something was inserted before it).
35 Token get firstToken => _head.next; 35 Token get firstToken => _head.next;
36 36
37 /// Inserts [newToken] into the token stream just before [insertionPoint], and 37 /// Inserts [newToken] into the token stream just before [insertionPoint], and
38 /// fixes up all "next" and "previous" pointers. 38 /// fixes up all "next" and "previous" pointers.
39 /// 39 ///
40 /// Caller is required to ensure that [insertionPoint] is actually present in 40 /// Caller is required to ensure that [insertionPoint] is actually present in
41 /// the token stream. 41 /// the token stream.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 nextPos = pos.next; 97 nextPos = pos.next;
98 if (nextPos == null || nextPos.charOffset > target.charOffset) { 98 if (nextPos == null || nextPos.charOffset > target.charOffset) {
99 return null; 99 return null;
100 } 100 }
101 } 101 }
102 pos = nextPos; 102 pos = nextPos;
103 } 103 }
104 return pos; 104 return pos;
105 } 105 }
106 } 106 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/fasta/token_utils.dart ('k') | pkg/front_end/lib/src/fasta/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698