| 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 num) { |
| 33 token = new Token(EOF_INFO, ex.message); | 33 // TODO(ahe): Always use tokens in MalformedInputException. |
| 34 message = 'unexpected character'; | 34 token = new Token(EOF_INFO, ex.position); |
| 35 } else { | 35 } else { |
| 36 token = new Token(EOF_INFO, 0); | 36 token = ex.position; |
| 37 message = ex.message; | |
| 38 } | 37 } |
| 39 compiler.cancel(message, token: token); | 38 compiler.cancel(ex.message, token: token); |
| 40 } | 39 } |
| 41 ElementListener listener = new ElementListener(compiler, compilationUnit); | 40 ElementListener listener = new ElementListener(compiler, compilationUnit); |
| 42 PartialParser parser = new PartialParser(listener); | 41 PartialParser parser = new PartialParser(listener); |
| 43 parser.parseUnit(tokens); | 42 parser.parseUnit(tokens); |
| 44 return listener.topLevelElements; | 43 return listener.topLevelElements; |
| 45 } | 44 } |
| 46 } | 45 } |
| OLD | NEW |