OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Parser for Dart code based on the experimental analyzer. | 6 * Parser for Dart code based on the experimental analyzer. |
7 */ | 7 */ |
8 library dart_parser; | 8 library dart_parser; |
9 | 9 |
10 import 'dart:utf'; | 10 import 'dart:utf'; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 var token = scanner.tokenize(); | 133 var token = scanner.tokenize(); |
134 var parser = new Parser(null, errorListener); | 134 var parser = new Parser(null, errorListener); |
135 var unit = parser.parseCompilationUnit(token); | 135 var unit = parser.parseCompilationUnit(token); |
136 | 136 |
137 if (path == null || messages == null) return unit; | 137 if (path == null || messages == null) return unit; |
138 | 138 |
139 // TODO(jmesserly): removed this for now because the analyzer doesn't format | 139 // TODO(jmesserly): removed this for now because the analyzer doesn't format |
140 // messages properly, so you end up with things like "Unexpected token '%s'". | 140 // messages properly, so you end up with things like "Unexpected token '%s'". |
141 // This used to convert parser messages into our messages. Enable this | 141 // This used to convert parser messages into our messages. Enable this |
142 // once analyzer is fixed. | 142 // once analyzer is fixed. |
| 143 // TODO(sigmund): once we enable this, we need to fix compiler.dart to clear |
| 144 // out the output of the compiler if we see compilation errors. |
143 if (false) { | 145 if (false) { |
144 var file = new File.text(path, code); | 146 var file = new File.text(path, code); |
145 for (var e in errorListener.errors) { | 147 for (var e in errorListener.errors) { |
146 var span = file.span(e.offset, e.offset + e.length); | 148 var span = file.span(e.offset, e.offset + e.length); |
147 | 149 |
148 var severity = e.errorCode.errorSeverity; | 150 var severity = e.errorCode.errorSeverity; |
149 if (severity == ErrorSeverity.ERROR) { | 151 if (severity == ErrorSeverity.ERROR) { |
150 messages.error(e.message, span, file: path); | 152 messages.error(e.message, span, file: path); |
151 } else { | 153 } else { |
152 assert(severity == ErrorSeverity.WARNING); | 154 assert(severity == ErrorSeverity.WARNING); |
153 messages.warning(e.message, span, file: path); | 155 messages.warning(e.message, span, file: path); |
154 } | 156 } |
155 } | 157 } |
156 } | 158 } |
157 | 159 |
158 return unit; | 160 return unit; |
159 } | 161 } |
160 | 162 |
161 class _ErrorCollector extends AnalysisErrorListener { | 163 class _ErrorCollector extends AnalysisErrorListener { |
162 final errors = new List<AnalysisError>(); | 164 final errors = new List<AnalysisError>(); |
163 onError(error) => errors.add(error); | 165 onError(error) => errors.add(error); |
164 } | 166 } |
OLD | NEW |