OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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.task; | 5 library dart2js.parser.task; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/tasks.dart' show CompilerTask; | 8 import '../common/tasks.dart' show CompilerTask; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../elements/modelx.dart' show ElementX; | 10 import '../elements/modelx.dart' show ElementX; |
11 import '../options.dart' show ParserOptions; | |
12 import '../tokens/token.dart' show Token; | 11 import '../tokens/token.dart' show Token; |
13 import '../tree/tree.dart' show Node; | 12 import '../tree/tree.dart' show Node; |
14 import 'element_listener.dart' show ScannerOptions; | 13 import 'element_listener.dart' show ScannerOptions; |
15 import 'listener.dart' show ParserError; | 14 import 'listener.dart' show ParserError; |
16 import 'node_listener.dart' show NodeListener; | 15 import 'node_listener.dart' show NodeListener; |
17 import 'parser.dart' show Parser; | 16 import 'parser.dart' show Parser; |
18 | 17 |
19 class ParserTask extends CompilerTask { | 18 class ParserTask extends CompilerTask { |
20 final ParserOptions parserOptions; | |
21 final Compiler compiler; | 19 final Compiler compiler; |
22 | 20 |
23 ParserTask(Compiler compiler, this.parserOptions) | 21 ParserTask(Compiler compiler): compiler = compiler, super(compiler.measurer); |
24 : compiler = compiler, | |
25 super(compiler.measurer); | |
26 | 22 |
27 String get name => 'Parser'; | 23 String get name => 'Parser'; |
28 | 24 |
29 Node parse(ElementX element) { | 25 Node parse(ElementX element) { |
30 return measure(() => element.parseNode(compiler.parsingContext)); | 26 return measure(() => element.parseNode(compiler.parsingContext)); |
31 } | 27 } |
32 | 28 |
33 Node parseCompilationUnit(Token token) { | 29 Node parseCompilationUnit(Token token) { |
34 return measure(() { | 30 return measure(() { |
35 NodeListener listener = | 31 NodeListener listener = |
36 new NodeListener(const ScannerOptions(), compiler.reporter, null); | 32 new NodeListener(const ScannerOptions(), compiler.reporter, null); |
37 Parser parser = new Parser(listener, parserOptions); | 33 Parser parser = new Parser(listener); |
38 try { | 34 try { |
39 parser.parseUnit(token); | 35 parser.parseUnit(token); |
40 } on ParserError catch (_) { | 36 } on ParserError catch (_) { |
41 assert(invariant(token, compiler.compilationFailed)); | 37 assert(invariant(token, compiler.compilationFailed)); |
42 return listener.makeNodeList(0, null, null, '\n'); | 38 return listener.makeNodeList(0, null, null, '\n'); |
43 } | 39 } |
44 Node result = listener.popNode(); | 40 Node result = listener.popNode(); |
45 assert(listener.nodes.isEmpty); | 41 assert(listener.nodes.isEmpty); |
46 return result; | 42 return result; |
47 }); | 43 }); |
48 } | 44 } |
49 } | 45 } |
OLD | NEW |