| 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 interface Scanner { | 5 interface Scanner { |
| 6 Token tokenize(); | 6 Token tokenize(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Common base class for a Dart scanner. | 10 * Common base class for a Dart scanner. |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return next; | 622 return next; |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 if (raw) { | 625 if (raw) { |
| 626 return tokenizeSingleLineRawString(next, q, start); | 626 return tokenizeSingleLineRawString(next, q, start); |
| 627 } else { | 627 } else { |
| 628 return tokenizeSingleLineString(next, q, start); | 628 return tokenizeSingleLineString(next, q, start); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 | 631 |
| 632 static bool isHexDigit(int character) { |
| 633 if ($0 <= character && character <= $9) return true; |
| 634 character |= 0x20; |
| 635 return ($a <= character && character <= $f); |
| 636 } |
| 637 |
| 632 int tokenizeSingleLineString(int next, int q1, int start) { | 638 int tokenizeSingleLineString(int next, int q1, int start) { |
| 633 while (next !== $EOF) { | 639 while (next !== $EOF) { |
| 634 if (next === q1) { | 640 if (next === q1) { |
| 635 appendByteStringToken(STRING_INFO, utf8String(start, 0)); | 641 appendByteStringToken(STRING_INFO, utf8String(start, 0)); |
| 636 return advance(); | 642 return advance(); |
| 637 } else if (next === $BACKSLASH) { | 643 } else if (next === $BACKSLASH) { |
| 638 next = advance(); | 644 next = advance(); |
| 639 if (next === $EOF) { | 645 if (next === $EOF) { |
| 640 throw new MalformedInputException(charOffset); | 646 throw new MalformedInputException(charOffset); |
| 641 } | 647 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 715 } |
| 710 return next; | 716 return next; |
| 711 } | 717 } |
| 712 } | 718 } |
| 713 | 719 |
| 714 class MalformedInputException { | 720 class MalformedInputException { |
| 715 final message; | 721 final message; |
| 716 MalformedInputException(this.message); | 722 MalformedInputException(this.message); |
| 717 toString() => message.toString(); | 723 toString() => message.toString(); |
| 718 } | 724 } |
| OLD | NEW |