| 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; | 5 library dart2js.scanner.string; |
| 6 | 6 |
| 7 import '../io/source_file.dart' show | 7 import '../io/source_file.dart' show SourceFile; |
| 8 SourceFile; | 8 import '../tokens/precedence.dart' show PrecedenceInfo; |
| 9 import '../tokens/precedence.dart' show | 9 import '../tokens/token.dart' show StringToken, Token; |
| 10 PrecedenceInfo; | |
| 11 import '../tokens/token.dart' show | |
| 12 StringToken, | |
| 13 Token; | |
| 14 | 10 |
| 15 import 'array_based_scanner.dart' show | 11 import 'array_based_scanner.dart' show ArrayBasedScanner; |
| 16 ArrayBasedScanner; | |
| 17 | |
| 18 | 12 |
| 19 /** | 13 /** |
| 20 * 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 |
| 21 * substrings. | 15 * substrings. |
| 22 */ | 16 */ |
| 23 class StringScanner extends ArrayBasedScanner { | 17 class StringScanner extends ArrayBasedScanner { |
| 24 /** The file content. */ | 18 /** The file content. */ |
| 25 String string; | 19 String string; |
| 26 | 20 |
| 27 /** The current offset in [string]. */ | 21 /** The current offset in [string]. */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 } | 39 } |
| 46 } | 40 } |
| 47 | 41 |
| 48 int advance() => string.codeUnitAt(++scanOffset); | 42 int advance() => string.codeUnitAt(++scanOffset); |
| 49 int peek() => string.codeUnitAt(scanOffset + 1); | 43 int peek() => string.codeUnitAt(scanOffset + 1); |
| 50 | 44 |
| 51 int get stringOffset => scanOffset; | 45 int get stringOffset => scanOffset; |
| 52 | 46 |
| 53 int currentAsUnicode(int next) => next; | 47 int currentAsUnicode(int next) => next; |
| 54 | 48 |
| 55 void handleUnicode(int startScanOffset) { } | 49 void handleUnicode(int startScanOffset) {} |
| 56 | 50 |
| 57 Token firstToken() => tokens.next; | 51 Token firstToken() => tokens.next; |
| 58 Token previousToken() => tail; | 52 Token previousToken() => tail; |
| 59 | 53 |
| 60 void appendSubstringToken(PrecedenceInfo info, int start, | 54 void appendSubstringToken(PrecedenceInfo info, int start, bool asciiOnly, |
| 61 bool asciiOnly, [int extraOffset = 0]) { | 55 [int extraOffset = 0]) { |
| 62 tail.next = new StringToken.fromSubstring(info, string, start, | 56 tail.next = new StringToken.fromSubstring( |
| 63 scanOffset + extraOffset, tokenStart, canonicalize: true); | 57 info, string, start, scanOffset + extraOffset, tokenStart, |
| 58 canonicalize: true); |
| 64 tail = tail.next; | 59 tail = tail.next; |
| 65 } | 60 } |
| 66 | 61 |
| 67 bool atEndOfFile() => scanOffset >= string.length - 1; | 62 bool atEndOfFile() => scanOffset >= string.length - 1; |
| 68 } | 63 } |
| OLD | NEW |