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('../scanner/scanner_implementation.dart'); | 7 #import('../scanner/scanner_implementation.dart'); |
8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
9 | 9 |
10 #source('../../source.dart'); | 10 #source('../../source.dart'); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } catch (MalformedInputException ex) { | 85 } catch (MalformedInputException ex) { |
86 var message = ex.message; | 86 var message = ex.message; |
87 if (message is !String) message = "unexpected character"; | 87 if (message is !String) message = "unexpected character"; |
88 Token fakeToken = new Token($QUESTION, scanner.charOffset); | 88 Token fakeToken = new Token($QUESTION, scanner.charOffset); |
89 new MyListener(source).error(message, fakeToken); | 89 new MyListener(source).error(message, fakeToken); |
90 throw; | 90 throw; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 List<int> read(String filename) { | 94 List<int> read(String filename) { |
95 File file = new File(filename); | 95 File file = new File(filename).openSync(); |
96 file.openSync(); | |
97 bool threw = true; | 96 bool threw = true; |
98 try { | 97 try { |
99 int size = file.lengthSync(); | 98 int size = file.lengthSync(); |
100 List<int> bytes = new List<int>(size + 1); | 99 List<int> bytes = new List<int>(size + 1); |
101 file.readListSync(bytes, 0, size); | 100 file.readListSync(bytes, 0, size); |
102 bytes[size] = $EOF; | 101 bytes[size] = $EOF; |
103 threw = false; | 102 threw = false; |
104 return bytes; | 103 return bytes; |
105 } finally { | 104 } finally { |
106 try { | 105 try { |
(...skipping 20 matching lines...) Expand all Loading... |
127 ++errorCount; | 126 ++errorCount; |
128 if (token !== null) { | 127 if (token !== null) { |
129 String tokenString = token.toString(); | 128 String tokenString = token.toString(); |
130 int begin = token.charOffset; | 129 int begin = token.charOffset; |
131 int end = begin + tokenString.length; | 130 int end = begin + tokenString.length; |
132 throw new ParserError(file.getLocationMessage(message, begin, end, true)); | 131 throw new ParserError(file.getLocationMessage(message, begin, end, true)); |
133 } | 132 } |
134 throw new ParserError(message); | 133 throw new ParserError(message); |
135 } | 134 } |
136 } | 135 } |
OLD | NEW |