| 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 '../../scanner/token.dart' show TokenType; | 7 import '../../scanner/token.dart' show TokenType; |
| 8 | 8 |
| 9 import 'array_based_scanner.dart' show ArrayBasedScanner; | 9 import 'array_based_scanner.dart' show ArrayBasedScanner; |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 int advance() => string.codeUnitAt(++scanOffset); | 36 int advance() => string.codeUnitAt(++scanOffset); |
| 37 int peek() => string.codeUnitAt(scanOffset + 1); | 37 int peek() => string.codeUnitAt(scanOffset + 1); |
| 38 | 38 |
| 39 int get stringOffset => scanOffset; | 39 int get stringOffset => scanOffset; |
| 40 | 40 |
| 41 int currentAsUnicode(int next) => next; | 41 int currentAsUnicode(int next) => next; |
| 42 | 42 |
| 43 void handleUnicode(int startScanOffset) {} | 43 void handleUnicode(int startScanOffset) {} |
| 44 | 44 |
| 45 @override | 45 @override |
| 46 StringToken createSubstringToken(TokenType info, int start, bool asciiOnly, | 46 StringToken createSubstringToken(TokenType type, 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 type, string, start, scanOffset + extraOffset, tokenStart, |
| 50 canonicalize: true); | 50 canonicalize: true); |
| 51 } | 51 } |
| 52 | 52 |
| 53 @override | 53 @override |
| 54 CommentToken createCommentToken(TokenType info, int start, bool asciiOnly, | 54 CommentToken createCommentToken(TokenType type, int start, bool asciiOnly, |
| 55 [int extraOffset = 0]) { | 55 [int extraOffset = 0]) { |
| 56 return new CommentToken.fromSubstring( | 56 return new CommentToken.fromSubstring( |
| 57 info, string, start, scanOffset + extraOffset, tokenStart, | 57 type, string, start, scanOffset + extraOffset, tokenStart, |
| 58 canonicalize: true); | 58 canonicalize: true); |
| 59 } | 59 } |
| 60 | 60 |
| 61 @override | 61 @override |
| 62 DartDocToken createDartDocToken(TokenType info, int start, bool asciiOnly, | 62 DartDocToken createDartDocToken(TokenType type, int start, bool asciiOnly, |
| 63 [int extraOffset = 0]) { | 63 [int extraOffset = 0]) { |
| 64 return new DartDocToken.fromSubstring( | 64 return new DartDocToken.fromSubstring( |
| 65 info, string, start, scanOffset + extraOffset, tokenStart, | 65 type, string, start, scanOffset + extraOffset, tokenStart, |
| 66 canonicalize: true); | 66 canonicalize: true); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool atEndOfFile() => scanOffset >= string.length - 1; | 69 bool atEndOfFile() => scanOffset >= string.length - 1; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Scanner that creates tokens for a part of a larger [String], where the part | 73 * Scanner that creates tokens for a part of a larger [String], where the part |
| 74 * starts at the [baseOffset]. | 74 * starts at the [baseOffset]. |
| 75 */ | 75 */ |
| 76 class SubStringScanner extends StringScanner { | 76 class SubStringScanner extends StringScanner { |
| 77 final int baseOffset; | 77 final int baseOffset; |
| 78 | 78 |
| 79 SubStringScanner(this.baseOffset, String string, | 79 SubStringScanner(this.baseOffset, String string, |
| 80 {bool includeComments: false}) | 80 {bool includeComments: false}) |
| 81 : super(string, includeComments: includeComments); | 81 : super(string, includeComments: includeComments); |
| 82 | 82 |
| 83 @override | 83 @override |
| 84 void beginToken() { | 84 void beginToken() { |
| 85 tokenStart = baseOffset + stringOffset; | 85 tokenStart = baseOffset + stringOffset; |
| 86 } | 86 } |
| 87 } | 87 } |
| OLD | NEW |