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

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

Issue 9568008: Do not allow native syntax on all libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « dart/frog/tests/leg/src/TypeCheckerTest.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) 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("../../../../lib/uri/uri.dart"); 7 #import("../../../../lib/uri/uri.dart");
8 8
9 #import("../../../leg/elements/elements.dart"); 9 #import("../../../leg/elements/elements.dart");
10 #import("../../../leg/tree/tree.dart"); 10 #import("../../../leg/tree/tree.dart");
11 #import('../../../leg/scanner/scannerlib.dart'); 11 #import('../../../leg/scanner/scannerlib.dart');
12 #import("../../../leg/leg.dart"); 12 #import("../../../leg/leg.dart");
13 #import("../../../leg/util/util.dart"); 13 #import("../../../leg/util/util.dart");
14 14
15 class LoggerCanceler implements DiagnosticListener { 15 class LoggerCanceler implements DiagnosticListener {
16 void cancel([String reason, node, token, instruction]) { 16 void cancel([String reason, node, token, instruction]) {
17 throw new CompilerCancelledException(reason); 17 throw new CompilerCancelledException(reason);
18 } 18 }
19 19
20 void log(message) { 20 void log(message) {
21 print(message); 21 print(message);
22 } 22 }
23 } 23 }
24 24
25 Token scan(String text) => new StringScanner(text).tokenize(); 25 Token scan(String text) => new StringScanner(text).tokenize();
26 26
27 Node parseBodyCode(String text, Function parseMethod) { 27 Node parseBodyCode(String text, Function parseMethod) {
28 Token tokens = scan(text); 28 Token tokens = scan(text);
29 LoggerCanceler lc = new LoggerCanceler(); 29 LoggerCanceler lc = new LoggerCanceler();
30 NodeListener listener = new NodeListener(lc); 30 NodeListener listener = new NodeListener(lc, null);
31 Parser parser = new Parser(listener); 31 Parser parser = new Parser(listener);
32 Token endToken = parseMethod(parser, tokens); 32 Token endToken = parseMethod(parser, tokens);
33 assert(endToken.kind == EOF_TOKEN); 33 assert(endToken.kind == EOF_TOKEN);
34 Node node = listener.popNode(); 34 Node node = listener.popNode();
35 Expect.isNotNull(node); 35 Expect.isNotNull(node);
36 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}'); 36 Expect.isTrue(listener.nodes.isEmpty(), 'Not empty: ${listener.nodes}');
37 return node; 37 return node;
38 } 38 }
39 39
40 Node parseStatement(String text) => 40 Node parseStatement(String text) =>
(...skipping 23 matching lines...) Expand all
64 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); 64 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens));
65 return unit.topLevelElements; 65 return unit.topLevelElements;
66 } 66 }
67 67
68 // TODO(ahe): We define this method to avoid having to import 68 // TODO(ahe): We define this method to avoid having to import
69 // the scanner in the tests. We should move SourceString to another 69 // the scanner in the tests. We should move SourceString to another
70 // location instead. 70 // location instead.
71 SourceString buildSourceString(String name) { 71 SourceString buildSourceString(String name) {
72 return new SourceString(name); 72 return new SourceString(name);
73 } 73 }
OLDNEW
« no previous file with comments | « dart/frog/tests/leg/src/TypeCheckerTest.dart ('k') | dart/tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698