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

Side by Side Diff: pkg/analyzer/lib/src/dart/scanner/scanner.dart

Issue 2895803002: add fasta.scanner support for lazy assignment operators (Closed)
Patch Set: address comments 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analyzer.src.dart.scanner.scanner; 5 library analyzer.src.dart.scanner.scanner;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/error/listener.dart'; 8 import 'package:analyzer/error/listener.dart';
9 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; 9 import 'package:analyzer/src/dart/error/syntactic_errors.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 @override 141 @override
142 Token tokenize() { 142 Token tokenize() {
143 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`), 143 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`),
144 // so we can ignore the `scanLazyAssignmentOperators` flag. 144 // so we can ignore the `scanLazyAssignmentOperators` flag.
145 if (scanGenericMethodComments) { 145 if (scanGenericMethodComments) {
146 // Fasta doesn't support generic method comments. 146 // Fasta doesn't support generic method comments.
147 // TODO(danrubel): remove this once fasts support has been added. 147 // TODO(danrubel): remove this once fasts support has been added.
148 throw 'No generic method comment support in Fasta'; 148 throw 'No generic method comment support in Fasta';
149 } 149 }
150 fasta.ScannerResult result = 150 fasta.ScannerResult result = fasta.scanString(_contents,
151 fasta.scanString(_contents, includeComments: _preserveComments); 151 includeComments: _preserveComments,
152 scanLazyAssignmentOperators: scanLazyAssignmentOperators);
152 // fasta pretends there is an additional line at EOF 153 // fasta pretends there is an additional line at EOF
153 lineStarts 154 lineStarts
154 .addAll(result.lineStarts.sublist(1, result.lineStarts.length - 1)); 155 .addAll(result.lineStarts.sublist(1, result.lineStarts.length - 1));
155 fasta.Token token = result.tokens; 156 fasta.Token token = result.tokens;
156 // The default recovery strategy used by scanString 157 // The default recovery strategy used by scanString
157 // places all error tokens at the head of the stream. 158 // places all error tokens at the head of the stream.
158 while (token.type == TokenType.BAD_INPUT) { 159 while (token.type == TokenType.BAD_INPUT) {
159 translateErrorToken(token, reportError); 160 translateErrorToken(token, reportError);
160 token = token.next; 161 token = token.next;
161 } 162 }
162 firstToken = token; 163 firstToken = token;
163 return firstToken; 164 return firstToken;
164 } 165 }
165 166
166 @override 167 @override
167 set preserveComments(bool preserveComments) { 168 set preserveComments(bool preserveComments) {
168 this._preserveComments = preserveComments; 169 this._preserveComments = preserveComments;
169 } 170 }
170 } 171 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/fasta/token_utils.dart » ('j') | pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698