OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.parser.diet.task; | 5 library dart2js.parser.diet.task; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/backend_api.dart' show Backend; | 8 import '../common/backend_api.dart' show Backend; |
9 import '../common/tasks.dart' show CompilerTask, Measurer; | 9 import '../common/tasks.dart' show CompilerTask, Measurer; |
10 import '../elements/elements.dart' show CompilationUnitElement; | 10 import '../elements/elements.dart' show CompilationUnitElement; |
11 import '../id_generator.dart'; | 11 import '../id_generator.dart'; |
12 import 'package:dart_scanner/dart_scanner.dart' show Token; | 12 import 'package:dart_scanner/dart_scanner.dart' show Token; |
13 import 'element_listener.dart' show ElementListener, ScannerOptions; | 13 import 'element_listener.dart' show ElementListener, ScannerOptions; |
14 import 'package:dart_parser/dart_parser.dart' show ParserError, TopLevelParser; | 14 import 'package:dart_parser/dart_parser.dart' |
| 15 show Listener, ParserError, TopLevelParser; |
| 16 |
| 17 class DietParser extends TopLevelParser { |
| 18 DietParser(Listener listener) |
| 19 : super(listener); |
| 20 |
| 21 Token parseFormalParameters(Token token) => skipFormalParameters(token); |
| 22 } |
15 | 23 |
16 class DietParserTask extends CompilerTask { | 24 class DietParserTask extends CompilerTask { |
17 final IdGenerator _idGenerator; | 25 final IdGenerator _idGenerator; |
18 final Backend _backend; | 26 final Backend _backend; |
19 final DiagnosticReporter _reporter; | 27 final DiagnosticReporter _reporter; |
20 | 28 |
21 DietParserTask( | 29 DietParserTask( |
22 this._idGenerator, this._backend, this._reporter, Measurer measurer) | 30 this._idGenerator, this._backend, this._reporter, Measurer measurer) |
23 : super(measurer); | 31 : super(measurer); |
24 | 32 |
25 final String name = 'Diet Parser'; | 33 final String name = 'Diet Parser'; |
26 | 34 |
27 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | 35 dietParse(CompilationUnitElement compilationUnit, Token tokens) { |
28 measure(() { | 36 measure(() { |
29 ScannerOptions scannerOptions = new ScannerOptions( | 37 ScannerOptions scannerOptions = new ScannerOptions( |
30 canUseNative: _backend.canLibraryUseNative(compilationUnit.library)); | 38 canUseNative: _backend.canLibraryUseNative(compilationUnit.library)); |
31 ElementListener listener = new ElementListener( | 39 ElementListener listener = new ElementListener( |
32 scannerOptions, _reporter, compilationUnit, _idGenerator); | 40 scannerOptions, _reporter, compilationUnit, _idGenerator); |
33 TopLevelParser parser = new TopLevelParser(listener); | 41 DietParser parser = new DietParser(listener); |
34 try { | 42 try { |
35 parser.parseUnit(tokens); | 43 parser.parseUnit(tokens); |
36 } on ParserError catch (_) { | 44 } on ParserError catch (_) { |
37 // TODO(johnniwinther): assert that the error was reported once there is | 45 // TODO(johnniwinther): assert that the error was reported once there is |
38 // a [hasErrorBeenReported] field in [DiagnosticReporter] | 46 // a [hasErrorBeenReported] field in [DiagnosticReporter] |
39 // The error should have already been reported by the parser. | 47 // The error should have already been reported by the parser. |
40 } | 48 } |
41 }); | 49 }); |
42 } | 50 } |
43 } | 51 } |
OLD | NEW |