| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of scanner; |
| 6 |
| 5 abstract class Scanner { | 7 abstract class Scanner { |
| 6 Token tokenize(); | 8 Token tokenize(); |
| 7 } | 9 } |
| 8 | 10 |
| 9 /** | 11 /** |
| 10 * Common base class for a Dart scanner. | 12 * Common base class for a Dart scanner. |
| 11 */ | 13 */ |
| 12 abstract class AbstractScanner<T extends SourceString> implements Scanner { | 14 abstract class AbstractScanner<T extends SourceString> implements Scanner { |
| 13 abstract int advance(); | 15 abstract int advance(); |
| 14 abstract int nextByte(); | 16 abstract int nextByte(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 251 |
| 250 if (identical(next, $PERIOD)) { | 252 if (identical(next, $PERIOD)) { |
| 251 return tokenizeDotsOrNumber(next); | 253 return tokenizeDotsOrNumber(next); |
| 252 } | 254 } |
| 253 | 255 |
| 254 if (identical(next, $0)) { | 256 if (identical(next, $0)) { |
| 255 return tokenizeHexOrNumber(next); | 257 return tokenizeHexOrNumber(next); |
| 256 } | 258 } |
| 257 | 259 |
| 258 // TODO(ahe): Would a range check be faster? | 260 // TODO(ahe): Would a range check be faster? |
| 259 if (identical(next, $1) || identical(next, $2) || identical(next, $3) | 261 if (identical(next, $1) || identical(next, $2) || identical(next, $3) |
| 260 || identical(next, $4) || identical(next, $5) || identical(next, $6) | 262 || identical(next, $4) || identical(next, $5) || identical(next, $6) |
| 261 || identical(next, $7) || identical(next, $8) || identical(next, $9)) { | 263 || identical(next, $7) || identical(next, $8) || identical(next, $9)) { |
| 262 return tokenizeNumber(next); | 264 return tokenizeNumber(next); |
| 263 } | 265 } |
| 264 | 266 |
| 265 if (identical(next, $EOF)) { | 267 if (identical(next, $EOF)) { |
| 266 return $EOF; | 268 return $EOF; |
| 267 } | 269 } |
| 268 if (next < 0x1f) { | 270 if (next < 0x1f) { |
| 269 return error(new SourceString("unexpected character $next")); | 271 return error(new SourceString("unexpected character $next")); |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 next = advance(); | 866 next = advance(); |
| 865 } | 867 } |
| 866 return error(const SourceString("unterminated string literal")); | 868 return error(const SourceString("unterminated string literal")); |
| 867 } | 869 } |
| 868 | 870 |
| 869 int error(SourceString message) { | 871 int error(SourceString message) { |
| 870 appendByteStringToken(BAD_INPUT_INFO, message); | 872 appendByteStringToken(BAD_INPUT_INFO, message); |
| 871 return advance(); // Ensure progress. | 873 return advance(); // Ensure progress. |
| 872 } | 874 } |
| 873 } | 875 } |
| OLD | NEW |