OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 | |
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // 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 | 3 // 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. | 4 // BSD-style license that can be found in the LICENSE file. |
6 | 5 |
7 import 'dart:io'; | 6 import 'dart:io'; |
8 | 7 |
9 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
11 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
12 import 'package:analyzer/src/generated/scanner.dart'; | 11 import 'package:analyzer/src/generated/scanner.dart'; |
(...skipping 24 matching lines...) Expand all Loading... |
37 var unit = parser.parseCompilationUnit(token); | 36 var unit = parser.parseCompilationUnit(token); |
38 | 37 |
39 var visitor = new _ASTVisitor(); | 38 var visitor = new _ASTVisitor(); |
40 unit.accept(visitor); | 39 unit.accept(visitor); |
41 | 40 |
42 for (var error in errorListener.errors) { | 41 for (var error in errorListener.errors) { |
43 print(error); | 42 print(error); |
44 } | 43 } |
45 } | 44 } |
46 | 45 |
47 class _ErrorCollector extends AnalysisErrorListener { | |
48 List<AnalysisError> errors; | |
49 _ErrorCollector() : errors = new List<AnalysisError>(); | |
50 onError(error) => errors.add(error); | |
51 } | |
52 | |
53 class _ASTVisitor extends GeneralizingAstVisitor { | 46 class _ASTVisitor extends GeneralizingAstVisitor { |
54 visitNode(AstNode node) { | 47 visitNode(AstNode node) { |
55 print('${node.runtimeType} : <"$node">'); | 48 print('${node.runtimeType} : <"$node">'); |
56 return super.visitNode(node); | 49 return super.visitNode(node); |
57 } | 50 } |
58 } | 51 } |
59 | 52 |
| 53 class _ErrorCollector extends AnalysisErrorListener { |
| 54 List<AnalysisError> errors; |
| 55 _ErrorCollector() : errors = new List<AnalysisError>(); |
| 56 onError(error) => errors.add(error); |
| 57 } |
OLD | NEW |