Chromium Code Reviews| OLD | NEW |
|---|---|
| 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(() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 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; | 26 Token tokens; |
| 27 try { | 27 try { |
| 28 tokens = new StringScanner(script.text).tokenize(); | 28 tokens = new StringScanner(script.text).tokenize(); |
| 29 } catch (MalformedInputException ex) { | 29 } catch (MalformedInputException ex) { |
| 30 Token token; | 30 Token token; |
| 31 var message; | 31 var message; |
| 32 if (ex.message is int) { | 32 if (ex.position is int) { |
|
ngeoffray
2012/01/24 09:12:35
This seems fragile if we self-host. To make it rob
ahe
2012/01/24 09:23:54
Done. I've also added a TODO to always use tokens.
| |
| 33 token = new Token(EOF_INFO, ex.message); | 33 token = new Token(EOF_INFO, ex.message); |
| 34 message = 'unexpected character'; | |
| 35 } else { | 34 } else { |
| 36 token = new Token(EOF_INFO, 0); | 35 token = ex.position; |
| 37 message = ex.message; | |
| 38 } | 36 } |
| 39 compiler.cancel(message, token: token); | 37 compiler.cancel(ex.message, token: token); |
| 40 } | 38 } |
| 41 ElementListener listener = new ElementListener(compiler, compilationUnit); | 39 ElementListener listener = new ElementListener(compiler, compilationUnit); |
| 42 PartialParser parser = new PartialParser(listener); | 40 PartialParser parser = new PartialParser(listener); |
| 43 parser.parseUnit(tokens); | 41 parser.parseUnit(tokens); |
| 44 return listener.topLevelElements; | 42 return listener.topLevelElements; |
| 45 } | 43 } |
| 46 } | 44 } |
| OLD | NEW |