| 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 dart2js.scanner.string_scanner; | 5 library dart2js.scanner.string_scanner; |
| 6 | 6 |
| 7 import 'array_based_scanner.dart' show ArrayBasedScanner; | 7 import 'array_based_scanner.dart' show ArrayBasedScanner; |
| 8 | 8 |
| 9 import 'precedence.dart' show PrecedenceInfo; | 9 import 'precedence.dart' show PrecedenceInfo; |
| 10 | 10 |
| 11 import 'token.dart' show StringToken; | 11 import 'token.dart' show CommentToken, DartDocToken, StringToken; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Scanner that reads from a String and creates tokens that points to | 14 * Scanner that reads from a String and creates tokens that points to |
| 15 * substrings. | 15 * substrings. |
| 16 */ | 16 */ |
| 17 class StringScanner extends ArrayBasedScanner { | 17 class StringScanner extends ArrayBasedScanner { |
| 18 /** The file content. */ | 18 /** The file content. */ |
| 19 String string; | 19 String string; |
| 20 | 20 |
| 21 /** The current offset in [string]. */ | 21 /** The current offset in [string]. */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 @override | 44 @override |
| 45 StringToken createSubstringToken( | 45 StringToken createSubstringToken( |
| 46 PrecedenceInfo info, int start, bool asciiOnly, | 46 PrecedenceInfo info, int start, bool asciiOnly, |
| 47 [int extraOffset = 0]) { | 47 [int extraOffset = 0]) { |
| 48 return new StringToken.fromSubstring( | 48 return new StringToken.fromSubstring( |
| 49 info, string, start, scanOffset + extraOffset, tokenStart, | 49 info, string, start, scanOffset + extraOffset, tokenStart, |
| 50 canonicalize: true); | 50 canonicalize: true); |
| 51 } | 51 } |
| 52 | 52 |
| 53 @override |
| 54 CommentToken createCommentToken( |
| 55 PrecedenceInfo info, int start, bool asciiOnly, |
| 56 [int extraOffset = 0]) { |
| 57 return new CommentToken.fromSubstring( |
| 58 info, string, start, scanOffset + extraOffset, tokenStart, |
| 59 canonicalize: true); |
| 60 } |
| 61 |
| 62 @override |
| 63 DartDocToken createDartDocToken( |
| 64 PrecedenceInfo info, int start, bool asciiOnly, |
| 65 [int extraOffset = 0]) { |
| 66 return new DartDocToken.fromSubstring( |
| 67 info, string, start, scanOffset + extraOffset, tokenStart, |
| 68 canonicalize: true); |
| 69 } |
| 70 |
| 53 bool atEndOfFile() => scanOffset >= string.length - 1; | 71 bool atEndOfFile() => scanOffset >= string.length - 1; |
| 54 } | 72 } |
| OLD | NEW |