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

Side by Side Diff: pkg/analyzer_experimental/example/parser_driver.dart

Issue 12838003: Rename analyzer-experimental to analyzer_experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 2
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4 // for details. All rights reserved. Use of this source code is governed by a 4 // for details. All rights reserved. Use of this source code is governed by a
5 // BSD-style license that can be found in the LICENSE file. 5 // BSD-style license that can be found in the LICENSE file.
6 6
7 import 'package:analyzer-experimental/src/generated/ast.dart'; 7 import 'package:analyzer_experimental/src/generated/ast.dart';
8 import 'package:analyzer-experimental/src/generated/error.dart'; 8 import 'package:analyzer_experimental/src/generated/error.dart';
9 import 'package:analyzer-experimental/src/generated/java_core.dart'; 9 import 'package:analyzer_experimental/src/generated/java_core.dart';
10 import 'package:analyzer-experimental/src/generated/parser.dart'; 10 import 'package:analyzer_experimental/src/generated/parser.dart';
11 import 'package:analyzer-experimental/src/generated/scanner.dart'; 11 import 'package:analyzer_experimental/src/generated/scanner.dart';
12 12
13 import 'dart:io'; 13 import 'dart:io';
14 14
15 15
16 main() { 16 main() {
17 17
18 print('working dir ${new File('.').fullPathSync()}'); 18 print('working dir ${new File('.').fullPathSync()}');
19 19
20 var args = new Options().arguments; 20 var args = new Options().arguments;
21 if (args.length == 0) { 21 if (args.length == 0) {
22 print('Usage: parser_driver [files_to_parse]'); 22 print('Usage: parser_driver [files_to_parse]');
23 exit(0); 23 exit(0);
24 } 24 }
25 25
26 for (var arg in args) { 26 for (var arg in args) {
27 _parse(new File(arg)); 27 _parse(new File(arg));
28 } 28 }
29 29
30 } 30 }
31 31
32 _parse(File file) { 32 _parse(File file) {
33 var src = file.readAsStringSync(); 33 var src = file.readAsStringSync();
34 var errorListener = new _ErrorCollector(); 34 var errorListener = new _ErrorCollector();
35 var scanner = new StringScanner(null, src, errorListener); 35 var scanner = new StringScanner(null, src, errorListener);
36 var token = scanner.tokenize(); 36 var token = scanner.tokenize();
37 var parser = new Parser(null, errorListener); 37 var parser = new Parser(null, errorListener);
38 var unit = parser.parseCompilationUnit(token); 38 var unit = parser.parseCompilationUnit(token);
39 39
40 var visitor = new _ASTVisitor(); 40 var visitor = new _ASTVisitor();
41 unit.accept(visitor); 41 unit.accept(visitor);
42 42
43 for (var error in errorListener.errors) { 43 for (var error in errorListener.errors) {
44 print(error); 44 print(error);
45 } 45 }
46 } 46 }
47 47
48 class _ErrorCollector extends AnalysisErrorListener { 48 class _ErrorCollector extends AnalysisErrorListener {
49 List<AnalysisError> errors; 49 List<AnalysisError> errors;
50 _ErrorCollector() : errors = new List<AnalysisError>(); 50 _ErrorCollector() : errors = new List<AnalysisError>();
51 onError(error) => errors.add(error); 51 onError(error) => errors.add(error);
52 } 52 }
53 53
54 class _ASTVisitor extends GeneralizingASTVisitor { 54 class _ASTVisitor extends GeneralizingASTVisitor {
55 visitNode(ASTNode node) { 55 visitNode(ASTNode node) {
56 print('${node.runtimeType} : <"${node.toString()}">'); 56 print('${node.runtimeType} : <"${node.toString()}">');
57 return super.visitNode(node); 57 return super.visitNode(node);
58 } 58 }
59 } 59 }
60 60
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/bin/analyzer.dart ('k') | pkg/analyzer_experimental/example/scanner_driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698