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

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

Issue 2933533002: Add option for printing tokens produced by the scanner. (Closed)
Patch Set: Created 3 years, 6 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 | « 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) 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fasta.scanner.main; 5 library fasta.scanner.main;
6 6
7 import 'io.dart' show readBytesFromFileSync; 7 import 'io.dart' show readBytesFromFileSync;
8 8
9 import '../scanner.dart' show scan; 9 import '../scanner.dart' show scan;
10 10
11 scanAll(Map<Uri, List<int>> files) { 11 scanAll(Map<Uri, List<int>> files) {
12 Stopwatch sw = new Stopwatch()..start(); 12 Stopwatch sw = new Stopwatch()..start();
13 int byteCount = 0; 13 int byteCount = 0;
14 files.forEach((Uri uri, List<int> bytes) { 14 files.forEach((Uri uri, List<int> bytes) {
15 scan(bytes); 15 var token = scan(bytes).tokens;
16 if (const bool.fromEnvironment("printTokens")) {
17 while (!token.isEof) {
18 print("${token.charOffset}: ${token}");
19 token = token.next;
20 }
21 }
16 byteCount += bytes.length - 1; 22 byteCount += bytes.length - 1;
17 }); 23 });
18 sw.stop(); 24 sw.stop();
19 print("Scanning files took: ${sw.elapsed}"); 25 print("Scanning files took: ${sw.elapsed}");
20 print("Bytes/ms: ${byteCount/sw.elapsedMilliseconds}"); 26 print("Bytes/ms: ${byteCount/sw.elapsedMilliseconds}");
21 } 27 }
22 28
23 mainEntryPoint(List<String> arguments) { 29 mainEntryPoint(List<String> arguments) {
24 Map<Uri, List<int>> files = <Uri, List<int>>{}; 30 Map<Uri, List<int>> files = <Uri, List<int>>{};
25 Stopwatch sw = new Stopwatch()..start(); 31 Stopwatch sw = new Stopwatch()..start();
26 for (String name in arguments) { 32 for (String name in arguments) {
27 Uri uri = Uri.base.resolve(name); 33 Uri uri = Uri.base.resolve(name);
28 List<int> bytes = readBytesFromFileSync(uri); 34 List<int> bytes = readBytesFromFileSync(uri);
29 files[uri] = bytes; 35 files[uri] = bytes;
30 } 36 }
31 sw.stop(); 37 sw.stop();
32 print("Reading files took: ${sw.elapsed}"); 38 print("Reading files took: ${sw.elapsed}");
33 scanAll(files); 39 scanAll(files);
34 } 40 }
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