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

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
(Empty)
1 #!/usr/bin/env dart
2
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
5 // BSD-style license that can be found in the LICENSE file.
6
7 import 'package:analyzer-experimental/src/generated/ast.dart';
8 import 'package:analyzer-experimental/src/generated/error.dart';
9 import 'package:analyzer-experimental/src/generated/java_core.dart';
10 import 'package:analyzer-experimental/src/generated/parser.dart';
11 import 'package:analyzer-experimental/src/generated/scanner.dart';
12
13 import 'dart:io';
14
15
16 main() {
17
18 print('working dir ${new File('.').fullPathSync()}');
19
20 var args = new Options().arguments;
21 if (args.length == 0) {
22 print('Usage: parser_driver [files_to_parse]');
23 exit(0);
24 }
25
26 for (var arg in args) {
27 _parse(new File(arg));
28 }
29
30 }
31
32 _parse(File file) {
33 var src = file.readAsStringSync();
34 var errorListener = new _ErrorCollector();
35 var scanner = new StringScanner(null, src, errorListener);
36 var token = scanner.tokenize();
37 var parser = new Parser(null, errorListener);
38 var unit = parser.parseCompilationUnit(token);
39
40 var visitor = new _ASTVisitor();
41 unit.accept(visitor);
42
43 for (var error in errorListener.errors) {
44 print(error);
45 }
46 }
47
48 class _ErrorCollector extends AnalysisErrorListener {
49 List<AnalysisError> errors;
50 _ErrorCollector() : errors = new List<AnalysisError>();
51 onError(error) => errors.add(error);
52 }
53
54 class _ASTVisitor extends GeneralizingASTVisitor {
55 visitNode(ASTNode node) {
56 print('${node.runtimeType} : <"${node.toString()}">');
57 return super.visitNode(node);
58 }
59 }
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