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

Side by Side Diff: dart/frog/leg/scanner/scanner_task.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/leg/scanner/listener.dart ('k') | dart/frog/leg/universe.dart » ('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 class ScannerTask extends CompilerTask { 5 class ScannerTask extends CompilerTask {
6 ScannerTask(Compiler compiler) : super(compiler); 6 ScannerTask(Compiler compiler) : super(compiler);
7 String get name() => 'Scanner'; 7 String get name() => 'Scanner';
8 8
9 void scan(CompilationUnitElement compilationUnit) { 9 void scan(CompilationUnitElement compilationUnit) {
10 measure(() { 10 measure(() {
11 Link<Element> elements = scanElements(compilationUnit); 11 scanElements(compilationUnit);
12 for (Link<Element> link = elements; !link.isEmpty(); link = link.tail) { 12 for (Element element in compilationUnit.topLevelElements) {
13 Element existing = compiler.universe.find(link.head.name); 13 compiler.universe.define(element, compiler);
14 if (existing !== null) { 14 }
15 Node node = link.head.parseNode(compiler, compiler); 15 for (ScriptTag tag in compilationUnit.tags) {
16 // TODO(ahe): Is this the right place to handle this? 16 compiler.reportWarning(tag, "library tags are not implemented");
17 compiler.cancel('Duplicate definition', node: node);
18 }
19 compiler.universe.define(link.head);
20 } 17 }
21 }); 18 });
22 } 19 }
23 20
24 Link<Element> scanElements(CompilationUnitElement compilationUnit) { 21 void scanElements(CompilationUnitElement compilationUnit) {
25 Script script = compilationUnit.script; 22 Script script = compilationUnit.script;
26 Token tokens; 23 Token tokens;
27 try { 24 try {
28 tokens = new StringScanner(script.text).tokenize(); 25 tokens = new StringScanner(script.text).tokenize();
29 } catch (MalformedInputException ex) { 26 } catch (MalformedInputException ex) {
30 Token token; 27 Token token;
31 var message; 28 var message;
32 if (ex.position is num) { 29 if (ex.position is num) {
33 // TODO(ahe): Always use tokens in MalformedInputException. 30 // TODO(ahe): Always use tokens in MalformedInputException.
34 token = new Token(EOF_INFO, ex.position); 31 token = new Token(EOF_INFO, ex.position);
35 } else { 32 } else {
36 token = ex.position; 33 token = ex.position;
37 } 34 }
38 compiler.cancel(ex.message, token: token); 35 compiler.cancel(ex.message, token: token);
39 } 36 }
40 ElementListener listener = new ElementListener(compiler, compilationUnit); 37 ElementListener listener = new ElementListener(compiler, compilationUnit);
41 PartialParser parser = new PartialParser(listener); 38 PartialParser parser = new PartialParser(listener);
42 parser.parseUnit(tokens); 39 parser.parseUnit(tokens);
43 return listener.topLevelElements;
44 } 40 }
45 } 41 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/listener.dart ('k') | dart/frog/leg/universe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698