| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('parser_helper'); | 5 #library('parser_helper'); |
| 6 | 6 |
| 7 #import("dart:uri"); | 7 #import("dart:uri"); |
| 8 | 8 |
| 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
| 10 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 10 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 Node parseBodyCode(String text, Function parseMethod) { | 28 Node parseBodyCode(String text, Function parseMethod) { |
| 29 Token tokens = scan(text); | 29 Token tokens = scan(text); |
| 30 LoggerCanceler lc = new LoggerCanceler(); | 30 LoggerCanceler lc = new LoggerCanceler(); |
| 31 Script script = | 31 Script script = |
| 32 new Script( | 32 new Script( |
| 33 new Uri.fromComponents(scheme: "source"), | 33 new Uri.fromComponents(scheme: "source"), |
| 34 new MockFile(text)); | 34 new MockFile(text)); |
| 35 LibraryElement library = new LibraryElement(script); | 35 LibraryElement library = new LibraryElement(script); |
| 36 library.canUseNative = true; | 36 library.canUseNative = true; |
| 37 NodeListener listener = new NodeListener(lc, library); | 37 NodeListener listener = new NodeListener(lc, library.entryCompilationUnit); |
| 38 Parser parser = new Parser(listener); | 38 Parser parser = new Parser(listener); |
| 39 Token endToken = parseMethod(parser, tokens); | 39 Token endToken = parseMethod(parser, tokens); |
| 40 assert(endToken.kind == EOF_TOKEN); | 40 assert(endToken.kind == EOF_TOKEN); |
| 41 Node node = listener.popNode(); | 41 Node node = listener.popNode(); |
| 42 Expect.isNotNull(node); | 42 Expect.isNotNull(node); |
| 43 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); | 43 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); |
| 44 return node; | 44 return node; |
| 45 } | 45 } |
| 46 | 46 |
| 47 Node parseStatement(String text) => | 47 Node parseStatement(String text) => |
| (...skipping 26 matching lines...) Expand all Loading... |
| 74 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); | 74 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); |
| 75 return unit.localMembers; | 75 return unit.localMembers; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // TODO(ahe): We define this method to avoid having to import | 78 // TODO(ahe): We define this method to avoid having to import |
| 79 // the scanner in the tests. We should move SourceString to another | 79 // the scanner in the tests. We should move SourceString to another |
| 80 // location instead. | 80 // location instead. |
| 81 SourceString buildSourceString(String name) { | 81 SourceString buildSourceString(String name) { |
| 82 return new SourceString(name); | 82 return new SourceString(name); |
| 83 } | 83 } |
| OLD | NEW |