Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: dart/frog/tests/leg/src/parser_helper.dart

Issue 9283031: Build script tags. (Closed) Base URL: ssh://aaricia.aar/home/ahe/Dart/all/dart.googlecode.com.git@script
Patch Set: Address review comments Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dart/frog/tests/leg/src/mock_compiler.dart ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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('parser_helper'); 5 #library('parser_helper');
6 6
7 #import("../../../leg/elements/elements.dart"); 7 #import("../../../leg/elements/elements.dart");
8 #import("../../../leg/tree/tree.dart"); 8 #import("../../../leg/tree/tree.dart");
9 #import('../../../leg/scanner/scannerlib.dart'); 9 #import('../../../leg/scanner/scannerlib.dart');
10 #import("../../../leg/leg.dart"); 10 #import("../../../leg/leg.dart");
(...skipping 23 matching lines...) Expand all
34 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); 34 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}');
35 return node; 35 return node;
36 } 36 }
37 37
38 Node parseStatement(String text) => 38 Node parseStatement(String text) =>
39 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); 39 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens));
40 40
41 Node parseFunction(String text, Compiler compiler) { 41 Node parseFunction(String text, Compiler compiler) {
42 Element element = parseUnit(text, compiler).head; 42 Element element = parseUnit(text, compiler).head;
43 Expect.equals(ElementKind.FUNCTION, element.kind); 43 Expect.equals(ElementKind.FUNCTION, element.kind);
44 compiler.universe.define(element); 44 compiler.universe.define(element, compiler);
45 return element.parseNode(compiler, compiler); 45 return element.parseNode(compiler, compiler);
46 } 46 }
47 47
48 class MockFile {
49 final filename = '<string>';
50 final text;
51 MockFile(this.text);
52 }
53
48 Link<Element> parseUnit(String text, Compiler compiler) { 54 Link<Element> parseUnit(String text, Compiler compiler) {
49 Token tokens = scan(text); 55 Token tokens = scan(text);
50 ElementListener listener = new ElementListener(compiler, null); 56 var unit = new CompilationUnitElement(new Script(new MockFile(text)), null);
57 ElementListener listener = new ElementListener(compiler, unit);
51 PartialParser parser = new PartialParser(listener); 58 PartialParser parser = new PartialParser(listener);
52 parser.parseUnit(tokens); 59 parser.parseUnit(tokens);
53 return listener.topLevelElements; 60 return unit.topLevelElements;
54 } 61 }
55 62
56 // TODO(ahe): We define this method to avoid having to import 63 // TODO(ahe): We define this method to avoid having to import
57 // the scanner in the tests. We should move SourceString to another 64 // the scanner in the tests. We should move SourceString to another
58 // location instead. 65 // location instead.
59 SourceString buildSourceString(String name) { 66 SourceString buildSourceString(String name) {
60 return new SourceString(name); 67 return new SourceString(name);
61 } 68 }
OLDNEW
« no previous file with comments | « dart/frog/tests/leg/src/mock_compiler.dart ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698