| 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 #library('parser'); | 5 #library('parser'); |
| 6 | 6 |
| 7 #import('../elements/elements.dart'); | 7 #import('../elements/elements.dart'); |
| 8 #import('../scanner/scanner_implementation.dart'); | 8 #import('../scanner/scanner_implementation.dart'); |
| 9 #import('../scanner/scannerlib.dart'); | 9 #import('../scanner/scannerlib.dart'); |
| 10 #import('../tree/tree.dart'); | 10 #import('../tree/tree.dart'); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 Token scan(MySourceFile source) { | 100 Token scan(MySourceFile source) { |
| 101 Scanner scanner = new ByteArrayScanner(source.rawText); | 101 Scanner scanner = new ByteArrayScanner(source.rawText); |
| 102 try { | 102 try { |
| 103 return scanner.tokenize(); | 103 return scanner.tokenize(); |
| 104 } catch (MalformedInputException ex) { | 104 } catch (MalformedInputException ex) { |
| 105 var message = ex.message; | 105 var message = ex.message; |
| 106 if (message is !String) message = "unexpected character"; | 106 if (message is !String) message = "unexpected character"; |
| 107 Token fakeToken = new Token($QUESTION, scanner.charOffset); | 107 Token fakeToken = new Token($QUESTION, scanner.charOffset); |
| 108 new MyListener(source).error(message, fakeToken); | 108 try { |
| 109 new MyListener(source).error(message, fakeToken); |
| 110 } catch (ParserError ex) { |
| 111 // TODO(ahe): Clean this up, don't throw exceptions. |
| 112 print(ex); |
| 113 } |
| 109 throw; | 114 throw; |
| 110 } | 115 } |
| 111 } | 116 } |
| 112 | 117 |
| 113 void parseFilesFrom(InputStream input, MyOptions options, Function whenDone) { | 118 void parseFilesFrom(InputStream input, MyOptions options, Function whenDone) { |
| 114 void readLine(String line) { | 119 void readLine(String line) { |
| 115 stopwatch.start(); | 120 stopwatch.start(); |
| 116 charCount += parseFile(line, options); | 121 charCount += parseFile(line, options); |
| 117 stopwatch.stop(); | 122 stopwatch.stop(); |
| 118 } | 123 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 String _GREEN_COLOR = '\u001b[32m'; | 269 String _GREEN_COLOR = '\u001b[32m'; |
| 265 String _RED_COLOR = '\u001b[31m'; | 270 String _RED_COLOR = '\u001b[31m'; |
| 266 String _MAGENTA_COLOR = '\u001b[35m'; | 271 String _MAGENTA_COLOR = '\u001b[35m'; |
| 267 String _NO_COLOR = '\u001b[0m'; | 272 String _NO_COLOR = '\u001b[0m'; |
| 268 | 273 |
| 269 class Mock { | 274 class Mock { |
| 270 const Mock(); | 275 const Mock(); |
| 271 bool get useColors() => true; | 276 bool get useColors() => true; |
| 272 internalError(message) { throw message.toString(); } | 277 internalError(message) { throw message.toString(); } |
| 273 } | 278 } |
| OLD | NEW |