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

Side by Side Diff: dart/lib/compiler/implementation/tools/mini_parser.dart

Issue 10831293: Update mini_parser.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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('parser'); 5 #library('parser');
6 6
7 #import('dart:io'); 7 #import('dart:io');
8 8
9 #import('../../../utf/utf.dart'); 9 #import('../../../utf/utf.dart');
10 10
11 #import('../elements/elements.dart'); 11 #import('../elements/elements.dart');
12 #import('../scanner/scanner_implementation.dart'); 12 #import('../scanner/scanner_implementation.dart');
13 #import('../scanner/scannerlib.dart'); 13 #import('../scanner/scannerlib.dart');
14 #import('../tree/tree.dart'); 14 #import('../tree/tree.dart');
15 #import('../util/characters.dart'); 15 #import('../util/characters.dart');
16 #import('../source_file.dart');
16 17
17 #source('../diagnostic_listener.dart'); 18 #source('../diagnostic_listener.dart');
18 #source('../../source.dart');
19 #source('../scanner/byte_array_scanner.dart'); 19 #source('../scanner/byte_array_scanner.dart');
20 #source('../scanner/byte_strings.dart'); 20 #source('../scanner/byte_strings.dart');
21 21
22 int charCount = 0; 22 int charCount = 0;
23 Stopwatch stopwatch; 23 Stopwatch stopwatch;
24 24
25 void main() { 25 void main() {
26 filesWithCrashes = []; 26 filesWithCrashes = [];
27 stopwatch = new Stopwatch(); 27 stopwatch = new Stopwatch();
28 MyOptions options = new MyOptions(); 28 MyOptions options = new MyOptions();
29 29
30 void printStats() { 30 void printStats() {
31 int kb = (charCount / 1024).round().toInt(); 31 int kb = (charCount / 1024).round().toInt();
32 String stats = 32 String stats =
33 '$classCount classes (${kb}Kb) in ${stopwatch.elapsedInMs()}ms'; 33 '$classCount classes (${kb}Kb) in ${stopwatch.elapsedInMs()}ms';
34 if (errorCount != 0) { 34 if (errorCount != 0) {
35 stats += ' with $errorCount errors'; 35 stats = '$stats with $errorCount errors';
36 } 36 }
37 if (options.diet) { 37 if (options.diet) {
38 print('Diet parsed $stats.'); 38 print('Diet parsed $stats.');
39 } else { 39 } else {
40 print('Parsed $stats.'); 40 print('Parsed $stats.');
41 } 41 }
42 if (filesWithCrashes.length !== 0) { 42 if (filesWithCrashes.length !== 0) {
43 print('The following ${filesWithCrashes.length} files caused a crash:'); 43 print('The following ${filesWithCrashes.length} files caused a crash:');
44 for (String file in filesWithCrashes) { 44 for (String file in filesWithCrashes) {
45 print(file); 45 print(file);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 } 203 }
204 204
205 String formatError(String message, Token beginToken, Token endToken, 205 String formatError(String message, Token beginToken, Token endToken,
206 SourceFile file) { 206 SourceFile file) {
207 ++errorCount; 207 ++errorCount;
208 if (beginToken === null) return '${file.filename}: $message'; 208 if (beginToken === null) return '${file.filename}: $message';
209 String tokenString = endToken.toString(); 209 String tokenString = endToken.toString();
210 int begin = beginToken.charOffset; 210 int begin = beginToken.charOffset;
211 int end = endToken.charOffset + tokenString.length; 211 int end = endToken.charOffset + tokenString.length;
212 return file.getLocationMessage(message, begin, end, true); 212 return file.getLocationMessage(message, begin, end, true, (x) => x);
213 } 213 }
214 214
215 class MyNodeListener extends NodeListener { 215 class MyNodeListener extends NodeListener {
216 MyNodeListener(SourceFile file, MyOptions options) 216 MyNodeListener(SourceFile file, MyOptions options)
217 : super(new MyCanceller(file, options), null); 217 : super(new MyCanceller(file, options), null);
218 218
219 void beginClassDeclaration(Token token) { 219 void beginClassDeclaration(Token token) {
220 classCount++; 220 classCount++;
221 } 221 }
222 222
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 return stringText; 312 return stringText;
313 } 313 }
314 } 314 }
315 315
316 set text(String newText) { 316 set text(String newText) {
317 throw "not supported"; 317 throw "not supported";
318 } 318 }
319 } 319 }
320 320
321 // Hacks to allow sourcing in ../source.dart:
322 var world = const Mock();
323 var options = const Mock();
324 String _GREEN_COLOR = '\u001b[32m';
325 String _RED_COLOR = '\u001b[31m';
326 String _MAGENTA_COLOR = '\u001b[35m';
327 String _NO_COLOR = '\u001b[0m';
328
329 class Mock { 321 class Mock {
330 const Mock(); 322 const Mock();
331 bool get useColors() => true; 323 bool get useColors() => true;
332 internalError(message) { throw message.toString(); } 324 internalError(message) { throw message.toString(); }
333 } 325 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698