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

Side by Side Diff: packages/analyzer/example/parser_driver.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « packages/analyzer/README.md ('k') | packages/analyzer/example/resolver_driver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env dart
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file.
5
6 import 'dart:io';
7
8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/parser.dart';
11 import 'package:analyzer/src/generated/scanner.dart';
12
13 main(List<String> args) {
14 print('working dir ${new File('.').resolveSymbolicLinksSync()}');
15
16 if (args.length == 0) {
17 print('Usage: parser_driver [files_to_parse]');
18 exit(0);
19 }
20
21 for (var arg in args) {
22 _parse(new File(arg));
23 }
24 }
25
26 _parse(File file) {
27 var src = file.readAsStringSync();
28 var errorListener = new _ErrorCollector();
29 var reader = new CharSequenceReader(src);
30 var scanner = new Scanner(null, reader, errorListener);
31 var token = scanner.tokenize();
32 var parser = new Parser(null, errorListener);
33 var unit = parser.parseCompilationUnit(token);
34
35 var visitor = new _ASTVisitor();
36 unit.accept(visitor);
37
38 for (var error in errorListener.errors) {
39 print(error);
40 }
41 }
42
43 class _ASTVisitor extends GeneralizingAstVisitor {
44 visitNode(AstNode node) {
45 print('${node.runtimeType} : <"$node">');
46 return super.visitNode(node);
47 }
48 }
49
50 class _ErrorCollector extends AnalysisErrorListener {
51 List<AnalysisError> errors;
52 _ErrorCollector() : errors = new List<AnalysisError>();
53 onError(error) => errors.add(error);
54 }
OLDNEW
« no previous file with comments | « packages/analyzer/README.md ('k') | packages/analyzer/example/resolver_driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698