Chromium Code Reviews| 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 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 next = nextByte(); | 665 next = nextByte(); |
| 666 } while (next > 127); | 666 } while (next > 127); |
| 667 String string = utf8String(nonAsciiStart, -1).slowToString(); | 667 String string = utf8String(nonAsciiStart, -1).slowToString(); |
| 668 isAscii = false; | 668 isAscii = false; |
| 669 int byteLength = nonAsciiStart - byteOffset; | 669 int byteLength = nonAsciiStart - byteOffset; |
| 670 addToCharOffset(string.length - byteLength); | 670 addToCharOffset(string.length - byteLength); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 | 674 |
| 675 int tokenizeRawString(int next) { | 675 int tokenizeRawString(int next) { |
|
kasperl
2012/08/21 05:40:43
This probably needs a different name now. Is token
ahe
2012/08/21 05:50:36
I think we're changing the syntax for raw strings,
ahe
2012/08/21 10:49:46
Done. Renamed to tokenizeAtOrRawString.
| |
| 676 int start = byteOffset; | 676 int start = byteOffset; |
| 677 next = advance(); | 677 next = advance(); |
| 678 if (next === $DQ || next === $SQ) { | 678 if (next === $DQ || next === $SQ) { |
| 679 return tokenizeString(next, start, true); | 679 return tokenizeString(next, start, true); |
| 680 } else { | 680 } else { |
| 681 throw new MalformedInputException("expected ' or \"", charOffset); | 681 appendPrecedenceToken(AT_INFO); |
| 682 return next; | |
| 682 } | 683 } |
| 683 } | 684 } |
| 684 | 685 |
| 685 int tokenizeString(int next, int start, bool raw) { | 686 int tokenizeString(int next, int start, bool raw) { |
| 686 int quoteChar = next; | 687 int quoteChar = next; |
| 687 next = advance(); | 688 next = advance(); |
| 688 if (quoteChar === next) { | 689 if (quoteChar === next) { |
| 689 next = advance(); | 690 next = advance(); |
| 690 if (quoteChar === next) { | 691 if (quoteChar === next) { |
| 691 // Multiline string. | 692 // Multiline string. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 charOffset); | 827 charOffset); |
| 827 } | 828 } |
| 828 } | 829 } |
| 829 | 830 |
| 830 class MalformedInputException { | 831 class MalformedInputException { |
| 831 final String message; | 832 final String message; |
| 832 final position; | 833 final position; |
| 833 MalformedInputException(this.message, this.position); | 834 MalformedInputException(this.message, this.position); |
| 834 toString() => message; | 835 toString() => message; |
| 835 } | 836 } |
| OLD | NEW |