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

Side by Side Diff: frog/leg/scanner/scanner_task.dart

Issue 9190038: Handle escapes in string literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed validation from scanner 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/scanner/scanner_implementation.dart ('k') | frog/leg/scanner/scannerlib.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 Link<Element> elements = scanElements(compilationUnit);
12 for (Link<Element> link = elements; !link.isEmpty(); link = link.tail) { 12 for (Link<Element> link = elements; !link.isEmpty(); link = link.tail) {
13 Element existing = compiler.universe.find(link.head.name); 13 Element existing = compiler.universe.find(link.head.name);
14 if (existing !== null) { 14 if (existing !== null) {
15 // TODO(ahe): Is this the right place to handle this? 15 // TODO(ahe): Is this the right place to handle this?
16 compiler.cancel('Duplicate definition', 16 compiler.cancel('Duplicate definition',
17 token: link.head.dynamic.beginToken); 17 token: link.head.dynamic.beginToken);
18 } 18 }
19 compiler.universe.define(link.head); 19 compiler.universe.define(link.head);
20 } 20 }
21 }); 21 });
22 } 22 }
23 23
24 Link<Element> scanElements(CompilationUnitElement compilationUnit) { 24 Link<Element> scanElements(CompilationUnitElement compilationUnit) {
25 Script script = compilationUnit.script; 25 Script script = compilationUnit.script;
26 Token tokens = new StringScanner(script.text).tokenize(); 26 Token tokens;
27 try {
28 tokens = new StringScanner(script.text).tokenize();
29 } catch (MalformedInputException e) {
30 if (e.message is int) {
31 Token token = new Token(ERROR_INFO, e.message);
32 compiler.cancel('Unexpected character', token: token);
33 throw "Unrecoverable error";
34 }
35 }
27 ElementListener listener = new ElementListener(compiler, compilationUnit); 36 ElementListener listener = new ElementListener(compiler, compilationUnit);
28 PartialParser parser = new PartialParser(listener); 37 PartialParser parser = new PartialParser(listener);
29 parser.parseUnit(tokens); 38 parser.parseUnit(tokens);
30 return listener.topLevelElements; 39 return listener.topLevelElements;
31 } 40 }
32 } 41 }
OLDNEW
« no previous file with comments | « frog/leg/scanner/scanner_implementation.dart ('k') | frog/leg/scanner/scannerlib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698